Skip to content

Scope the install helper's key use to the table key's ARN - #558

Merged
nambok merged 1 commit into
mainfrom
fix/helper-key-scope
Nov 10, 2026
Merged

nambok merged 1 commit into
mainfrom
fix/helper-key-scope

Conversation

@nambok

@nambok nambok commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Security Hub KMS.2 flagged the install helper role (coderhelm-<name>-install-helper). Its inline policy allowed kms:Decrypt on "*", limited by an install-tag condition that Security Hub doesn't read. The helper now uses the install's table key, named by its ARN, and no other key. This applies to existing installs as an in-place update, with no stateful resource replaced.

Changes

  • infra/lib/native/parent.ts:
    • The TableKey statement is removed from helperPolicy().
    • A new parent resource, HelperTableKey (AWS::IAM::RolePolicy, policy name table-key, on HelperRole), allows the same four actions only on Fn::GetAtt Database.Outputs.TableKeyArn. It has to be a separate policy because the helper is made before the parts, so its own policy can't name the key without a cycle.
    • Allowlist, the one helper call that writes to a key-encrypted table, now depends on HelperTableKey.
  • infra/lib/database-stack.ts adds a new output, TableKeyArn, with the table key's ARN.
  • infra/scripts/deploy-role-sim.py:
  • infra/test/fixtures/native-sim.json is regenerated with deploy-role-sim.py --native, which makes only read-only IAM simulator calls.
  • infra/test/security-hub.test.ts gets a new KMS.2 test:
    • the helper's own policy uses no key;
    • HelperTableKey names exactly the Database part's KMS key;
    • Allowlist waits for it;
    • no role or policy in the release allows decrypt on * or key/*, except the pinned deploy role.
  • docs/self-host/security.md: the helper's permission list is updated, and the KMS.2 accepted row now covers only the deploy role.

Verification

  • Simulator run, compared with the fixture on main:
    • deploy role and boundary policies are unchanged;
    • AWS::IAM::RolePolicy is the only new type;
    • the deploy role is allowed iam:PutRolePolicy, iam:DeleteRolePolicy and iam:GetRolePolicy on coderhelm-prod-install-helper;
    • the helper gets implicitDeny for kms:Decrypt on another key and on *;
    • with the FunctionArn mapping, the streaming function's permission calls from Fix Security Hub findings at the source of every install #557 now show allowed. Before, they were unresolved placeholders.
  • In place. I built a native release from main and from this branch and diffed them:
    • parent: HelperTableKey added, HelperRole changes only Policies, Allowlist changes only DependsOn;
    • Database part: one new output;
    • functions: only the config fingerprint in their environment;
    • nothing removed, no replacement, no stateful resource touched.
    • Allowlist's properties don't change, so the update doesn't run it again.
  • infra npm test: 167 pass, including native-sim and native.
  • cfn-lint 1.58.0 passes on the release's coderhelm.json, access.json and every part.
  • python3 -m unittest discover -s lambda/tests: OK.

The helper's own policy allowed kms:Decrypt on every key tagged for the
install, which Security Hub reads as every key (KMS.2). The helper is made
before the parts, so its own policy can't name the key: a separate inline
policy, table-key, made once the Database part is, names the table key by
its ARN (a new Database output), and the allowlist waits for it.

The IAM simulator fixture is regenerated (deploy-role-sim.py --native). It
now maps AWS::IAM::RolePolicy and a function URL's FunctionArn, and checks
that the helper can't decrypt with any other key.
@nambok
nambok merged commit 8592e64 into main Nov 10, 2026
10 checks passed
@nambok
nambok deleted the fix/helper-key-scope branch November 10, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant