Cryptographic Protocols

Definition

Communication protocol

rules for data transmission in a network. i.e. HTTP

Cryptographic protocol

communication protocol for encrypted messages.

used in: e-banking, e-commerce, file sharing, online messengers

Cryptography is not enough: the attacker can circumvent cryptography and break the protocol.

Possible flaws can be in the:

  • Protocol design / implementation
  • Encryption design

Automated Protocol Analysis

Protocols are complicated and attacks are difficult to find. We need Automatation, formal proofs.

Requirements:

  1. Specification language for the protocol (= process calculus: λ\lambda -Calculus, π\pi -Calculus)
  1. Formal definition of Security
  1. Automated security analysis (ProVerif)

Attacks

Interleaving Attack

Message from one protocol-session is used in other ones.

Reflection Attack

(Subtype of Interleaving attack)

Message sent back to the person that generated it (in a different session).

Problem: (If we are using symmetric encryption) the sender can not verify who sent the message.

Solution: Identifier (sender / receivers name)

A{A,Give E 1000€}kB A -\{\textcolor{pink}A,\text{Give } E \text{ 1000€}\}_k \rarr B 

Replay Attack

(Subtype of Interleaving attack)

Duplicate of message re-sent at a different time.

Problem: we cant verify the freshness of the received message.

Solution 1: timestamptt(issues with time zones, synchronization)

A{A,Give E 1000€,t}kB A -\{A,\text{Give } E \text{ 1000€},\textcolor{pink}t\}_k \rarr B 

Solution 2: noncenn

AnBBA \longleftarrow \textcolor{pink}{n_B} -B Challenge / Request

A{A,Give E 1000€,nB}kB A -\{A,\text{Give } E \text{ 1000€},\textcolor{pink}{n_B}\}_k \rarr B  Response

Man-in-the-middle Attack

Needham-Shroeder Protocol

Uses nonces nn , Asymmetric encryption to exchange symmetric keys.

Because public keys / nonces are for specific sessions, we don't need identifiers (except for the first message or else someone could respond faster thanBBusingpkApk_Afrom that session).

A{B,nB}pkABA \larr \{B, n_B\}_{pk_A} - B

A{nB,nA}pkBBA - \{n_B, n_A\}_{pk_B} \rarr B

A{nA}pkABA \larr \{n_A\}_{pk_A} - B

Man-in-the-middle Attack

The victim BB then thinks he is communicating with \bigcirc but he is actually communicating with AA .

The attacker has access to nA,nBn_A,n_B and can decrypt all messages from BB .

A{B,nB}pkA{B,nB}pkB A \larr \{B, n_B\}_{pk_A} - \bigcirc \larr \{B, n_B\}_{pk_\bigcirc} - B Attacker reads Bobs messages, has hisnBn_B.

A{nB,nA}pkBBA - \{n_B, n_A\}_{pk_B}\rarr B

A{nA}pkA{nA}pkB A \larr \{n_A\}_{pk_A} - \bigcirc \larr \{n_A\}_{pk_\bigcirc} - B Attacker getsnAn_Afrom Bob.

Solution: Needham-Schroeder-Lowe Protocol

A{B,nB}pkABA \larr \{B, n_B\}_{pk_A} - B

A{A,nB,nA}pkBBA - \{\textcolor{pink}A,n_B, n_A\}_{pk_B} \rarr B(new identifier!)

A{nA}pkABA \larr \{n_A\}_{pk_A} - B

Then the attack is not possible because bob does not think he is talking to \bigcirc anymore.

Applied Pi-Calculus

Highly abstracted mathematical descriptions for concurrent computation.

Very simple, only based on functions, no side-effects, only focused on communication.

Considers cryptography as flawless.

Example: Digital Signature

We want to model AA using a digital signature that can be verified with a pkpk .

AnB —–BA \longleftarrow n_B \text{ -----} B

A — {B,nB,nA}skABA \text{ --- } \{B, n_B, n_A\}_{sk_A}\rarr B

whereskA:=sk(kA)sk_A := sk(k_A)

We can express the entire digital signature encryption as

