Skip to main content

Quick start

ProofGate runs inside cdk synth. This page shows two ways to see it: on a demo stack without installing anything, and in your own CDK app. No AWS account is used and nothing is deployed.

See it on the demo stack​

The demo stack has two permissions that look ordinary alone. One role may pass a role to Lambda, and may create Lambda functions. The passed role can read the protected bucket.

In your browser​

  1. Open the repository, choose Code, then Codespaces, then Create codespace on main.

  2. Wait for the setup to print Ready. It takes about 3.5 minutes.

  3. In the terminal, run the four steps on the published npm version:

    node scripts/demo-fix.mjs --app-dir ~/proofgate-npm-demo

The four steps are:

  1. Plain cdk synth: exit 0.
  2. cdk synth with ProofGate: exit 1, PG-IAM-004.
  3. Remove the iam:PassRole statement (8 lines).
  4. cdk synth with ProofGate again: exit 0.

Without running anything​

Every CI run of the repository runs the same four steps. Open the latest run of the CI workflow under the Actions tab, job Demo with the published npm version.

Add ProofGate to your CDK app​

Requirements:

  • Node.js 26 or later.
  • Lean 4 and Lake, installed with elan. The plugin builds the Lean project that ships in the npm package the first time it runs (about 10 seconds).
  • aws-cdk-lib with the policy validation plugin API (2.277 or later was used in the tests).

Install the plugin:

npm install @proofgate-cdk/cdk-plugin

Register it when the app is created. The PROOFGATE switch keeps ordinary cdk synth and cdk deploy runs unchanged:

import { App, Validations } from "aws-cdk-lib";
import { ProofGateValidator } from "@proofgate-cdk/cdk-plugin";

const app = new App();

if (process.env.PROOFGATE === "1") {
Validations.of(app).addPlugins(
new ProofGateValidator({
protectedBucketArns: ["arn:aws:s3:::production-data"],
}),
);
}

Run it:

PROOFGATE=1 npx cdk synth

Use a literal bucket ARN with a fixed bucket name. bucket.bucketArn is a token and cannot be used. An empty list is rejected, because the check would be vacuous.

Read the result​

A rejection names who can reach what, and how:

ERROR DeveloperRole58EC5A58 can pass role ProtectedDataRoleCDFF69BA to lambda.amazonaws.com
and launch it (lambda:CreateFunction); ProtectedDataRoleCDFF69BA trusts lambda.amazonaws.com
and can access protected bucket
Suggested fix: Remove iam:PassRole or the launch action from DeveloperRole58EC5A58, ...

The exit code is 1. Change the code, then run again. A passing run with at least one IAM role prints a line such as:

ProofGate: Lean certificate for MyStack.template.json checked by the Lean kernel (decide +kernel)

A template with no IAM resource is accepted because there is nothing to check. That is not a safety result.

An exception is not a fix​

CDK lets an author acknowledge a finding with Validations.of(app).acknowledge(...). The synthesis then succeeds silently, and the path still exists. Use it only for an exception that your team has accepted, and review it like code. The plugin has a second kind of exception that stays in the code and is visible in review: allowedPassRoleTargets and allowedPolicyWriters.

Next​

  • Findings: PG-IAM-003, PG-IAM-004, and PG-IAM-005, and how to answer each.
  • How it works: what is checked, and what Lean does and does not prove.
  • Limits: what is not modeled.
  • The full guide in the repository, including a stack you write yourself.