1 of 37

Zero-Knowledge Middleboxes

Paul Grubbs - NYU/UMich

Arasu Arun - NYU

Ye Zhang - NYU

Joseph Bonneau - NYU/Melbourne

Mike Walfish - NYU

USENIX Security 2022

eprint.iacr.org/2021/1022.pdf

2 of 37

Zero-Knowledge Middleboxes

enforce

network

policies�

allow

encrypted

traffic

(using zero-knowledge proofs)

3 of 37

DNS Filtering

Client

MiddleBox

example.com

Is example.com allowed?

DNS Resolver

example.com

Blocklist

ban.co.uk

blocked.com

Local Network

4 of 37

DNS Filtering is a fact of life

In-flight

Schools

Cafes

Parental controls

legally required in USA

5 of 37

The rise of encrypted DNS: standards

6 of 37

The rise of encrypted DNS: resolvers

1.1.1.1

8.8.8.8

9.9.9.9

7 of 37

The rise of encrypted DNS: browsers

8 of 37

Encrypted DNS breaks filtering

Dilemma:

Client’s Privacy

vs.

Network Policy

MiddleBox

Is Enc(Query) allowed?

Blocklist

ban.co.uk

blocked.com…

???

Enc(Query)

Client

9 of 37

Mozilla’s “solution”: network-level kill switch

10 of 37

Past academic solutions

  • Approach #1: modify TLS to use functional encryption
    • Blindbox [Sherry et al. 2015], Embark [Lan et al. 2016]
    • Requires server-side changes
    • Weakens TLS security guarantees

  • Approach #2: enforce network policies using trusted hardware
    • SGX-Box [Han et al. 2017], Endbox [Goltzsche et al. 2018]
    • Requires clients have trusted hardware
    • Vulnerable to TEE side-channel attacks

11 of 37

Can we achieve privacy & policy enforcement?

  • Compatibility: work with TLS 1.3, no server-side changes
  • Privacy: middlebox learns nothing additional beyond policy compliance
  • Flexibility: support arbitrary network policies
  • Efficiency: “reasonable” client overhead, very low middlebox overhead

12 of 37

This is a job for zero-knowledge proofs

13 of 37

Zero-Knowledge �Sudoku Proof

Proof

Puzzle

Accept/Reject

Solution

Sudoku

Testing Algorithm

Prover knows �solution �to

Puzzle

Puzzle

, Proof

Prover

Verifier

14 of 37

ZK 101

  • Possible for any NP statement
  • Continual efficiency improvement since 1980s
  • Practical deployment during 2010s
  • Compilers produce prover/verifier from higher-level description

proof π

public input

(statement)

private input

(witness)

Proving

Algorithm

Verification Algorithm

public input

(statement)

Accept/Reject

15 of 37

Blockchains have brought $$$ to ZKPs

  • Privacy-benefits: prove a transactions is valid without publishing details

  • Efficiency benefits: prove many transactions are valid in a short proof

16 of 37

New Application: ZKMBs

MiddleBox

Client

DNS Resolver

Enc(Query) + Proof

Blocklist

ban.co.uk

blocked.com

Verification Algorithm��Enc(Query) + Proof

Query is not in the Blocklist

Enc(Query)

Blocklist

ban.co.uk

blocked.com

17 of 37

Many evasion strategies exist for motivated clients

  • Application-layer encryption

  • Alternate routing protocols (e.g. TELEX)
  • Tor hidden services
  • Steganography
  • Out-of-band communication

Assumption: client, server use standard protocols only

18 of 37

Filtering vs. Censorship

Censorship

Filtering

Polite request

19 of 37

Designing ZKMBS

20 of 37

Designing efficient ZK proofs remains challenging

Long-term expectations:

  • Generic zk-SNARK constructions exist for all NP statements
  • Compilers exist from human-level languages to circuit representation
  • Programmers can choose from multiple “backends” with different tradeoffs

Today’s reality:

  • Generic zk-SNARK can be very expensive
  • Compiled circuits often impractically slow
  • Practicality requires problem-specific optimization
  • As much art as science

21 of 37

TLS is complex (even TLS 1.3)

22 of 37

ZKMBs proofs decompose into several tasks

Channel opening

Parse & extract

Policy

check

Ciphertext

Plaintext

Policy-relevant text

Accept/

reject

23 of 37

Channel opening statement proves plaintext matches transcript

Plaintext

Proof

Decryption (AES)

TLS Key Schedule (SHA-256)

key

Handshake

Transcript

TLS secrets

24 of 37

Simply supplying a valid AES key + decryption is insufficient

Problem:

  • AES-GCM (as used in TLS 1.3) is not committing
  • Multiple keys can decrypt the same plaintext to different ciphertexts

25 of 37

Observation: TLS transcripts do commit to an exact AES key

Simple solution:

  • Provide client Diffie-Hellman secret as a witness
  • Prove that the AES key was derived from the DH exchange

Fast solution:

  • Provide only AES key as a witness
  • Prove the key is derived from an intermediate value in the handshake

26 of 37

Parse & extract circuit (DNS example)

Optional hints

Proof

Verify DNS query parse

Plaintext

Queried domain

27 of 37

Policy check: Merkle-tree non-membership

Verify Merkle

Non-inclusion Proof

Proof

Merkle �Non-Membership Proof

Domain

Blocklist

commitment

  • Leaves are domains in sorted order
  • “Circuit-friendly” hash used (Poseidon)

28 of 37

Implementation #1 (MB-optimized)

  • ZKPs were constructed using xJsnark
  • Proofs generated using libsnark - Groth16 algorithm

29 of 37

Proving Time is the Bottleneck

Channel-opening

Parsing, policy check (DNS filtering)

30 of 37

Proving Time is the Bottleneck

MiddleBox

Client

Enc(Query) + Proof

5 ms

20 seconds

300 bytes

Verification time

Proof size

Proving time

75% of the runtime is due to SHA256!

31 of 37

Amortization

Opening Proof

Reuse Proof throughout session

Client

MiddleBox

20 seconds

6

seconds

* Middlebox needs to store some state

TLS 1.3 Session

32 of 37

Pre-computation

Opening Proof

Reuse Proof throughout session

TLS 1.3 Session

Doesn’t affect

DNS latency

Client

MiddleBox

20 seconds

6

seconds

33 of 37

Implementation #2 (balanced?)

  • ZK proofs were constructed using Spartan

34 of 37

Spartan is much more client-friendly

Channel-opening

Parsing, policy check (DNS filtering)

35 of 37

Future Work

  • Support other encrypted protocols
    • Tor, VPNs

  • Support private blocklists�
  • Support other policies: Data Loss Prevention

36 of 37

Conclusion: ZKMBs close to practical!

“Zero-Knowledge Middleboxes” paper: eprint.iacr.org/2021/1022.pdf

Implementation: github.com/pag-crypto/zkmbs

This work supported by the DARPA SIEVE Project

37 of 37

Operations Involved

SHA256

AES-GCM

Poseidon Hash

Blocklist with ~1 M entries