Skip to content

Actions table query reports Conditions incorrectly #522

Closed
@eddydee123

Description

@eddydee123

I installed policy_sentry yesterday with pip.

$ policy_sentry --version
policy_sentry, version 0.13.1

When I query the Conditions table for Actions which support iam:PermissionsBoundary, iam:CreateRole comes up:

$ policy_sentry query action-table -s iam -c iam:PermissionsBoundary
IAM actions under iam service that support the iam:PermissionsBoundary condition only:
iam:AttachRolePolicy
iam:AttachUserPolicy
iam:CreateRole <=======
iam:CreateUser
iam:DeleteRolePermissionsBoundary
iam:DeleteRolePolicy
iam:DeleteUserPermissionsBoundary
iam:DeleteUserPolicy
iam:DetachRolePolicy
iam:DetachUserPolicy
iam:PutRolePermissionsBoundary
iam:PutRolePolicy
iam:PutUserPermissionsBoundary
iam:PutUserPolicy

But when I query the Action table for iam:CreateRole, the condition_keys element does NOT contain iam:PermissionsBoundary:

$ policy_sentry query action-table -s iam -n CreateRole
{
    "iam": [
        {
            "action": "iam:CreateRole",
            "description": "Grants permission to create a new role",
            "access_level": "Permissions management",
            "api_documentation_link": "https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateRole.html",
            "resource_arn_format": "arn:${Partition}:iam::${Account}:role/${RoleNameWithPath}",
            "condition_keys": [
                "aws:ResourceTag/${TagKey}",  <======
                "iam:ResourceTag/${TagKey}"
            ],
            "dependent_actions": []
        },
        {
            "action": "iam:CreateRole",
            "description": "Grants permission to create a new role",
            "access_level": "Permissions management",
            "api_documentation_link": "https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateRole.html",
            "resource_arn_format": "*",
            "condition_keys": [
                "aws:ResourceTag/${TagKey}",  <======
                "iam:ResourceTag/${TagKey}"
            ],
            "dependent_actions": []
        }
    ]
}

Maybe this is because the SAR has more than one entry in the resource_types[] array? TBH I'm not even sure how to interpret this phenomenon in the SAR, which shows up as split cells in the table, e.g. iam:CreateRole

Actually, trying other Actions it seems policy_sentry just doesn't report Condtion Keys at all? e.g.

$ policy_sentry query action-table -s lambda -n CreateEventSourceMapping
{
    "lambda": [
        {
            "action": "lambda:CreateEventSourceMapping",
            "description": "Grants permission to create a mapping between an event source and an AWS Lambda function",
            "access_level": "Write",
            "api_documentation_link": "https://docs.aws.amazon.com/lambda/latest/dg/API_CreateEventSourceMapping.html",
            "resource_arn_format": "*",
            "condition_keys": [],  <======
            "dependent_actions": []
        }
    ]
}

compare with https://docs.aws.amazon.com/service-authorization/latest/reference/list_awslambda.html#awslambda-CreateEventSourceMapping

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions