Skip to content

Dynamic labels policy has no allow-list mode, only deny-list #5412

Closed

Description

@atsikham

Description

aws_dynamic_labels_policy (the guardrail for ghr-ec2-* dynamic labels) only supports a blocklist: blocked_keys rejects specific keys, restricted_keys limits the values a specific key can have, and any key not on either list is allowed.

This means: if GitHub adds a new EC2 override key later, or a key is simply left off the list, that key stays allowed until someone notices and blocks it. There is no way to set up a strict "nothing except these specific keys" policy without listing every single key to forbid — an open-ended, easy-to-miss list.

Impact

An allow-list (deny by default) is the safer choice here, because dynamic labels let workflow authors set arbitrary EC2 launch settings (instance type, AMI, subnet, EBS volume size) — see the security warning already in docs/configuration.md. Right now, any new EC2 override key GitHub adds in the future is allowed by default for every deployment using this policy, until someone notices and adds it to blocked_keys.

Proposed fix

Add allowed_keys to AwsDynamicLabelsPolicy: when set (not empty), only the keys listed there are allowed — everything else is rejected. blocked_keys/restricted_keys keep working exactly as before when allowed_keys is not set. Since allowed_keys and blocked_keys mean opposite things (allow-only vs. block-only), only one of them should be used at a time in the same policy — checked by Terraform at config time, and also checked at runtime (rejecting everything) if a policy with both somehow still reaches the code.

See PR (to follow) for the implementation.

Activity

  1. added a commit that references this issue on Sep 20, 2026
    05984f6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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