Skip to content

Create rule S7608: S3 operations should verify bucket ownership using ExpectedBucketOwner parameter #5131

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
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

github-actions[bot]
Copy link
Contributor

You can preview this rule here (updated a few minutes after each push).

Review

A dedicated reviewer checked the rule description successfully for:

  • logical errors and incorrect information
  • information gaps and missing content
  • text style and tone
  • PR summary and labels follow the guidelines

@ghislainpiot ghislainpiot force-pushed the rule/add-RSPEC-S7608 branch 7 times, most recently from 4d561cf to 816e95d Compare June 24, 2025 15:07
@ghislainpiot ghislainpiot changed the title Create rule S7608 Create rule S7608: AWS client calls should specify explicit timeout values Jun 24, 2025
@ghislainpiot ghislainpiot changed the title Create rule S7608: AWS client calls should specify explicit timeout values Create rule S7608 Jun 25, 2025
@ghislainpiot ghislainpiot force-pushed the rule/add-RSPEC-S7608 branch 2 times, most recently from 1041ef9 to 1a39458 Compare June 25, 2025 07:32
@ghislainpiot ghislainpiot changed the title Create rule S7608 Create rule S7608: S3 operations should verify bucket ownership using ExpectedBucketOwner parameter Jun 25, 2025
@ghislainpiot ghislainpiot requested a review from Seppli11 June 25, 2025 08:01
Copy link
Contributor

@Seppli11 Seppli11 left a comment

Choose a reason for hiding this comment

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

The rule looks good. Nice work 💪

I've left some nitpick comments about formatting and the links.

Also, at least right now, the framework names haven't been added to the allowed frame work list. (see #5132 which adds this)

Comment on lines +10 to +11
"aws",
"s3"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we set tags already? Isn't this something Jean has to approve?

Copy link
Contributor

Choose a reason for hiding this comment

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

No we can do the tags ourselves, we just need to be consistent with each other

@@ -0,0 +1,114 @@
This rule raises an issue when S3 operations are performed without verifying bucket ownership using the ExpectedBucketOwner parameter.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This rule raises an issue when S3 operations are performed without verifying bucket ownership using the ExpectedBucketOwner parameter.
This rule raises an issue when S3 operations are performed without verifying bucket ownership using the `ExpectedBucketOwner` parameter.

Same applies to the other mentions of ExpectedBucketOwner

import boto3

def lambda_handler(event, context):
s3_client = boto3.client('s3')
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: the s3_client should probably be initialized outside of the lambda_handler

import aiobotocore.session

async def lambda_handler(event, context):
session = aiobotocore.session.get_session()
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that the aiobotocore.session should also be initialized outside of the lambda_handler

Comment on lines 98 to 99
* https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.get_object[boto3 S3 get_object documentation with ExpectedBucketOwner parameter]
* https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-owner-condition.html[AWS S3 bucket owner condition documentation]
Copy link
Contributor

Choose a reason for hiding this comment

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

The format of the links are not quite right 1

Suggested change
* https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.get_object[boto3 S3 get_object documentation with ExpectedBucketOwner parameter]
* https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-owner-condition.html[AWS S3 bucket owner condition documentation]
* boto3 Documentation - https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.get_object[get_object]
* AWS Documentation - https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-owner-condition.html[Verifying bucket ownership with bucket owner condition]

Footnotes

  1. https://github.com/SonarSource/rspec/blob/master/docs/link_formatting.adoc


== Why is this an issue?

Verifying S3 bucket ownership is a critical security practice in AWS applications. The ExpectedBucketOwner parameter confirms you're accessing the correct bucket owned by the intended AWS account.
Copy link
Contributor

Choose a reason for hiding this comment

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

I find that this section flows a bit weird with so many small paragraphs. Personally, I would prefer one bigger paragraph, but that's personal preference

Copy link
Contributor

@Seppli11 Seppli11 left a comment

Choose a reason for hiding this comment

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

The rule looks good. Nice work 💪

I've left some nitpick comments about formatting and the links.

Also, at least right now, the framework names haven't been added to the allowed frame work list. (see #5132 which adds this)

Copy link
Contributor

@Seppli11 Seppli11 left a comment

Choose a reason for hiding this comment

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

The rule looks good. Nice work 💪

I've left some nitpick comments about formatting and the links.

Also, at least right now, the framework names haven't been added to the allowed frame work list. (see #5132 which adds this)

Copy link

Quality Gate passed Quality Gate passed for 'rspec-tools'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
0 Dependency risks
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Copy link

Quality Gate passed Quality Gate passed for 'rspec-frontend'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
0 Dependency risks
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants