Skip to content

feat(terraform): add CKV_AWS_394 for public Secrets Manager secret policy#7595

Open
PhinehasNarh wants to merge 1 commit into
bridgecrewio:mainfrom
PhinehasNarh:feat/secretsmanager-secret-policy-any-principal
Open

feat(terraform): add CKV_AWS_394 for public Secrets Manager secret policy#7595
PhinehasNarh wants to merge 1 commit into
bridgecrewio:mainfrom
PhinehasNarh:feat/secretsmanager-secret-policy-any-principal

Conversation

@PhinehasNarh

Copy link
Copy Markdown

PR Information

Adds a new check, CKV_AWS_394, that flags an AWS Secrets Manager secret whose resource policy grants access to any principal (Principal: "*" / AWS: "*") without a Condition scoping it.

Why this matters

Checkov already detects public/wildcard-principal resource policies for a range of services: SNS (CKV_AWS_169), SQS (CKV_AWS_171), Glacier (CKV_AWS_167), KMS, S3, and others. aws_secretsmanager_secret_policy had no equivalent coverage, so a secret exposed to the entire internet passed silently.

This is arguably the highest-impact resource to leave uncovered: a Secrets Manager secret typically holds database credentials, API keys, and tokens. A resource policy that allows secretsmanager:GetSecretValue to Principal: "*" makes those readable by any AWS account. Checkov reported no finding on that configuration before this change.

The check reuses the same detection path as the existing SNS/Glacier checks (cloudsplaining's ResourcePolicyDocument.internet_accessible_actions), so behavior and edge-case handling stay consistent with the rest of the codebase.

Behavior

  • FAIL: Principal: "*", Principal.AWS: "*", or a principal list containing "*" with an Allow effect and no scoping Condition.
  • PASS: wildcard principal used with Effect: Deny; wildcard scoped by a Condition (e.g. aws:SourceAccount); a specific principal ARN.

Template validation

  • Validated with a host running a vulnerable version and/or configuration (True Positive) - sm_fail_* fixtures
  • Validated with a host running a patched version and/or configuration (avoid False Positive) - sm_pass_* fixtures

Unit test: tests/terraform/checks/resource/aws/test_SecretManagerSecretPolicyAnyPrincipal.py (3 passing resources, 3 failing resources).

AI disclosure

Portions of this change were drafted with AI assistance; I reviewed, tested, and take ownership of every line.

…licy

Checkov detects public/wildcard-principal resource policies for SNS
(CKV_AWS_169), SQS (CKV_AWS_171), Glacier (CKV_AWS_167), KMS, S3 and
others, but aws_secretsmanager_secret_policy had no equivalent check.
A secret policy that allows secretsmanager:GetSecretValue to
Principal: "*" without a scoping Condition exposes the secret (DB
credentials, API keys, tokens) to any principal, and checkov reported
no finding on it.

Add CKV_AWS_394 using the same detection path as the existing SNS and
Glacier checks (cloudsplaining ResourcePolicyDocument.internet_accessible_actions)
so behavior stays consistent. Wildcard-with-Deny and wildcard scoped by
a Condition still pass; unconditional wildcard Allow fails.

Includes a unit test with 3 passing and 3 failing resources.
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