Repository navigation
Scope the install helper's key use to the table key's ARN - #558
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Security Hub KMS.2 flagged the install helper role (
coderhelm-<name>-install-helper). Its inline policy allowedkms:Decrypton"*", 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:TableKeystatement is removed fromhelperPolicy().HelperTableKey(AWS::IAM::RolePolicy, policy nametable-key, onHelperRole), allows the same four actions only onFn::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 onHelperTableKey.infra/lib/database-stack.tsadds a new output,TableKeyArn, with the table key's ARN.infra/scripts/deploy-role-sim.py:AWS::IAM::RolePolicyto its role;FunctionArnto its function (the OAC permissions from Fix Security Hub findings at the source of every install #557 name the streaming function);kms:Decryptwith another key or*.infra/test/fixtures/native-sim.jsonis regenerated withdeploy-role-sim.py --native, which makes only read-only IAM simulator calls.infra/test/security-hub.test.tsgets a new KMS.2 test:HelperTableKeynames exactly the Database part's KMS key;Allowlistwaits for it;*orkey/*, 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
AWS::IAM::RolePolicyis the only new type;iam:PutRolePolicy,iam:DeleteRolePolicyandiam:GetRolePolicyoncoderhelm-prod-install-helper;kms:Decrypton another key and on*;FunctionArnmapping, 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.HelperTableKeyadded,HelperRolechanges onlyPolicies,Allowlistchanges onlyDependsOn;Allowlist's properties don't change, so the update doesn't run it again.infranpm test: 167 pass, includingnative-simandnative.coderhelm.json,access.jsonand every part.python3 -m unittest discover -s lambda/tests: OK.