Module 1-NCS
Module 1-NCS
Module 1-NCS
Institute of Technology
(Approved by AICTE, Affiliated to VTU, ISO 9001:2008 certified
and accredited as grade A Institution by NAAC)
Post box no. 7087, 27th cross, 12th Main,
Banashankari II Stage, Bengaluru- 560070, INDIA
Ph: 91-80- 26711780/81/82 Email: principal@bnmit.in, bnmitprincipal@gmail.com, www.bnmit.org
1. List different types of threats and consequence when using the web. Also countermeasures to
be taken.
2. Briefly explain various web traffic security approaches
3. Explain secure socket layer (SSL) protocol stack with a neat diagram and define the different
parameters used in session and connection states.
4. Discuss security socket layer (SSL) record protocol in terms of fragmentation, compression and
encryption.
5. Explain Change Cipher Spec, Alert Protocol and Handshake Protocols
6. Explain the alert signals used in alert protocols
7. Explain the various phases of SSL handshake protocol. / With a diagram, explain handshake
protocol action.
8. Briefly explain, TLS alert codes
9. Briefly explain HTTPS, connection initiation and connection closure in HTTPS.
10. With diagram explain SSH Protocol Stack
11. With diagram explain the steps involved in SSH Transport Layer Protocol Packet Exchanges
12. Explain SSH TLP packet format
13. Explain the steps involved in SSH User Authentication Protocol message Exchanges
14. Briefly explain the authentication methods used in SSH User Authentication Protocol
15. Explain the steps involving in Connection Protocol Message Exchange
16. Explain the different types of channels recognized in SSH connection Protocol specification
17. Explain Port forwarding in SSH protocol
1. List different types of threats and consequence when using the web. Also countermeasures
to be taken.
Table 1 provides a summary of the types of security threats faced when using the Web. One way to
group these threats is in terms of passive and active attacks.
Passive attacks include eavesdropping on network traffic between browser and server and gaining
access to information on a Web site that is supposed to be restricted. Active attacks include
impersonating another user, altering messages in transit between client and server, and altering
information on a Web site. Another way to classify Web security threats is in terms of the location
of the threat: Web server, Web browser, and network traffic between browser and server.
Number of approaches are possible to providing Web security. The various approaches are similar
in the services they provide and, to some extent, in the mechanisms that they use, but they differ
with respect to their scope of applicability and their relative location within the TCP/IP protocol
stack.
Figure 1.1 Relative Locations of Security Facilities in the TCP/IP Protocol Stack
Figure 1.1 illustrates the different approaches. One way to provide Web security is to use IP
security (IPsec) (Figure 1.1a).The advantage of using IPsec is that it is transparent to end users and
applications and provides a general-purpose solution. IPsec includes a filtering capability so that
only selected traffic need incur the overhead of IPsec processing.
Another relatively general-purpose solution is to implement security just above TCP (Figure 1.1b).
The foremost example of this approach is the Secure Sockets Layer (SSL) and the follow-on
Internet standard known as Transport Layer Security (TLS). At this level, there are two
implementation choices. For full generality, SSL (or TLS) could be provided as part of the
underlying protocol suite and therefore be transparent to applications. Alternatively, SSL can be
embedded in specific packages. For example, Netscape and Microsoft Explorer browsers come
equipped with SSL, and most Web servers have implemented the protocol.
Application-specific security services are embedded within the particular application. Figure 1.1c
shows examples of this architecture. The advantage of this approach is that the service can be
tailored to the specific needs of a given application.
3. Explain secure socket layer (SSL) protocol stack with a neat diagram and define the
different parameters used in session and connection states.
The SSL Record Protocol provides basic security services to various higher layer protocols. In
particular, the Hypertext Transfer Protocol (HTTP), which provides the transfer service for Web
client/server interaction, can operate on top of SSL. Three higher-layer protocols are defined as
part of SSL: the Handshake Protocol, The Change Cipher Spec Protocol, and the Alert Protocol.
These SSL specific protocols are used in management of SSL exchanges.
SSL Concepts: Two important SSL concepts are the SSL session and the SSL connection, which
are defined in the specification as follows.
➢ Connection: A connection is a transport that provides a suitable type of service. For SSL, such
connections are peer-to-peer relationships. The connections are transient. Every connection
associated with one session.
➢ Session: An SSL session is an association between a client and a server. Sessions are created by
the Handshake Protocol. Sessions define a set of cryptographic security parameters which can
be shared among multiple connections. Sessions are used to avoid the expensive negotiation of
new security parameters for each connection.
Parameters used in session state:
➢ Session identifier: An arbitrary byte sequence chosen by the server to identify an active or
resumable session state.
➢ Peer certificate: An X509.v3 certificate of the peer. This element of the state may be null.
➢ Compression method: The algorithm used to compress data prior to encryption.
➢ Cipher spec: Specifies the bulk data encryption algorithm (such as null, AES, etc.) and a hash
algorithm (such as MD5 or SHA-1) used for MAC calculation. It also defines cryptographic
attributes such as the hash size.
➢ Master secret: 48-byte secret shared between the client and the server.Is resumable: A flag
indicating whether the session can be used to initiate new connections.
Parameters used in connection states:
➢ Server and client random: Byte sequences that are chosen by the server and client for each
connection.
➢ Server write MAC secret: The secret key used in MAC operations on data sent by the server.
➢ Client write MAC secret: The secret key used in MAC operations on data sent by the client.
➢ Server write key: The secret encryption key for data encrypted by the server and decrypted by
the client.
➢ Client write key: The symmetric encryption key for data encrypted by the client and decrypted
by the server.
➢ Initialization vectors: When a block cipher in CBC mode is used, an initialization vector (IV)
is maintained for each key. This field is first initialized by the SSL Handshake Protocol.
➢ Sequence numbers: Each party maintains separate sequence numbers for transmitted and
received messages for each connection. When a party sends or receives a change cipher spec
message, the appropriate sequence number is set to zero. Sequence numbers may not exceed
(264 – 1).
The SSL record protocol provides two services for SSL connections Confidentiality and Message
Integrity. Figure 1.3 indicates the overall operation of SSL Record Protocol. The Record Protocol
takes an application message to be transmitted, fragments the data into manageable blocks,
optionally compresses the data, applies a MAC, encrypts, adds a header, and transmits the resulting
unit in a TCP segment.
The first step is Fragmentation. Each upper-layer message fragmented into blocks of 214 bytes
(16384 bytes) or less. Next Compression is optionally applied. Compression must be lossless and
may not increase the content length by more than 1024 bytes. The next step in processing is to
compute a message authentication code over the compressed data. For this purpose, a shared secret
key is used. The calculation is defined as
For block encryption, padding may be added after the MAC prior to encryption. The padding is in
the form of a number of padding bytes followed by a one-byte indication of length of padding. The
total amount of padding is the smallest amount such that the total size of data to be encrypted is a
multiple of the cipher’s block length.
The final step of SSL Record Protocol processing is to prepare a header consisting of the following
fields:
➢ Content Type (8 bits): The higher-layer protocol used to process the enclosed fragment.
➢ Major Version (8 bits): Indicates major version of SSL in use. For SSLv3, the value is 3.
➢ Minor Version (8 bits): Indicates minor version in use. For SSLv3, the value is 0.
➢ Compressed Length (16 bits): The length in bytes of the plaintext fragment (or compressed
fragment if compression is used).The maximum value is 214+2048 .
The Change Cipher Spec Protocol is one of the three SSL-specific protocols that use the SSL
Record Protocol, and it is the simplest. This protocol consists of a single message (Figure 1.4a),
which consists of a single byte with the value 1.The sole purpose of this message is to cause the
pending state to be copied into the current state, which updates the cipher suite to be used on this
connection.
The Alert Protocol is used to convey SSL-related alerts to the peer entity. As with other
applications that use SSL, alert messages are compressed and encrypted, as specified by the current
state. Each message in this protocol consists of two bytes (Figure 1.4b). The first byte takes the
value warning (1) or fatal (2) to convey the severity of the message. If the level is fatal, SSL
immediately terminates the connection. Other connections on the same session may continue, but
no new connections on this session may be established. The second byte contains a code that
indicates the specific alert.
The most complex part of SSL is the Handshake Protocol. This protocol allows the server and
client to authenticate each other and to negotiate an encryption and MAC algorithm and
cryptographic keys to be used to protect data sent in an SSL record. The Handshake Protocol is used
before any application data is transmitted. The Handshake Protocol consists of a series of messages
exchanged by client and server. All of these have the format shown in Figure 1.5. Each message has
three fields:
Figure 1.6 below shows the initial exchange needed to establish a logical connection between
client and server. There are four phases of SSL handshake protocol.
Phase 1: Establish Security Capabilities
Phase 2: Server Authentication and Key Exchange
Phase 3: Client Authentication and Key Exchange
Phase 4: Finish
After sending the client_hello message, the client waits for the server _ hello message, which
contains the same parameters as the client _ hello message. The parameters contain the values
which client had sent to the server and the server has chosen to use.
The principal difference seen by a user of a Web browser is that URL (uniform resource locator)
addresses begin with https:// rather than http://. A normal HTTP connection uses port 80. If
HTTPS is specified, port 443 is used, which invokes SSL.
When HTTPS is used, the following elements of the communication are encrypted:
➢ URL of the requested document
➢ Contents of the document
➢ Contents of browser forms (filled in by browser user)
➢ Cookies sent from browser to server and from server to browser
➢ Contents of HTTP header
Connection Initiation: For HTTPS, the agent acting as the HTTP client also acts as the TLS
client. The client initiates a connection to the server on the appropriate port and then sends the
TLS Client Hello to begin the TLS handshake. When the TLS handshake has finished, the client
may then initiate the first HTTP request. All HTTP data is to be sent as TLS application data.
there are three levels of awareness of a connection in HTTPS. At the HTTP level, an HTTP
client requests a connection to an HTTP server by sending a connection request to the next
lowest layer. Typically, the next lowest layer is TCP, but it also may be TLS/SSL. At the level
of TLS, a session is established between a TLS client and a TLS server. This session can
support one or more connections at any time
Connection Closure: An HTTP client or server can indicate the closing of a connection by
including the following line in an HTTP record: Connection: close. This indicates that the
connection will be closed after this record is delivered. The closure of an HTTPS connection
requires that TLS close the connection with the peer TLS entity on the remote side, which will
involve closing the underlying TCP connection. At the TLS level, the proper way to close a
connection is for each side to use the TLS alert protocol to send a close_notify alert. TLS
implementations must initiate an exchange of closure alerts before closing a connection. A TLS
implementation may, after sending a closure alert, close the connection without waiting for the
peer to send its closure alert, generating an “incomplete close”. HTTP clients also must be able
to cope with a situation in which the underlying TCP connection is terminated without a prior
close_notify alert and without a Connection: close indicator. Such a situation could be due to a
programming error on the server or a communication error that causes the TCP connection to
drop.
SSH is organized as three protocols as shown in figure 1.7, that typically run on top of TCP
➢ Transport Layer Protocol: Provides server authentication, data confidentiality, and data
integrity with forward secrecy (i.e., if a key is compromised during one session, the
knowledge does not affect the security of earlier sessions).The transport layer may
optionally provide compression.
➢ User Authentication Protocol: Authenticates the user to the server.
➢ Connection Protocol: Multiplexes multiple logical communications channels over a
single, underlying SSH connection.
11. With diagram explain the steps involved in SSH Transport Layer Protocol Packet
Exchanges
Figure 1.8 illustrates the sequence of events in the SSH Transport Layer Protocol. First, the
client establishes a TCP connection to the server. This is done via the TCP protocol and is not
part of the Transport Layer Protocol. Once the connection is established, the client and server
exchange data, referred to as packets, in the data field of a TCP segment.
➢ The first step in packet exchange is identification string exchange, begins with the client
sending a packet with an identification string of the form:
SSH-protoversion-softwareversion SP comments CR LF
Where SP, CR, and LF are space character, carriage return, and line feed, respectively.
➢ Next is algorithm negotiation. Each side sends an SSH_MSG_KEXINIT containing lists of
supported algorithms in the order of preference to the sender. There is one list for each type of
cryptographic algorithm. The algorithms include key exchange, encryption, MAC algorithm,
and compression algorithm.
➢ The next step is key exchange. The specification allows for alternative methods of key
exchange, but at present, only two versions of Diffie-Hellman key exchange are specified.
Both versions are defined in RFC 2409 and require only one packet in each direction.
➢ The end of key exchange is signaled by the exchange of SSH_MSG_NEWKEYS packets
➢ The final step is service request. The client sends an SSH_MSG_ SERVICE_REQUEST
packet to request either the User Authentication or the Connection Protocol. Subsequent to
this, all data is exchanged as the payload of an SSH Transport Layer packet, protected by
encryption and MAC.
12. Explain SSH TLP packet format
Each SSH packet is in the following format
➢ Packet length: Length of the packet in bytes, not including the packet length and MAC
fields.
➢ Padding length: Length of the random padding field.
➢ Payload: Useful contents of the packet. Prior to algorithm negotiation, this field is
uncompressed. If compression is negotiated, then in subsequent packets, this field is
compressed.
➢ Random padding: Once an encryption algorithm has been negotiated, this field is added. It
contains random bytes of padding so that that total length of the packet (excluding the MAC
field) is a multiple of the cipher block size, or 8 bytes for a stream cipher.
➢ Message authentication code (MAC): If message authentication has been negotiated, this
field contains the MAC value. The MAC value is computed over the entire packet plus a
sequence number, excluding the MAC field. The sequence number is an implicit 32-bit packet
sequence that is initialized to sequence number is an implicit 32-bit packet sequence that is
initialized to zero for the first packet and incremented for every packet. The sequence number
is not included in the packet sent over the TCP connection.
13. Explain the steps involved in SSH User Authentication Protocol message Exchanges
14. Briefly explain the authentication methods used in SSH User Authentication Protocol
In SSH User Authentication Protocol the server may require one or more of the following
authentication methods.
➢ Publickey: The details of this method depend on the public-key algorithm chosen. In
essence, the client sends a message to the server that contains the client’s public key, with
the message signed by the client’s private key. When the server receives this message, it
checks whether the supplied key is acceptable for authentication and, if so, it checks whether
the signature is correct.
➢ Password: The client sends a message containing a plaintext password, which is protected
by encryption by the Transport Layer Protocol.
➢ Hostbased: Authentication is performed on the client’s host rather than the client itself.
Thus, a host that supports multiple clients would provide authentication for all its clients.
This method works by having the client send a signature created with the private key of the
client host. Thus, rather than directly verifying the user’s identity, the SSH server verifies
the identity of the client host and then believes the host when it says the user has already
authenticated on the client side.
15. Explain the steps involving in Connection Protocol Message Exchange
The SSH connection protocol runs on the top of the SSH transport layer protocol and assumes
that a secure authentication connection is in use. All types of communication using SSH, such
as terminal session, are supported using separate channels. Either side may open a channel. The
life of a channel progresses through three stages: Opening a channel, data transfer and closing a
channel.
When either side wishes to open a new channel, it allocates a local number for the channel and
then sends a message of form:
Byte SSH_MSG_CHANNEL_OPEN
String channel type
Uint32 sender channel
Unit32 initial window size
Unit32 maximum packet size
Where uint32 means unsigned 32 bit integer. The channel type identifies the application of this
channel. The sender channel is local channel number. The initial window size specifies how
many bytes of channel data can be sent to the sender of this message without adjusting the
window.
If the remote side is able to open the channel, it returns SSH_MSG_CHANNEL_OPEN_
CONFIRMATION message, which include the sender channel number, the recipient channel
number and window packet size values for incoming traffic. Otherwise, the remote side returns
a SSH_MSG_CHANNEL_OPEN_FAILURE message with a reason code indicating the reasin
for failure.
16. Explain the different types of channels recognized in SSH connection Protocol
specification
➢ session: The remote execution of a program. The program may be a shell, an application
such as file transfer or e-mail, a system command, or some built-in subsystem. Once a
session channel is opened, subsequent requests are used to start the remote program.
➢ x11: This refers to the X Window System, a computer software system and network
protocol that provides a graphical user interface (GUI) for networked computers.X allows
applications to run on a network server but to be displayed on a desktop machine.
➢ forwarded-tcpip: This is remote port forwarding, as explained in the next subsection.
➢ direct-tcpip: This is local port forwarding, as explained in the next subsection.
17. Explain Port forwarding in SSH protocol.
Figure 1.11 illustrates the basic concept behind port forwarding. Here the client application is
identified by port number x and a server application by a port number. At some point, the client
application invokes the local TCP entry and requests a connection to the remote server on y. the
local TCP entry negotiates a TCP connection with remote TCP entry, such that the connection links
local port x to remote port y.
To secure this connection, SSH is configured so that the SSH Transport layer protocol establishes a
TCP connection between SSH client and server entries with TCP port number A and b,
respectively. A secure SSH channel is established over this TCP connection. Traffic from the client
at port x is redirected to local SSH entity and travels through the tunnel where the remote SSH
entity delivers the data to the server application on port . Traffic in the other direction is similarly
redirected.
SSH supports two types of port forwarding: local forwarding and remote forwarding. Local
forwarding allows the client to set up a “hijacker” process. This will intercept selected application-
level traffic and redirect it from an unsecured TCP connection to a secure SSH tunnel. SSH is
configured to listen on selected ports. SSH grabs all traffic using a selected port and sends it
through an SSH tunnel. On the other end, the SSH server sends the incoming traffic to the
destination port dictated by the client application.
With remote forwarding, the user’s SSH client acts on the server’s behalf. The client receives
traffic with a given destination port number, places the traffic on the correct port and sends it to the
destination the user chooses.
18