ver(sign(x,sk(k)),vk(k))x \operatorname{ver}(\operatorname{sign}(x, s k(k)), v k(k)) \rarr x 

Below we usedkAk_Aforkk.

And model the process the following way

Systemnew kA.(InitResp)System \triangleq\text{new }k_A. (Init \mid Resp)

Initnew nB.out(c,nB).in(c,x).let(=B,=nB,z)=ver(x,vk(kA)) in P Init\triangleq \text {new } n_B. \operatorname{out}(c, n_B) . \operatorname{in}(c, x).\text{let} (=B,=n_B, z)=\text{ver}(x, \text{vk}(k_{A})) \text { in } P 

Respin(c,x).new nA.out(c,sign((B,x,nA),sk(kA))) Resp \triangleq \text{in}(c,x).\text{new }n_A. \operatorname{out}(c, \textcolor{pink}{\text{sign}((B, x, n_A), \text{sk}(k_{A}))}) 

Example: Pairs

We have the following process:

new s.( out(a,pair(M,s))in(a,x).if snd(x)=s then out(b,fst(x))) \text{new }s.(\text { out}(a, \operatorname{pair}(M, s)) \mid \operatorname{in}(a, x) \text {.if } \operatorname{snd}(x)=s \text { then out}(b, \operatorname{fst}(x))) 

Run these two processes concurrently:

  • Send(M,s)(M,s)to channelaa
  • Receive(M,s)(M',s')from channelaa, ifsss'\equiv sthen sendMM'to channelbb

We have an attacker:

in(a,x). out(a,pair(N,snd(x))) \operatorname{in}(a, x) . \text { out}(a, \operatorname{pair}(N, \operatorname{snd}(x))) 

Receive(X,s)(X,s'')on channelaa, then send(N,s)(N,s'')on channelaa.

Question: Can our process output anything different than MM with / without the attacker?

Answer: Without the attacker only MM is put out , but with the attacker alsoNN.

Example: Hashes

h(M)h(M) hashes data and outputs a bit string.

We have a modified hash function:

 new s.(out(a,pair(M,h(pair(s,M))))in(a,x). if h(pair(s,fst(x)))=snd(x) then out (b,fst(x))) \text { new } s .\left(\begin{array}{l}\text {out}(a, \operatorname{pair}(M, h(\operatorname{pair}(s, M)))) \mid \\\operatorname{in}(a, x) . \text { if } h(\operatorname{pair}(s, \operatorname{fst}(x)))=\operatorname{snd}(x) \text { then out }(b, \operatorname{fst}(x))\end{array}\right) 

Run these two processes concurrently:

  • Send(M,h((s,M)))(M, h((s,M)))to channelaa
  • Receive(M,y)(M', y)from channelaa, ifh(s,M)yh(s,M') \equiv ythen sendMM'to channelbb

Question: Is this function secure?

Answer: Yes - ss is kept a secret and the attacker can not forge h(pair(s,N))h(pair(s,N))

Basic Security Goals

There are many more properties, but we only focus on these.

Secrecy

Only authorized end-points should be able to read messages.

Secrecy is undecidable - infinite number of opponents OO . (automatized proofs with tools possible).


Protocol PP preserves secercy of MM \Lrarr

O,cfn(O):PO\forall O,~ c\in fn(O): ~P \mid O does not output MM on channel cc .

Where channelccis a free name (public) known to processOO.

If the attacker can not outputMM, it has no access to it.

Integrity

The recipient of a message should be able to determine changes during transmission.

Sender and receiver should agree on their roles.

Authenticity

For authentication we have to introduce a new process:

event p(M)\text{event} ~ p(M)Event process: This processppglobally logsMM.

We use these events to log authentication / acceptance of requests :

event begin(A,B,M)\text{event} ~ {begin}(A, B, M)start of authentication request fromAAtoBBfor messageMM

event end(A,B,M)\text{event} ~ { end }(A, B, M)acceptance of request byBB

Non-Injective Agreement


Formally

PP guarantees noninjective agreement iff:

O:PO new aundefined.(event end(A,B,M)Q) \forall O: \quad P \mid O \rightarrow^{*} \text { new } \widetilde{a} .(\text {event } {end}(A, B, M) \mid Q) \implies 

