Checking Firewall Equivalence with Z3

  • Abstraction almost always fails; you can’t build something on top of a system without understanding how that system works.
  • Bleeding-edge methods are a recipe for disaster
  • Everything good is hype and you’ll only ever get a small fraction of the utility being promised.

The Problem

  • Accidentally allowing connections from computers which should be blocked, a significant security issue.
  • Accidentally blocking connections from computers which should be allowed, a significant availability issue.

Indistinguishable from magic

The right question

  1. Tell Z3 what a packet is.
  2. Tell Z3 what a firewall is.
  3. Tell Z3 we want to find a packet blocked by one firewall but allowed by the other.
(declare-const src Int)
(declare-const dst Int)
(define-fun matches ((srcLower Int) (srcUpper Int) (dstLower Int) (dstUpper Int)) Bool
(and (<= srcLower src) (<= src srcUpper) (<= dstLower dst) (<= dst dstUpper))
)
(define-fun firewall1 () Bool
(and
(matches 0 10 20 30)
(not (matches 5 10 25 30))
)
)

Satisfaction

(define-fun firewall2 () Bool
(and
(matches 1 10 20 30)
(not (matches 5 10 25 30))
)
)
(assert (not (= firewall1 firewall2)))
(check-sat)
(get-model)
  1. The firewalls are not equivalent: check-sat returns satisfiable, and the get-model instruction provides a packet demonstrating firewall inequivalence.
  2. The firewalls are equivalent: check-sat returns unsatisfiable and no packet is produced.

In the real world

Beyond the firewall

--

--

--

Formal methods, distributed systems, quantum computing. Software engineer in Azure Networking. TLA+ enthusiast.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Famous Quotes About Software Engineer Everyone Should Know

SemaphoreSlim

Golang Study — map

In The Media — OpsRamp’s State Of AIOps Report

Being a marketer in a developer’s world

What I wish I knew for my first year as a software engineer?

WIP4: Close Some Partnership Mining Pools and Add the Airdrop Reward Reserve Pool

Leibniz’s Dream in Dogelog Player

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrew Helwer

Andrew Helwer

Formal methods, distributed systems, quantum computing. Software engineer in Azure Networking. TLA+ enthusiast.

More from Medium

What is a Clustered File System ?

Injecting Fault in Azure Cache for Redis using Azure Chaos Studio

What do monitoring metrics tell us?

Connect to IBM Cloud Foundry from your local