EventBridge Bus Policy Allows Wildcard Principal
eventbridge-bus-policy-wildcard-principal
What this rule checks
Detects AWS::Events::EventBusPolicy with an Allow statement targeting Principal=* (or AWS=*) without a Condition restricting access. Without the condition, any AWS account can publish events to the bus.
How to fix it
- 1Replace wildcard Principal with specific 12-digit AWS account IDs
- 2Or scope the policy with a Condition such as aws:PrincipalOrgID
- 3Verify the StatementId is descriptive β easier to audit later
import { aws_events as events, aws_iam as iam } from 'aws-cdk-lib';
const bus = new events.EventBus(this, 'Bus');
bus.addToResourcePolicy(new iam.PolicyStatement({
sid: 'AllowPutEvents',
effect: iam.Effect.ALLOW,
principals: [new iam.AnyPrincipal()],
actions: ['events:PutEvents'],
resources: [bus.eventBusArn],
}));import { aws_events as events, aws_iam as iam } from 'aws-cdk-lib';
const bus = new events.EventBus(this, 'Bus');
bus.addToResourcePolicy(new iam.PolicyStatement({
sid: 'AllowPutEvents',
effect: iam.Effect.ALLOW,
principals: [new iam.AnyPrincipal()],
actions: ['events:PutEvents'],
resources: [bus.eventBusArn],
conditions: { StringEquals: { 'aws:PrincipalOrgID': 'o-abc123example' } },
}));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::Events::EventBusPolicyIntentional? Suppress this finding
Sometimes a flag is deliberate β a genuinely public endpoint, say. You can dismiss eventbridge-bus-policy-wildcard-principal and the reason is kept in the report, not silently hidden.
In .cdk-insights.json:
{
"ignoreRules": [
{ "id": "eventbridge-bus-policy-wildcard-principal", "reason": "Why this is intentional" }
]
}Or inline in your CDK code:
Validations.of(scope).acknowledge({
id: 'cdk-insights::eventbridge-bus-policy-wildcard-principal',
reason: 'Why this is intentional',
});Use the rule ID eventbridge-bus-policy-wildcard-principal 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 scanCDK Insights runs this and 118+ other rules locally against your synthesised CDK app β free, no account, your code never leaves your machine.