Skip to content
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

bug: use credentials when scanning #337

Merged
merged 13 commits into from
Sep 8, 2024
Merged

bug: use credentials when scanning #337

merged 13 commits into from
Sep 8, 2024

Conversation

sa7mon
Copy link
Owner

@sa7mon sa7mon commented Sep 8, 2024

Bug

As reported in #328, credentials stored in ~/.aws/credentials or a path located by the AWS_SHARED_CREDENTIALS_FILE environment variable were not being used when scanning buckets. Because of this, any results from scanning AWS buckets would be potentially missing AUTH_USERS permissions.
This was an unfortunate oversight when re-writing S3Scanner in Go mostly due to the account ownership of the test buckets not being fully understood at that time. Consequently, the unit tests to verify this functionality did not report accurately.

Changes

  • A new IAM user has been provisioned to use for unit tests. This user has custom policies applied to it so that permission checks produce the results that would be produced if using an account that does not own the bucket (blocking access to READ and READ_ACL operations on certain test buckets).
  • Fix grant check in ParseAclOutputv2
  • Minor cleanup refactors
  • Load profile and credentials when scanning
    • S3Scanner will follow the procedure documented here when choosing which profile to use and where to load credentials from. For example, an alternative profile can be used by setting the AWS_PROFILE environment variable.
    • Note: the only exception is that the EC2 IMDS feature has been disabled. If you want to use S3Scanner inside an EC2 instance, you will need to store the credentials to use in the credentials file.
  • Update ClientMap to use a compound key when storing clients. Now we can store both anonymous and authenticated clients for each region.
  • Add additional logging when -verbose is supplied

Closes #328

@sa7mon sa7mon added the bug label Sep 8, 2024
@sa7mon sa7mon linked an issue Sep 8, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Sep 8, 2024

Code Coverage

Package Line Rate Complexity Health
github.com/sa7mon/s3scanner/bucket 91% 0
github.com/sa7mon/s3scanner/cmd/regioncheck 55% 0
github.com/sa7mon/s3scanner/cmd/s3scanner 19% 0
github.com/sa7mon/s3scanner/db 73% 0
github.com/sa7mon/s3scanner/permission 28% 0
github.com/sa7mon/s3scanner/provider 79% 0
github.com/sa7mon/s3scanner/worker 49% 0
Summary 62% (595 / 959) 0

@sa7mon sa7mon merged commit 8f5b035 into main Sep 8, 2024
8 checks passed
@sa7mon sa7mon deleted the 328 branch September 8, 2024 22:07
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.

bug: only anonymous permissions checked properly
1 participant