-
Notifications
You must be signed in to change notification settings - Fork 605
[Rule Tuning][New Rule] AWS S3 Bucket Policy Added to Share with External Account/ to Allow Public Access #5268
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
Merged
+323
−44
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
…rnal Account/ to Allow Public Access AWS S3 Bucket Policy Added to Share with External Account Low telemetry volume overall, however false positives were seen for cloudfront identity and service accounts being given access to a bucket - Reduced the scope of this rule to only analyze policy that include account ids or account ARNs (which include an account ID). This eliminates the false positives triggered by sharing buckets with a service account (i.e. cloudtrail.amazonaws.com) - Excluded cloudfront identity, which should be treated the same way service accounts are being treated and be excluded as they do not include account IDs in their ARN - This rule wasn't explicitly capturing the use of `Principal: *` which is a public sharing method, often accompanied by a Condition statement (i.e. aws.SourceAccount = OR aws.PrincipalAccount= OR ip.address = ....). The new query will capture Condition statements that include an account id. However there is still a gap for Policies that have explicit `Principal:*` with or without a condition, so another rule was created that will account for these scenarios. - added highlighted fields - updated investigation guide and description - updated Mitre tactics and tags - `event.type` used in place of `event.category` field ### AWS S3 Bucket Policy Added to Allow Public Access Rule added to cover gap in public bucket policy added which includes an `Effect=Allow` and `Principal: *`. While an additional condition might be added to this policy which would exclude public access, cases where the condition is not included mean the bucket is publicly accessible. Both cases need to be verified, because even the condition could be giving access to an attacker owned account. There is also the chance that an `Effect=Deny` for `Principal:*` will trigger a false positive for this rule if the same policy also includes an `Effect=Allow` statement. We call this out in the description, false positive and investigation guide sections of the rule.
Contributor
Rule: New - GuidelinesThese guidelines serve as a reminder set of considerations when proposing a new rule. Documentation and Context
Rule Metadata Checks
New BBR Rules
Testing and Validation
|
1 similar comment
Contributor
Rule: New - GuidelinesThese guidelines serve as a reminder set of considerations when proposing a new rule. Documentation and Context
Rule Metadata Checks
New BBR Rules
Testing and Validation
|
All 3 rules are showing extremely low telemetry volume as expected. No major changes needed to these queries. - updated the descriptions, investigation guides and false positive sections - reduced execution window - added highlighted fields
… Deletion" This reverts commit c66a4f1.
Aegrah
approved these changes
Oct 31, 2025
terrancedejesus
approved these changes
Oct 31, 2025
Contributor
terrancedejesus
left a comment
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.
Very nice work!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backport: auto
Domain: Cloud
Integration: AWS
AWS related rules
Rule: New
Proposal for new rule
Rule: Tuning
tweaking or tuning an existing rule
Team: TRADE
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.
Pull Request
Issue link(s):
Summary - What I changed
(TUNE) AWS S3 Bucket Policy Added to Share with External Account
Low telemetry volume overall, however false positives were seen for cloudfront identity and service accounts being given access to a bucket
Principal: *which is a public sharing method, often accompanied by a Condition statement (i.e. aws.SourceAccount = OR aws.PrincipalAccount= OR ip.address = ....). The new query will capture Condition statements that include an account id. However there is still a gap for Policies that have explicitPrincipal:*with or without a condition, so another rule was created that will account for these scenarios.event.typeused in place ofevent.categoryfield(NEW) AWS S3 Bucket Policy Added to Allow Public Access
Rule added to cover gap in public bucket policy added which includes an
Effect=AllowandPrincipal: *. While an additional condition might be added to this policy which would exclude public access, cases where the condition is not included mean the bucket is publicly accessible. Both cases need to be verified, because even the condition could be giving access to an attacker owned account. There is also the chance that anEffect=DenyforPrincipal:*will trigger a false positive for this rule if the same policy also includes anEffect=Allowstatement. We call this out in the description, false positive and investigation guide sections of the rule.Note: Unfortunately there will be duplicate alerts between these rules for the case where both a Principal Wildcard is included AND a reference to an Account Id is included. I could not think of a way to eliminate this chance without compromising the intent of either of the rules, open to suggestions if you have any.
How To Test
Scripts for Testing each rule:
Test data in the stack for running the queries and screenshots below
AWS S3 Bucket Policy Added to Share with External Account
For this rule I tested 3 different scenarios that should trigger an alert and 3 scenarios that shouldn't
Screenshots of scenario 1, 2, and 3 being captured by rule query
Screenshot of scenario 5 Cloudfront being captured before exclusions added
Screenshot of exclusions added which no longer capture Cloudfront or Service Principal shares
AWS S3 Bucket Policy Added to Allow Public Access
Screenshot of New Rule Query For Capturing scenario 1 and 6, Principal Wildcard (both with and without a condition)