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]: False Positive on check s3_bucket_public_access when Conditions in Policy #4257

Closed
jmanduca-psfy opened this issue Jun 17, 2024 · 4 comments · Fixed by #4281
Closed
Labels
backport-v3 Pending to port to Prowler v3 branch bug provider/aws Issues/PRs related with the AWS provider severity/medium Results in some unexpected or undesired behavior.

Comments

@jmanduca-psfy
Copy link

Steps to Reproduce

  1. prowler aws -c s3_bucket_public_access
  2. aws
  3. Single Account
  4. Failed finding: S3 Bucket sample-restricted-bucket has public access due to bucket policy.

Expected behavior

S3 Bucket sample-restricted-bucket should have passed the check.

Actual Result with Screenshots or Logs

Failed check: S3 Bucket sample-restricted-bucket has public access due to bucket policy.

How did you install Prowler?

From pip package (pip install prowler)

Environment Resource

  1. Workstation (Linux Subsystem)

OS used

  1. Ubuntu 22.04 (WSL)

Prowler version

Prowler 4.2.4

Pip version

pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

Context

The check only looks for Principal = "*" and Effect = "Allow" without investigating other contexts to the statement, such as Conditions or Resources.

EX. For this policy, the check should pass as the condition restricts public access:
{ "Sid": "AllowVPCAccess", "Effect": "Allow", "Principal": "*", "Action": "s3:*", "Resource": [ "arn:aws:s3:::sample-restricted-bucket/*", "arn:aws:s3:::sample-restricted-bucket" ], "Condition": { "StringEquals": { "aws:sourceVpc": "vpc-12345678abcdef" } } }

@jmanduca-psfy jmanduca-psfy added bug status/needs-triage Issue pending triage labels Jun 17, 2024
@mtronrd
Copy link
Contributor

mtronrd commented Jun 18, 2024

If you set Block Public Access on the bucket or account this should go away while still working as intended. Ideally you should use IAM to grant S3 access and not allow anonymous access like this.

I'm currently working on a PR to standardize resource policy checks for public access and access from untrusted accounts. This condition should probably pass a public access check but fail a trust boundary check, as it's not feasible to verify that access is coming from a trusted account via source network conditions.

@jfagoagas
Copy link
Member

@mtronrd you are right but this check is only reviewing the bucket's configuration. We are actively working to fix that in the check.

I'm happy to hear that you are working on that, please let us know if you need something.

@jfagoagas jfagoagas added provider/aws Issues/PRs related with the AWS provider severity/medium Results in some unexpected or undesired behavior. and removed status/needs-triage Issue pending triage labels Jun 20, 2024
@puchy22
Copy link
Contributor

puchy22 commented Jun 20, 2024

Hi @jmanduca-psfy I am working on your problem, please can you test now the check in this PR and send some feedback.

Thanks for the reporting and for using Prowler 🚀

@sergargar sergargar added the backport-v3 Pending to port to Prowler v3 branch label Jun 20, 2024
@jmanduca-psfy
Copy link
Author

Thank you @puchy22 for working on this! Looks good except for an issue I commented in the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v3 Pending to port to Prowler v3 branch bug provider/aws Issues/PRs related with the AWS provider severity/medium Results in some unexpected or undesired behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants