-
Notifications
You must be signed in to change notification settings - Fork 4.3k
chore(efs): scope down overly permissive AnyPrincipal in anonymous access policy #36290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
pahud
wants to merge
3
commits into
aws:main
Choose a base branch
from
pahud:fix-36224-efs-mount-permission
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5,082
−3,521
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Replace AnyPrincipal with AccountRootPrincipal in EFS resource policy to block anonymous NFS access - Add ClientMount action to the policy statement alongside existing Write and RootAccess actions - Update policy to enforce IAM authentication by switching EFS from default anonymous access mode to IAM enforcement mode - Add comprehensive documentation explaining why AccountRootPrincipal is used instead of AnyPrincipal - Update all related test cases to reflect the new AccountRootPrincipal ARN in policy assertions - Ensure same-account IAM principals can still access the file system with proper identity-based permissions while preventing cross-account anonymous access
aws-cdk-automation
previously requested changes
Dec 3, 2025
Collaborator
There was a problem hiding this 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)
- Update EFS filesystem one-zone integration test snapshot manifests - Update EFS filesystem policy integration test snapshot files - Update EFS filesystem protection integration test snapshots - Update EFS filesystem replication integration test snapshots - Update EFS from imported subnet integration test snapshots - Update EFS transition integration test snapshots - Update EFS permission integration test snapshots and source - Regenerate CloudFormation templates and asset hashes - Simplify analytics construct data in snapshot manifests
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
- Update manifest.json files across all EFS integration test snapshots - Regenerate CloudFormation template asset URLs for all test cases - Update tree.json files to reflect current construct tree state - Refresh assets.json files with latest asset configurations - Update EFS filesystem implementation to reflect snapshot changes - Regenerate test snapshots for efs-filesystem-one-zone integration test - Regenerate test snapshots for efs-filesystem-policy integration test - Regenerate test snapshots for efs-filesystem-protection integration test - Regenerate test snapshots for efs-filesystem-replication integration test - Regenerate test snapshots for efs-from-imported-subnet integration test - Regenerate test snapshots for efs-transition integration test - Regenerate test snapshots for efs integration test - Regenerate test snapshots for efs.permission integration test
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
This issue is a bug.
contribution/core
This is a PR that came from AWS.
effort/medium
Medium work item – several days of effort
p2
pr/needs-further-review
PR requires additional review from our team specialists due to the scope or complexity of changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue # (if applicable)
N/A - Security improvement and test reliability fix. Related to #36224
Reason for this change
Primary goal: Current implementation for
anonymousAccess: falseis essentially derived from EFS console. With this default resource policyClientMountClientMountso this policy is general fine with protective purpose but confusing. We should scope down the resource policy principal definition from any arn('*') to account root principal as this could be a concern(though it's default behavior from EFS console)
Secondary goal: Update the existing integration test to validate this policy change. The current test uses EC2 NANO instances with AL2023, which has critical reliability issues:
We replace the EC2-based implementation with Lambda functions to simplify the process and ensure reliable test execution.
Description of changes
1. EFS File System Policy Security Fix (
packages/aws-cdk-lib/aws-efs/lib/efs-file-system.ts):AnyPrincipal(AWS: '*') toAccountRootPrincipalto scope down overly permissive accessClientMountaction - principals must be explicitly granted viagrantRead(),grantReadWrite(), orgrantRootAccess()methodsClientMountis excluded2. Integration Test Refactor (
packages/@aws-cdk-testing/framework-integ/test/aws-efs/test/integ.efs.permission.ts):/mnt/efsKey technical changes:
AnyPrincipal()→AccountRootPrincipal(),ClientMountintentionally excluded from resource policyDescribe any new or updated permissions being added
EFS File System Policy Change:
AWS: '*'(any principal) withClientWriteandClientRootAccessactionsAccountRootPrincipal(account root) with onlyClientWriteandClientRootAccessactionsThis change is more restrictive and follows AWS security best practices:
AnyPrincipaltoAccountRootPrincipal, limiting access to IAM principals within the same AWS accountgrantRead(),grantReadWrite(), orgrantRootAccess()for principals to mount the filesystemClientMountis intentionally excluded from the resource policy to enforce explicit grants through identity-based permissionsDescription of how you validated changes
efs-file-system.test.tsto reflect the new policy structure withAccountRootPrincipalandClientMountactionChecklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license