Skip to content

LearnCloud

AWS secrets and KMS key policy review

Brief

Reading a secret in AWS takes two permissions, one on the secret and one on the KMS key that encrypts it, so access is decided by four policies at once: the identity's, the secret's, the key's and any grant on the key. The review reads each of them by name, never a value, and finds the secrets nobody rotates, the parameters stored as plain strings and the keys any account can use.

Track
Cloud
Stage
Access
Reviewed
On this page
  1. Check first
  2. AWS
  3. The defender sees
  4. Done when
  5. Not covered
  6. Tools
  7. Related research
  8. Where this page fits
  9. Reviewed

All commands

AWS book Chapter 8 of AWS Identity and Secrets, "Who can read the secrets: Secrets Manager, KMS key policies and grants", goes further than this page.

Situation
A read-only review role in each account in scope with SecurityAudit, plus iam:SimulatePrincipalPolicy, Access Analyzer read and its policy check access-analyzer:CheckNoPublicAccess. Every command on this page lists names, policies and metadata, or asks Access Analyzer to judge a policy document without applying it: we never call GetSecretValue, GetParameter with decryption or Decrypt, and we review only the accounts and regions the scope letter names.
Goal
A secrets table: each secret and secure parameter by name, its rotation state, its key, and every principal inside and outside the account that can read and decrypt it.
Outputs
Captured on 8 Nov 2026 (UTC) in the Atarus lab AWS Organization from the Atarus Bench edition 2026.11-cloud-0.3, AWS CLI 2.39.3 and jq 1.7.1, with account ids, the key id and other identifiers replaced by stable placeholders. Every step on this page is captured, in a member account through the lab's read-only review role atarus-review; 444455556666 is the lab's second member account, standing in for a vendor. No secret in the lab rotates, so a rotating secret's line is described, not shown. The key half of the reporting role's read, the alias lookup and the refused policy check come from three shorter runs that day.

Check first

  • The accounts and regions in scope, since secrets, parameters and keys are regional.
  • The client's list of sensitive secrets, and which roles are meant to read each one.
  • Their rotation standard, for example every 90 days, so "never rotated" has something to be measured against.
  • The account ids of the client's organization and known vendors, to tell cross-account access from a leak.
  • Whether the organization trail excludes KMS events, which decides whether Decrypt calls are recorded at all.

Steps

AWS

Which secrets exist, and when were they last rotated?

aws secretsmanager list-secrets --region us-east-1 \
  --query 'SecretList[].[Name,RotationEnabled,LastRotatedDate,KmsKeyId]' --output text

Expected output

prod/db/app	None	None	None
prod/payments/api-key	None	None	alias/capture-a-data   # <- never rotated, under a customer managed key
prod/partner/webhook	None	None	None

list-secrets returns names and metadata, never values. None under rotation means rotation was never turned on; a secret that rotates prints True and the date of its last rotation, and none of the three here does. The key column shows the key as the secret's creator named it, here an alias of a customer managed key. None under the key means the AWS managed key, which cannot be used from another account, so a cross-account statement on such a secret does nothing. A secret that is never rotated and that a vendor can read is the one to follow first; the next step shows that the payments secret is both.

Negative result. Every secret on the client's list has rotation on and a recent rotation date, or a documented reason why it cannot rotate.

Fix. Turn on rotation with a Lambda rotation function for database and API credentials, and delete secrets with no recent access after confirming with their owners.

Who can read each secret?

aws secretsmanager get-resource-policy --region us-east-1 --secret-id prod/payments/api-key \
  --query ResourcePolicy --output text | jq '.Statement[] | {Effect, Principal, Action}'
aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::111122223333:role/reporting-batch \
  --action-names secretsmanager:GetSecretValue \
  --resource-arns "$(aws secretsmanager describe-secret --region us-east-1 --secret-id prod/payments/api-key --query ARN --output text)" \
  --query 'EvaluationResults[].[EvalActionName,EvalDecision]' --output text

Expected output

{
  "Effect": "Allow",
  "Principal": {
    "AWS": "arn:aws:iam::444455556666:root"   # <- the other account decides which of its identities can read
  },
  "Action": "secretsmanager:GetSecretValue"
}
secretsmanager:GetSecretValue	allowed   # <- allowed on the secret; the key decides the rest

