Skip to main content

How it works

The steps​

ProofGate is a CDK policy validation plugin. For each template that cdk synth writes, it does this:

  1. Extract. The extractor reads the CloudFormation JSON and builds a small typed model: roles, policy statements, trusted services, and the protected buckets. A syntax it does not support is reported with its JSON path as PG-IAM-003, and no partial model is used.
  2. Write. The generator writes the model as a Lean 4 module, together with TypeScript's own list of findings.
  3. Compute and check. For the iam:PassRole shape, Lean computes the findings from the model. Its kernel checks that its list equals the TypeScript list. If the two differ, or Lean cannot run, the stack is rejected with PG-IAM-003.
  4. Report. The plugin turns the findings into CDK violations that name the principal, the role, the service, and the bucket, with a suggested fix. The terminal shows how the check was done, for example checked by the Lean kernel (decide +kernel).

Lean runs under a time limit (60 seconds for the kernel check, 300 seconds for the slower method). A run that exceeds it is stopped and the stack is rejected, never accepted.

What Lean checks​

The function that computes the findings is proved equal, for every model, to a rule written over AWS request strings ("a role ARN exists such that iam:PassRole is allowed on it, ..."). That is a property of the model that ProofGate gives to Lean. For a stack whose action patterns have a wildcard in the service part (such as lambda*:create*), or with many roles that can pass each other, the check uses native_decide, which also trusts the Lean compiler; the terminal says which method was used.

Two smaller shapes (a change of an existing function, and a role that changes IAM itself) still use Booleans that TypeScript computes, and Lean checks only their conjunction.

What is trusted​

Lean does not prove anything about CloudFormation or IAM themselves. These are trusted, and tested against an independent oracle:

  • the extractor, and the normalization in TypeScript (lowercasing, regional service names, bucket ARNs);
  • the tables generated from the AWS Service Reference;
  • the rule itself, which is our model of IAM, compared with 58 decisions of the real IAM engine (iam:SimulateCustomPolicy);
  • the assumption that the synthesized template is what gets deployed.

How it was checked​

CheckResult
Decisions of the real IAM engine, written into the Lean project58
Generated cases that compare an independent oracle, the TypeScript evaluator, and Lean (per run)2,000
Missed paths found by the generated cases in an early version532, from two bugs; 0 after the fixes
Realistic CDK stacks with the expected result committed before each run84
Paths of pathfinding.cloud (91) that ProofGate reports60, including 46 of 47 that pass a role
A fictional shop application, 27 variants: dangerous variants found after 1.3.214 of 15, with no false alarm

The 60 of 91 reproduce the preconditions of each path in a two-role model. They do not show working attacks.

Three bugs were found in our own releases and fixed: a missed iam:PassRole Resource without :role/ (1.2.1), a cdk synth that could wait for ever with many roles (1.3.1), and a whole stack rejected because of a Step Functions EcsRunTask (1.3.2).

Time​

On the demo stack, ProofGate adds about 3 seconds to the rejected synth (5 s against 1.5 s) and under 1 second to the fixed one. For a larger application of 121 roles and about 600 KB of templates, the check took 29 to 42 seconds (measured before 1.3.2).