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: Policies with broad Deny statements are incorrectly interpreted as internet accessible #161

Open
tweedge opened this issue Oct 5, 2022 · 0 comments

Comments

@tweedge
Copy link
Contributor

tweedge commented Oct 5, 2022

Pulling an example from the AWS documentation for API Gateway resource policies here:

% cat test.py
from policyuniverse.policy import Policy
from json import loads
from pprint import pprint

json_policy = loads("""
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "execute-api:Invoke",
            "Resource": [
                "execute-api:/*"
            ]
        },
        {
            "Effect": "Deny",
            "Principal": "*",
            "Action": "execute-api:Invoke",
            "Resource": [
                "execute-api:/*"
            ],
            "Condition" : {
                "StringNotEquals": {
                   "aws:SourceVpc": "vpc-1a2b3c4d"
                }
            }
        }
    ]
}
""")

pu_policy = Policy(json_policy)
pprint(pu_policy.is_internet_accessible())

% python3 test.py
True

This is because Policy Universe interprets each statement's internet accessibility separately, marking the policy as internet accessible if any statement individually appears internet accessible, and does not include logic for explicit Deny statements taking precedence over Allow statements.

I'm investigating some options for fixing this though unfortunately, seems a bit of a lift. Will create a PR if I come up with something clean!

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

No branches or pull requests

1 participant