The resource policy says who outside the account can read; identity policies decide who inside can. A role with secretsmanager:GetSecretValue on * reads every secret whose key it can also use, so we run the simulator for each role that is not on the client's list. A secret's ARN ends in a random suffix, so the simulation looks it up with describe-secret; naming the secret matters, because a simulation with no --resource-arns tests * and prints implicitDeny for a grant written for named secrets (the rule is on the policy evaluation page). The simulator sees only identity policies, so its answer is half of the result, and the key in the next step is the other half.

Negative result. No resource policy names an account outside the organization's vendor list, and only the roles on the client's list are allowed.

Fix. Scope GetSecretValue to named secret ARNs, add aws:PrincipalOrgID or aws:SourceAccount conditions to resource policies, and turn on Block Public Policy for secrets.

Which KMS keys can be used too widely?

aws kms get-key-policy --region us-east-1 --key-id 1a2b3c4d-5e6f-7a8b-9c0d-EXAMPLE11111 \
  --policy-name default --query Policy --output text \
  | jq -c '.Statement[] | select(.Effect == "Allow") | {Sid, Principal, Action, Condition}'
aws kms list-grants --region us-east-1 --key-id 1a2b3c4d-5e6f-7a8b-9c0d-EXAMPLE11111 \
  --query 'Grants[].[GranteePrincipal,join(`,`,Operations)]' --output text

Expected output

{"Sid":"Enable IAM User Permissions","Principal":{"AWS":"arn:aws:iam::111122223333:root"},"Action":"kms:*","Condition":null}
{"Sid":"PartnerDecrypt","Principal":{"AWS":"arn:aws:iam::444455556666:root"},"Action":["kms:Decrypt","kms:DescribeKey"],"Condition":null}   # <- another account, no condition: it decides which of its identities decrypt
{"Sid":"Allow use of the key","Principal":{"AWS":"arn:aws:iam::444455556666:role/vendor-sync"},"Action":["kms:Decrypt","kms:DescribeKey"],"Condition":null}
arn:aws:iam::444455556666:role/vendor-sync	Decrypt   # <- a grant, outside the key policy

The first statement is the default and is not about the root user: it lets IAM policies in the account grant use of the key. The other two let a second account decrypt: PartnerDecrypt names that account's root, so any identity there that its own policies allow can use the key, and the payments secret's resource policy above names the same account. Grants give decrypt quietly, outside the key policy, and are easy to miss; this one repeats what the key policy already gives vendor-sync. We read every customer managed key, found with list-keys and describe-key, and compare the account ids we see with the client's list. Access Analyzer's external access findings cover the same keys and catch any we misread.

Because the first statement delegates to IAM, a role in the account decrypts with this key only if its own policies allow kms:Decrypt on it. That decides the reporting role's read of the payments secret. The secret names its key by alias, describe-key turns the alias into the key id read above, and the simulation names that key:

aws secretsmanager describe-secret --region us-east-1 --secret-id prod/payments/api-key --query KmsKeyId --output text
aws kms describe-key --region us-east-1 --key-id alias/capture-a-data --query KeyMetadata.KeyId --output text
aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::111122223333:role/reporting-batch \
  --action-names kms:Decrypt \
  --resource-arns arn:aws:kms:us-east-1:111122223333:key/1a2b3c4d-5e6f-7a8b-9c0d-EXAMPLE11111 \
  --query 'EvaluationResults[].[EvalActionName,EvalDecision]' --output text

Expected output

alias/capture-a-data
1a2b3c4d-5e6f-7a8b-9c0d-EXAMPLE11111   # <- the alias is this key
kms:Decrypt	implicitDeny   # <- tested on the key itself: the role cannot decrypt the payments secret

reporting-batch passes the identity check on the secret and is stopped by the key, so it cannot read the value, and the finding for this secret is the vendor account's reach rather than the reporting role. A GetSecretValue simulation alone is never the finding.

The statement most worth finding is a * principal with no condition, which lets any AWS principal that holds a ciphertext decrypt it, from any account. The lab never applies one to a key, so Access Analyzer judges such a policy as a document instead; the check reads the file and changes nothing.

