Security review

The Well-Architected Review skill of Agent Toolkit, run from Claude Code against the code and the live AWS account, rated SEC03-BP01 Critical: Stub's budget check lived only in application code, and the app connected to the database as admin. This page lists what changed and every number measured afterwards. Each one is copied from RESULTS.md, and Kiro checked them against the write-up and the review reports. Watch the 90-second video for the before and after, or read the write-up on AWS Builder Center.

The finding: SEC03-BP01

The review rated it Critical. Its evidence: the balance check lived only in core/ledger.ts, the app connected as admin, and the app's AWS identity was an IAM user with a long-lived key that could call 6 of 6 destructive actions on the clusters.

So a write that skipped the check, from a script, a hotfix or a new route, would commit. Measured on Aurora DSQL, ten such writers took a $3.00 budget to -$7.00 in 20 runs out of 20. Concurrency control put the writes in order. Nothing decided whether they were affordable.

SEC03-BP01

Each of your workload components or services runs under a distinct identity scoped to the permissions its function requires.

What changed

  1. 1

    The database enforces the budget

    Every balance carries CHECK (balance_micro >= 0), and accounts also carry a cap check, so a bug can't mint budget either. Each was added as NOT VALID and validated in the background, with no downtime.

  2. 2

    A least-privilege database role

    The app connects as stub_app. It can add entries and move balances, but not change or delete an entry, create an account or touch the schema.

  3. 3

    No stored AWS keys

    The app assumes an IAM role through Vercel OIDC, gets one-hour credentials, and may only call dsql:DbConnect.

  4. 4

    A refusal becomes a record

    A 23514 that reaches the app is stored as a denial with reason db_refused, so it shows in the audit trail.

  5. 5

    CI attacks a real database

    Every push starts Postgres 17, connects as stub_app, sends the six statements from the proof page and runs the ten-writer race. It fails if any statement is accepted.

The review

The Well-Architected Review skill of Agent Toolkit, run three times on Security and Reliability. The third run read the deployed app.

The budget

The database now refuses an overspend, whoever sends it.

Access

The app runs with the least it needs, and nothing is stored that could leak.

Recovery

The ledger survives a deleted cluster, a bad write and a lost Region.

Detection and audit

Every change to the ledger and the account is recorded, and the alarms page someone.

Delivery

What is live is what is in the repo, and CI fails if a control is dropped.

Operations

The controls above are written down, deployed from the repo and checked in CI.
  • Infrastructure as code

    Clusters, backups, the audit trail, detection and the failure drill are CloudFormation stacks with termination protection, deployed from main.

    infra/
  • Incident response

    One playbook per alarm and rule, the freeze criteria, and recovery with the measured restore and failover times.

    incident-response.md
  • Data classification

    Every table, column, export and log classed Public, Internal or Confidential, with retention and where it flows.

    data-classification.md