Skip to main content
CRITICALSecrets ManagerSecurity

Secrets Manager Secret Publicly Accessible

secrets-manager-secret-public

What this rule checks

Detects Secrets Manager secrets whose resource policy grants access to a wildcard or public principal.

How to fix it

  1. 1Remove wildcard/public principals from the secret resource policy
  2. 2Scope access to specific IAM principals or accounts
FlaggedThe secret's resource policy grants an Allow to a wildcard principal with no scoping Condition, making the secret publicly accessible. Anyone could retrieve its value.
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
import { PolicyStatement, Effect, AnyPrincipal } from 'aws-cdk-lib/aws-iam';

const secret = new Secret(this, 'DbSecret');
secret.addToResourcePolicy(new PolicyStatement({
  effect: Effect.ALLOW,
  principals: [new AnyPrincipal()],
  actions: ['secretsmanager:GetSecretValue'],
  resources: ['*'],
}));
FixedRead access is granted to a specific IAM role via an identity-based policy, so no public resource policy is attached to the secret. Only that role can retrieve the value.
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
import { Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';

const role = new Role(this, 'AppServiceRole', { assumedBy: new ServicePrincipal('lambda.amazonaws.com') });
const secret = new Secret(this, 'DbSecret');
secret.grantRead(role);

CDK Insights pinpoints the exact file and line in your CDK source for every finding, so you can jump straight to the fix.

Affected resource types

AWS::SecretsManager::ResourcePolicy

Compliance frameworks

SOC2HIPAAPCI-DSSNIST

AWS documentation

Read the AWS guidance

Intentional? Suppress this finding

Sometimes a flag is deliberate — a genuinely public endpoint, say. You can dismiss secrets-manager-secret-public and the reason is kept in the report, not silently hidden.

In .cdk-insights.json:

{
  "ignoreRules": [
    { "id": "secrets-manager-secret-public", "reason": "Why this is intentional" }
  ]
}

Or inline in your CDK code:

Validations.of(scope).acknowledge({
  id: 'cdk-insights::secrets-manager-secret-public',
  reason: 'Why this is intentional',
});

Use the rule ID secrets-manager-secret-public shown above — not the CDK-* ID from SARIF / GitHub code scanning. To dismiss every finding on one construct instead, use ignorePaths. Suppression docs →

Catch this in your stack

$ npx cdk-insights scan

CDK Insights runs this and 126+ other rules locally against your synthesised CDK app — free, no account, your code never leaves your machine.