cat > wildcard-key-policy.json <<EOF
{"Version":"2012-10-17","Statement":[{"Sid":"Enable IAM User Permissions","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::111122223333:root"},"Action":"kms:*","Resource":"*"},{"Sid":"Allow use of the key","Effect":"Allow","Principal":{"AWS":"*"},"Action":["kms:Decrypt","kms:DescribeKey"],"Resource":"*"}]}
EOF
aws accessanalyzer check-no-public-access --policy-document file://wildcard-key-policy.json --resource-type AWS::KMS::Key \
  --query '[result,message]' --output text
rm -f wildcard-key-policy.json && echo removed

Expected output

FAIL	The resource policy grants public access for the given resource type.   # <- applied to a key, this policy would open it to every account
removed

The same check takes a key policy read from the client's account, saved to a file. SecurityAudit and ReadOnlyAccess do not include the policy checks, so the review role needs access-analyzer:CheckNoPublicAccess added. Without it the call is refused like this, run here with the wildcard statement alone before the lab's review role was given the action:

printf '%s' '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":"*"},"Action":["kms:Decrypt","kms:DescribeKey"],"Resource":"*"}]}' > f1-key-policy.json
aws accessanalyzer check-no-public-access --policy-document file://f1-key-policy.json --resource-type AWS::KMS::Key \
  --query '[result,message]' --output text
rm -f f1-key-policy.json && echo removed

Expected output


aws: [ERROR]: An error occurred (AccessDeniedException) when calling the CheckNoPublicAccess operation: User: arn:aws:sts::111122223333:assumed-role/atarus-review/atarus-review is not authorized to perform: access-analyzer:CheckNoPublicAccess on resource: arn:aws:access-analyzer:us-east-1:111122223333:* because no identity-based policy allows the access-analyzer:CheckNoPublicAccess action
removed

Negative result. No * principal without an aws:PrincipalOrgID or account condition, grants only to the services and vendors on the client's list, and separate keys for separate sensitivity levels.

Fix. Replace * statements with named principals or an organization condition, retire grants nobody can explain, and keep administration and use of a key in separate statements.

Which parameters hold secrets as plain strings?

aws ssm describe-parameters --region us-east-1 \
  --query 'Parameters[].[Name,Type,KeyId]' --output text | grep -iE 'secret|token|password|key'

Expected output

/prod/db/password	SecureString	alias/aws/ssm
/prod/payments/webhook-secret	String	None   # <- stored unencrypted, readable by anyone with ssm:GetParameter

describe-parameters returns names and types, never values. A String parameter needs no key permission to read, so the key policy above protects nothing for it. /prod/db/password is a SecureString, but under alias/aws/ssm, the AWS managed key: its policy lets anyone in the account who may read the parameter decrypt it through Parameter Store, and nobody can narrow it, so identity policies alone decide its readers. A customer managed key adds a key policy that names who may decrypt. Parameter Store has no resource policy of its own except when an advanced parameter is shared through AWS RAM, so identity policies decide who reads it.

Negative result. Every parameter that holds a credential is a SecureString under a customer managed key, and no role reads /prod/* that does not need it.

Fix. Convert secret strings to SecureString with a customer managed key, or move them to Secrets Manager where rotation is needed. The IAM escalation checks show which roles can grant themselves read later.

The defender sees

Every call here is a CloudTrail management event under the review role: ListSecrets, GetResourcePolicy, DescribeSecret, GetKeyPolicy, ListGrants, CheckNoPublicAccess, DescribeParameters and SimulatePrincipalPolicy, the last for both halves of the reporting role's read. The events worth an alert are the ones that change access: PutResourcePolicy on a secret, PutKeyPolicy and CreateGrant on a key, RotationFailed and CancelRotateSecret, and GetSecretValue from an account or role that never read that secret before. Decrypt events show who used each key, but only if the trail does not exclude KMS events. If it does, the client cannot tell which identities read a secret, and that is a finding beside the policy.

Done when

Every secret and parameter is listed with rotation state and key, every resource policy and customer managed key policy is read, broad or cross-account statements and grants are listed, and the roles that can read each sensitive secret are named.

Not covered

Finding secrets in Lambda, EC2 user data and code (see AWS secrets in Lambda config and user data), CloudHSM, and key material imported from outside AWS.