Q event begin(A,B,M)QQ \equiv \text { event } {begin}(A, B, M) \mid Q^{\prime}

Injective Agreement

Formally

PP guarantees noninjective agreement iff:

O:PO new aundefined.(event end(A,B,M)Q) \forall O: \quad P \mid O \rightarrow^{*} \text { new } \widetilde{a} .(\text {event } {end}(A, B, M) \mid Q) \implies 

(Q event begin(A,B,M)Q)new a~.Q \bigg(Q \equiv \text { event } {begin}(A, B, M) \mid Q^{\prime} \bigg) \wedge \text {new } \tilde{a}.Q^{\prime}  guarantees injective agreement.

Challenge-Response Nonce Handshakes

Handshake Implementations: (Challenge/Request - Response)

Reminder: we place loggers before and after each authentication / acceptance of requests.

When a direction is mentioned in which an injective agreement is given that means that the freshness of the received nonce can be verified by the receiver.

PC Handshake

Symmetric version

AnBBA \larr n_B -B

A{A,m,nB}kABBA - \{\textcolor{pink}A,m,n_B\}_{k_{AB}} \rarr B(kABk_{AB}= symmetrical key)(Injective)

Asymmetric version

Identifier was changed - else the message could be sent to anyone.

AnBBA \larr n_B -B

A{B,m,nB}skABA - \{\textcolor{pink}B,m,n_B\}_{sk_A} \rarr B(skAsk_{A}= digital signature fromAA)(Injective)

CP Handshake

The second message is an acknowledgement.

There are 2 authentications happening.

Symmetric version

A{A,m,nB}kABBA \larr \{\textcolor{pink}A,m,n_B\}_{k_{AB}} -B(Non-Injective)

AnBBA - n_B\rarr B(Injective)

Asymmetric version

Here the request is encrypted with pkApk_A - Then the identifier must be changed to BB .

The request might come from an attacker.

A{B,m,nB}pkABA \larr \{\textcolor{pink}B,m,n_B\}_{pk_A} -B

AnBBA - n_B\rarr B(Injective)

CC Handshake

Symmetric version

The first agreement property ( ABA \larr B ) only holds if the endpoints can not swap roles (we must add tags for the messages).

We can not change the identifiers in the messages since it would make the protocol vulnerable to a reflection attack.

A{B,m1,nB}kABBA \larr \{B,m_1,n_B\}_{k_{AB}} -B(Non-Injective)

A{B,m2,nB}kABBA - \{B,m_2,n_B\}_{k_{AB}} \rarr B(Injective)

Asymmetric version

A{B,m1,nB}pkABA \larr \{B,m_1,n_B\}_{pk_{A}} -B

A{B,m2,nB}pkBBA - \{B,m_2,n_B\}_{pk_{B}} \rarr B(Injective)

Combination of Handshakes

All the other protocols are only made out of the ones mentioned above.

Example: Mutual Authentication

Combination of PC and CC handshake.

AnBBA \larr n_B -B

A{B,m1,nB,nA}kABBA - \{B, m_1, n_B, n_A\}_{k_{AB}} \rarr B(Injective)

A{m2,nB,nA}kABBA \larr \{m_2, n_B, n_A\}_{k_{AB}} - B(Injective)

We can not remove the identifier BB or else a reflection attack would be possible.

Example: SAML-based single sign-on

Protocol to allow client CC to authenticate with a service provider SPSP via an identity provider IdPIdP .


The client wants to request some resource from the service provider. (Instagram in example.)

The Service provider then allows the client to log in with a third party. (Google in example.)

Using automated techniques, people found an attack:

The IdPIdP then (if this protocol would ever be used) have access to the clients CC google account data (Gmail, google calendar, ...).

ProVerif

Cryptographic protocol verifier based on Horn clause resolution.

Input notation: applied pi-calculus.

Outcomes

Possible outcomes after modelling a protocol:

a) proven security

b) found attacks - (could be a false positve because of abstraction)

c) not finding anything / not terminating

Translation

