Security of network applications Flashcards
Approaches to security of network applications
We have a very poor standard, very weak authn (interceptable pwd) or ip-address based authentication (can be spoofed). And even if stronger systems are used (OTP, challenge response), that prevent problems with authn, there are issues related to data snooping/forging, shadow servers/MITM, replay and filtering.
Approaches to avoid problems:
- Channel security: nodes negotiate encryption algo/keys before communication starts
- Message/data security: each data item is protected (individually) by being wrapped inside a secure container (e.g. PK-SSL).
- Mixed approeach is also possible: secure data inside a secure channel, the secure channel, however, is the preferred choice for applications such as the web.
Apprach to security of net. applications: message/data security
- Message/data security: each data item is protected (individually) by being wrapped inside a secure container (e.g. PK-SSL).
- sender is creating the protection
- data that doesn’t need security is not protected
- only single authn is achieved
- integrity and privacy are self-contained in the message.
- protection remains even if data exits network (and is stored at dest): allows non-repudiation, but requires some modifications to the application.

Approach to security of net. applications: Channel security
- Channel security: nodes negotiate encryption algo/keys before communication starts
- all traffic will be protected by secure channel after set-up.
- can get single or mutual authn, integrity and privacy (since features are negotiated at the start)
- no possibility of non-repudiation when data exits the secure channel
- widely adopted because easy to implement (can be done at OS level), doesn’t require modifications of applications

Internal and External Secuirty to Applications
- Internal:
- each app. implements security internally
- possible implementation errors (inventing sec. protocols is hard)
- doesn’t guarantee interoperability between app.s
- communication channel is the part in common.
- External:
- session would be ideal to implement sec. but TCP/IP doesn’t have one.
- secure session level was proposed: “secure logical channel”
- defacto standard
- uses socket to send data enriched with protection
- simplifies application dev. work
- avoids implementation errors
- app. is free to use it or implement its own sec.

Secure channel products
- SSL/TLS: most widely used, intially SSL -> TLS
- SSH: was successful (when export of crypto products from USA was limited), nowdays is niche.
- PCT: MSFT alternative to SSL. Fiasco.
SSL
Initially SSL (Secure Socket Layer) was proposed by Netspace Communications, that needed a secure protocol to implement e-commerce on the web. SSL is a secure transport channel (session level) with some properties:
-
Peer authn and optionally mutual authn
- compulsory to have server authentication when SSL channel is opened (since it was made for e-commerce).
- possible to do also client authn.
- session level protocol means that username/pwd aren’t required.
- message confidentiality: optional because maybe authn is enough
- message authn and integrity: compulsory, are used to prove who created the message and that the message has not been modified during transmission.
-
replay attack and filtering attack protection
- replay attacks will be detected as weel as filtering attacks (part of the data being deleted)
Success of SSL is based on the fact that is built on top of TCP, making it available to all protocols that use it: HTTP, SMTP, NNTP, FTP, TELNET.
SSL: Authn and integrity
- peer authentication at channel setup:
- server authenticates itself by sending its public key cert. (x.509) and by responding to an implicit asymmetric challenge
- client authn is optional, is done with public key certificate and explicit challenge to prove the possesion of the private key by the client)
- if authn fails the channel is not opened.
- authentication and integrity of data achieved using:
- a keyed-digest (SHA-1 or better) to demonstrate authentication and integrity.
- A message IDentifier (number to avoid reply and cancellations)
- TCP doesn’t deliver to upper levels out-of-order or duplicate packets. So if a packet has a duplicate ID or skipped a number we are under attack.
SSL: confidentiality
- Optional.
- Client generates a session key, that later is used for symmetric encryption of data (RC4, 3DES, IDEA, AES)
- Key exchange with the server occurs via public key cryptography (RSA, Diffie-Hellman or Fortezza-KEA)
TLS connection opening
TLS is a negotiation protocols.
In the security config. parties agree on algorithms/keys.
Next, if they have agreed about a set of algorithms, the server would give back its certificate which must contain the name corresponding to the connected URL. Then, the server must use its private key to implicitly respond a challenge (on the picture there is a simplification, the browser is not sending a challenge).
SSL3 architecture
Base: network protocol (IP), reliable transport protocol (TCP), on top of the latter there’s a record protocol to transmit SSL records (i.e. protected data).
Inside the record protocol there’s application data, altough it it initially used for the handshake protocol.
The change cipher spec protocol is used at the end of the handshake to tell systems that the agreement ended.
Alarm protocol is to signal missing or duplicated packets, or the end of the communication.

