Panther high experimental python

AWS S3 Bucket Policy Allow With Not Principal

Prevents the use of a 'Not' principal in conjunction with an allow effect in an S3 bucket policy, which would allow global access for the resource besides the principals specified.

View Source

Detection Logic

import json

from policyuniverse.policy import Policy


def policy(resource):
    if resource["Policy"] is None:
        return True

    iam_policy = Policy(json.loads(resource["Policy"]))

    for statement in iam_policy.statements:
        if statement.effect == "Allow" and statement.uses_not_principal():
            return False

    return True

Field Validations

Loading…

Comments (0)

Loading comments...