Skip to content

Conversation

amandladev
Copy link
Contributor

@amandladev amandladev commented Oct 2, 2025

Introduction

This change improves security by scoping IAM policies to the specific
destination key prefix instead of granting access to all bucket objects.

Changes:

  • IAM policies now grant access to /<destinationKeyPrefix>/* instead of /*
  • When destinationKeyPrefix is specified (e.g., 'deploy/here/', 'efs/'),
    the Lambda execution role only receives permissions for that specific prefix
  • Deployments without a prefix continue to work as before with /* access
  • Applies to both standard deployments and EFS-backed deployments

Security Benefits:

  • Follows the principle of least privilege
  • Multiple deployments to the same bucket are now isolated by prefix
  • Reduces blast radius if deployment Lambda credentials are compromised
  • Prevents accidental cross-deployment modifications

Affected Use Cases:
✅ Deployment with prefix: destinationKeyPrefix: 'deploy/here/'
✅ EFS-backed deployment: destinationKeyPrefix: 'efs/', useEfs: true
✅ Multiple deployments to same bucket with different prefixes
✅ Deployments without prefix (unchanged behavior)

Testing:

  • Updated integration tests for all deployment scenarios
  • Verified snapshots for standard, EFS, and prefixed deployments
  • All existing functionality preserved with improved security posture

Fixes #35610

@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1 labels Oct 2, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team October 2, 2025 19:32
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Oct 2, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@aws-cdk-automation aws-cdk-automation dismissed their stale review October 2, 2025 20:51

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@amandladev amandladev force-pushed the feature/s3-deployment-permissions-least-privilege branch from a4fd28a to f17cf5b Compare October 2, 2025 21:27
@abidhasan-aws abidhasan-aws self-assigned this Oct 15, 2025
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

2 similar comments
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-s3-deployment): BucketDeployment grants itself wider permissions than needed

3 participants