SSL session-id
- The identifier is sent by the server, it is used to avoid re-negotiation of crypto parameters of each SSL connection => more connections can be part of the same logical session.
- If the client sends a valid session-id when opening a SSL connection, negotiation is skipped, and data is exchanged securely from then on.
- the server can reject use of session-id (always or according the the validity set by its policy)
Since a typical use of SSL is to request a lot of items from the same server, it becomes computationally expensive to negotiate parameters with the same server at each request.

SSL-3 / TLS record protocol
If large files need to be sent using SSL, packets are fragmented and compressed (only in old versions, it was vulnerable to attacks).
SSL has a maximum packet length of 32KB.
Then a MAC is computed to protected authentication and integrity.
If confidentiality is wanted too, padding is added (to match multiple of block-size).
The packet is then encrypted and the header prepended to make it recognizable as an SSL segment inside TCP.

TLS-1.0 record format
- uint8 type = change_cipher_spec (20), alert (21), handshake (22), application_data (23)
- uint16 version = major (uint8) + minor (uint8)
- uint16 length:
- ≤ 214 (record not compressed) for compatibility with SSL-2
- ≤ 214 + 1024 (compressed records)
- This means that it is a 5-byte header
- Plus a payload of max 16kB

SSL computation of MAC
- MAC = digest_fun(key, seq_number || type || version || length || fragment)
- In order to protect authentication and integrity a MAC is computed with a specific hash function, using the key used during handshake.
- everything is protected.
- Notes:
- changes based on the direction of the message (otherwise we could replay packets sent from client to server as part of server to client.
- seq-number is a 64bits integer that is never transmitted, it’s implcitly calculated. The seq-number allows for a lot of segments, the channel must be closed after exhausted.
SSL/TLS handshake protocol
- Needed to:
- agree on set of algos: integrity and confidentiality
- exchange random numbers between client and server (used for subsequent generation of keys)
- establish a symmetric key by means of public key operations ( RSA, DH, Fortezza)
- Negotiate the session-id: when contacting server multiple times
- exchange necessary certificates

TLS sessions vs connections
- Session:
- logical association between client and server
- created by the Handshake protocol
- defines a set of cyptographic parameters
- is shared by one or more SSL connections
- Connection
- transient tls channel betwen client and server
- assosicated with one specific TLS session

SSL relationship among keys and sessions
The relationship among keys and session between the same client and a server:
- During the handshake two public keys are established:
- pre-master secret (long-term server secret)
- master secret
- When the connection is the first in the session, the pre-master secret is generated.
- After that, the client and the server generate a random number each, combined with the pre-master secret to create the master secret (symmetric operation, e.g. key derivation function)
- Each connection keys for MAC, encryption and the IV are generated by derived by combining the master secret with random values (different for each connection)
- Only persistent thing in the sessione = master secret, generated by the pre-master secret and the random values generated everytime there is a new connection.

Perfect forward secrecy.
- If a certificate is valid for signing and encrypting messages, then it can be used for both authentication and key exchange (asymmetric encryption of session key).
- If an attacker sniffs traffic for a long time and discovers the private key, they will be able to decrypt all traffic: past, present and future.
-
Perfect forward secrecy is achieved when an attacker that discovers the private key can only decrypt present and future traffic.
- To achieve it, we need to use a one-time key for encryption.
- This also imples that the keys used for authentication should be different than the ones used for encryption.
Ephemeral mechanisms to achieve Perfect Forward Secrecy
- Encryption key is a one-time key generated on the fly
- Key must be signed to prove authenticity
- DH is suitable, RSA is not because key generation is too slow (prime numbers…)
- compromise to use RSA = generate 1 key to re-use 10-100 times
- We obtain PFS because the server’s private key is only used for signing the key:
- if (temporary or short-lived) private key is compromised, the attacker can only decrypt traffic generated with it.
- compromise of the long term key is an issue for authentication, but not for confidentiality.
- Modern TLS servers use ECDHE(EC Diffie-Hellman Ephemeral) with on-the-fly generation of DH parameters.
Problem with TLS and virtual servers
- Virtual servers: multiple servers that share the same ip (es. home.myweb.it=1.2.3.4 , food.myweb.it=1.2.3.4) since we are short of ipv4 addresses.
- HTTP/1.1 handles it easily using the Host header.
- Using HTTPS it is diffult, because TLS is activated before HTTP, how can we know which certificate to provide?
- Solutions:
- Collective (wildcard) certificate
- e.g. CN=*myweb.it
- private key shared by all servers
- there are some behavioral non uniformities between browsers
- certificate with a list of servers in subjectAltName (subject alternative name)
- p. key shared by all servers
- need to re-issue certificate at any modification of the list
- use the SNI (Server Name Indication) extension
- in ClientHello (RFC-4366)
- best solution, but limited support by browsers and servers
- Collective (wildcard) certificate
ALPN extension
TLS protects application segments. The application protocol may have various versions, which one should be used?
Application-Layer Protocol Negotation (for TLS-then-proto)
- to speed up connection creation by avoiding additional rountrips due to application level negotiation
- ClientHello asserts ALPN=true + list of supported app protocols
- ServerHello asserts ALPN=true + selected app. protocol
- particularly important to negotiate HTTP/2 and QUIC (UDP-based HTTP), since Chrome and Firefox support HTTP/2 only over TLS.
- also useful for servers that use many application protocols
- possible values are http/1.{0,1}, h2, h2c
DTLS
- TLS had success, why not use the same idea for datagrams (UPD packets)? (TLS can be used only on reliable protocols)
- DTLS is Datagram Transport Layer Security, it applies the same concepts of TLS but for datagrams.
- It doesn’t offer the same features (e.g. protection from replay attacks is impossible)
DTLS competes with IPsec and application security, there are a few option to take into consideration when designing an architecture. For example SIP (VoIP protcol) we could use:
- IPsec (SIP packets over IP)
- TLS (for SIP over TCP)
- DTLS (only for SIP over UDP)
- with secure SIP (app level sec)
How to decide: what’s easier to implement?
TLS downgrade problem
- There are many versions of TSL, SSL 1,2,3, TLS 1.0, 1.1, 1.2.
- Old versions are less secure than modern ones.
- Normal behavior is for the client to send ClientHello message, containing the highest supported version, the server then will reply with the version to be used (ServerHello), which is the highest in common.
- Problem: some servers, instead of doing what described above, just close the connection.
- The client has no choice but to try again with a lower protocol.
- Downgrade attack: attackers sends fake server response to force repeated downgrade until reaching a vulnerable version, in order to execute a suitable attack (e.g. Poodle)
TLS fallback signalling Cipher Suite Value (SCSV)
Extension reported in RFC-7507 to prevent protocol downgrade attacks.
- Achieved using a new (dummy) ciphersuite which is not listing any algorithms, just mentioning TLS_FALLBACK_SCSV that should be sent by the client when opening a downgraded connection (by putting it in the ciphersuite list)
- Example: client proposes 1.1 -> downgrade to 1.0. The response will be se sent with 1.0, but it’s possible to do better, so the ciphersuite list includes FALLBACK_SCSV.
- If it is possible to use a better version, but it isn’t being used, the server sends the value “inappropriate_fallback”.
- if there was an error, the channel is closed, and the cliend should retry with its highest protocol version.
Many servers don’t support SCSV, but most have fixed their bad behavior, now browsers can disable insecure downgrade (since 2015/2016).





