Three Formal Engines. Same Facts. Same Answer. Here's What Broke Getting There.
✓ Human-authored analysis; AI used for formatting and proofreading. We ran a static analyzer against NCC Group's SadCloud which is a deliberately vulnerable AWS environment and got 57 findings across 12 services. That'
✓ Human-authored analysis; AI used for formatting and proofreading.
We ran a static analyzer against NCC Group's SadCloud which is a deliberately vulnerable AWS environment and got 57 findings across 12 services. That's one tool's opinion. Opinions aren't proofs.
So we exported the findings as structured facts and fed them to three independent formal reasoning engines built on different mathematical foundations. The question: do they agree?
They do. But getting there required fixing a real engineering problem that will hit anyone trying to use formal methods at infrastructure scale.
The export
The analyzer produces findings by evaluating observations against a control catalog. Under the hood, those evaluations produce structured facts. Predicates about assets, their properties, and the relationships between them. We exported those facts in two formats:
JSONL — 5,829 flat triples, one per line. Each triple is a predicate: has_type(asset, "aws_iam_role"), trust.wildcard(asset, "true"), audit.cloudtrail.has_s3_data_event_gap(asset, "true"). This is the format Datalog engines consume.
SMT-LIB v2 — the same facts encoded as first-order logic assertions for satisfiability solvers. Boolean functions over string arguments, with declarations and assertions.
Same facts. Different serializations. Three engines.
Engine 1: Soufflé (Datalog)
Soufflé is a Datalog engine. It takes facts and rules, grounds them, and enumerates all derivable tuples. We wrote rules that match the compound risk patterns from the findings:
A detection bypass exists when a degraded CloudTrail trail coexists with a wildcard-trust IAM role. A credential exposure exists when an EC2 instance has both a public IP and secrets in user data. A shadow admin factory exists when a wildcard-trust role coexists with a group that has admin policies attached.
Result: 21 individual tuples covering every finding category, plus 3 compound chains. Under 1 second on 5,829 triples.
Engine 2: Z3 (SMT solver)
Z3 is a satisfiability solver. It takes logical assertions and determines whether a satisfying assignment exists. The question is different from Soufflé's: not "enumerate everything that's wrong" but "does a state matching this property exist?"
We fed Z3 the SMT-LIB export. It timed out at 30 seconds.
The timeout
The SMT-LIB file was 24,633 lines. The 35-asset SadCloud environment produced only 229 actual facts. Predicates about real assets and their properties. The other 24,404 lines were:
5,375 catalog metadata assertions — has_severity, has_type, has_domain for all 2,670 controls in the catalog. These describe the controls, not the infrastructure. Z3 was trying to reason about the control catalog's metadata alongside the infrastructure facts.
167 closed-world universal quantifiers — forall axioms asserting that every predicate is false for every input not explicitly stated as true. Mathematically correct (proving completeness), computationally intractable (Z3 must enumerate every possible string against every predicate).
The facts-to-noise ratio was 229:24,404. Z3 was spending its time on catalog bookkeeping and completeness proofs, not on the infrastructure.
The fix
Three changes to the export pipeline:
Open-world by default. SMT-LIB output no longer includes closed-world forall axioms. If you need negative proofs on small fact sets ("prove that no principal can reach admin"), pass --closed-world explicitly. The default assumes open-world semantics — predicates may be true for inputs beyond those asserted.
Strip catalog metadata. A --strip-catalog flag omits has_severity, has_type, has_domain, and other control metadata from the fact stream. The solver doesn't need to know that a control is "high severity". It needs to know that an asset has a wildcard trust policy.
Metadata header. The SMT-LIB output now includes a machine-readable header:
; total_facts: 229
; total_predicates: 167
; mode: open-world (no forall axioms)
; recommended: souffle, clingo (enumeration at scale)
; scoped_queries: z3, cvc5, prolog (append targeted query)
Downstream tooling knows what it's getting and which engines are appropriate.
The result: 24,633 lines → 1,558 lines. Timeout → 22 milliseconds.
Before: 24,633 lines | Z3 timeout at 30s
After: 1,558 lines | Z3 sat in 0.022s
| 1,100x faster
Engine 2, take two: Z3 on stripped facts
With the cleaned export, we wrote 11 targeted queries. One per finding category. Each query appends a specific assertion to the fact file and asks Z3 for satisfiability.
"Does an asset with a wildcard trust policy exist?" Sat. "Does a KMS key with no rotation exist?" Sat. "Does a trail with missing log validation exist?" Sat.
11 queries. 11 sat results. Every one matches the corresponding Soufflé tuple. Under 1 second total.
The consensus
Three engines and mathematical foundations. Same facts and answer.
| Engine | Foundation | Input | Result | Time |
|---|---|---|---|---|
| Stave CEL | Predicate evaluation | obs.v0.1 | 57 findings + 1 chain | 8.7s |
| Soufflé | Datalog enumeration | 5,829 JSONL triples | 21 tuples + 3 chains | <1s |
| Z3 | SMT satisfiability | 1,558 SMT-LIB assertions | 11/11 sat | <1s total |
Zero disagreements on the facts. The engines answer different questions about the same facts. Soufflé enumerates everything wrong, Z3 proves specific properties hold. But where their answers overlap, they agree completely.
Why three engines instead of one?
The same reason an Airbus A320 uses flight computers built by different teams on different hardware: dissimilar redundancy. A bug in one engine's implementation doesn't exist in the others. If all three agree, confidence is high. If they disagree, you've found either a bug or an ambiguity in the specification.
Soufflé found 3 compound chains where the primary analyzer found 1. That's not a disagreement. The Datalog rules defined additional chain patterns (credential_exposure, shadow_admin_factory) that don't exist in the analyzer's chain catalog yet. The disagreement revealed missing chain definitions. That's the value of dissimilar redundancy: the second opinion catches what the first opinion didn't think to check.
What this means for production
SadCloud is 35 assets. A production AWS account has hundreds to thousands. The scaling implications:
Soufflé and Clingo scale linearly. Datalog and answer-set programming operate on grounded facts without quantifier explosion or combinatorial blowup. 5,829 triples took under 1 second. 100,000 triples would take seconds.
Z3 requires scoped queries. Sending a full enterprise fact base to Z3 with (check-sat) will timeout regardless of export format. The correct usage is targeted: "can principal A reach admin through any path?" with a subgraph of relevant facts. Z3 proves existence. Soufflé enumerates everything. Different tools for different questions.
The metadata header enables routing. The recommended and scoped_queries fields tell downstream tooling which engine gets the full fact base and which gets a scoped subset. A production pipeline reads the header and routes accordingly where human decision is not required.
The design principle that made this possible
The analyzer's architecture has a rule: facts only, never rules. The exporter writes what is true about the configuration. External programs decide what it means.
This is why three engines work from the same export. The analyzer doesn't embed inference rules, solver strategies, or reasoning logic in the fact stream. It emits ground facts. Each engine brings its own reasoning such as Datalog rules, SMT assertions, Prolog clauses and applies them to the same base.
If the analyzer had embedded its own reasoning in the export (solver hints, inference rules, evaluation strategies), every engine would need a custom adapter. By exporting only facts, the fact format is engine-neutral by construction. Adding a fourth engine (Prolog, PySAT, TLA+, PRISM) means writing rules in that engine's language over the same fact predicates. The facts don't change.
The critical design decision was deleting a built-in solver backend early in the project. The temptation was to embed Z3 directly. A multi-backend engine that switches between solvers. Instead, the solver was deleted and the system exported facts. That decision is why three engines work today, and why the tenth engine will work without changing a line of the exporter.
The numbers
Infrastructure: NCC Group SadCloud (35 assets, 12 AWS services)
Primary findings: 57 (from CEL evaluation)
JSONL export: 5,829 triples
SMT-LIB (before): 24,633 lines → Z3 timeout at 30s
SMT-LIB (after): 1,558 lines → Z3 sat in 0.022s
Engines confirmed: 3 (Stave CEL, Soufflé, Z3)
Engine disagreements: 0
Compound chains found: 3 (Soufflé) / 1 (CEL)
Chain gap identified: 2 missing chain definitions in primary catalog
The tool is Stave. The fact export formats (JSONL, SMT-LIB v2) are documented in the repo. The engine runners are under examples/.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.