Is what ProVerif does:

our source-code \rarr applied pi-calculus \rarr logical formulas (horn-clauses)

The horn clauses are then sent to a theorem prover.

The translations are sound (= error free) but incomplete:

There can be no false-negatives of security, only false-positives.

Horn Clauses

Are a special type of logical formulas.

For all xx (all the messages):

(x~)(p1(Mundefined1)pn(Mundefinedn)q(Nundefined)) (\forall \tilde{x})\left(p_{1}(\widetilde M_{1}) \wedge \ldots \wedge p_{n}(\widetilde{M}_{n}) \Rightarrow q(\widetilde{N})\right) 

ppare predicate symbols that can have multiple arguments

Resolution provers take a set of Horn clauses and a specified goal: x~.p(Mundefined)\exists \tilde x.p(\widetilde M)

Translation: Applied Pi-Calculus → Logic Formulas

Translating the predicates from the pi-calculus into logical formulas.

Facts (a type of horn clause)

We only have 2 predicates.

F::=F::=

attacker(M)attacker(M) the attacker knows the message MM

message(C,M)message(C,M) the message MM is put out on channel CC- meansout(C,M){out}(C,M)

Input

PP \dots process

SS \dots free public names in PP

Output

set of Horn-Clauses:

B(P,S)=B(P,S) =

InitialAttackerKnowledge(S)\text{InitialAttackerKnowledge}(S) ~\cup

AttackerRules \text{AttackerRules} ~\cup

ProtocolRules(P)\text{ProtocolRules}(P)

Initial Attacker Knowlege

All free public names in PP that the attacker knows.

InitialAttackerKnowledge(S)={attacker(n)nS} \text{InitialAttackerKnowledge}(S) = \{attacker(n) \mid n \in S\} 

Attacker Rules

We model all the constructors and destructors in terms of the attackers knowledge.

AttackerRules=\text{AttackerRules} =

For each constructorff

attacker(x1)...attacker(xn)attacker(f(x1,...,xn)) attacker(x_1) ∧ ... ∧ attacker(x_n) \Rarr attacker(f(x_1,...,x_n)) 

For each destructorggwithg(M1,...,Mn)=Mg(M_1,...,M_n)=M

attacker(M1)...attacker(Mn)attacker(M)attacker(M_1) ∧ ... ∧ attacker(M_n) \Rarr attacker(M)

Why is that so? Because if the attacker knows the ciphertextx1x_1and the encryption keyx2x_2then he can construct the result of the destructor which would be the plaintext in this case.

For each Input and output

message(x,y)attacker(x)attacker(M)message(x,y) \wedge attacker (x) \Rarr attacker(M)Ifyyis on channelxxand the attacker knows that channel, then he has access to it.

attacker(x)attacker(y)message(x,y)attacker(x) \wedge attacker(y) \Rarr message(x,y)If the attacker knows the channelxx, then he can put out content on it.

Protocol Rules

ProtocolRules(P)=\text{ProtocolRules}(P) =

Each output out(c,N)out(c,N) generates a Horn-Clause with the form:

message(c1,M1)message(cn,Mn)message(c,N) message(c_1,M_1) \wedge \ldots \wedge message(c_n,M_n) \Rarr message(c,N) 

whereMiM_iare the previously received messages andNNis a combination of all previous messages.

Examples of protocol rules

Example 1:

P=P =

in(c,x);in(c,x);

in(c,y);in(c,y);

out(c,(x,y));out(c,(x,y));


ProtocolRules(P)={message(c,x)message(c,y)message(c,(x,y))} ProtocolRules(P)=\{message(c,x) ∧ message(c,y) \Rarr message(c,(x,y))\} 

Example 2:

Q=Q=

in(c,x);in(c,x);(receivexx)

let y=decrypt(x,k) in out(c,y)\text{let} ~ y = decrypt (x,k)~ \text{in}~out(c,y)(senddecrypt(x,k)decrypt(x,k))


ProtocolRules(Q)={message(c,enc(y,k))message(c,y)} ProtocolRules(Q)=\{message(c,enc(y,k)) \Rarr message(c,y)\}