Skip to content

iam: condition-key names are matched case-sensitively, but AWS documents them as case-insensitive #704

Closed

Description

@scttfrdmn

Problem

AWS states plainly, in IAM JSON policy elements: Condition:

For conditions, the condition key is not case-sensitive and the condition value is case-sensitive.

Substrate matches condition-key names case-sensitively. conditionMatches
(emulator/iam_eval.go) looks the key up in the request context map directly, so a policy
that spells a key ec2:createaction, aws:requesttag/Env or AWS:PrincipalArn — every one of
which real IAM evaluates — is silently unmatched here.

The failure direction depends on the effect:

  • a Deny written with a differently-cased key name is inert — substrate allows what AWS denies;
  • an Allow written that way is an implicit deny — a false refusal.

This is global to the evaluator, not specific to any one key. It was found while implementing
the second ec2:CreateTags pass (#691): a subtest asserting that ec2:createaction still
matches failed, and the comment at emulator/ec2_createtags_authz_test.go:297 records the gap
pointing here.

Scope

The key name is case-insensitive; the key value is not. Only the lookup changes:

  • conditionMatches / evaluateConditionKey (emulator/iam_eval.go) must resolve a policy's
    key name against the request context case-insensitively, for both Context and MultiContext.
  • Null must resolve the same way, or the recommended ForAllValues + Null: false pattern
    breaks for a differently-cased key.
  • unsetConditionKeys (emulator/iam_eval.go) must not report a key as missing merely because
    the policy's spelling differs from the producer's.
  • Tag-suffixed keys need care: the prefix (aws:RequestTag/, aws:ResourceTag/) is a key
    name and case-insensitive, but AWS documents tag keys themselves as case-sensitive, and
    substrate's own tag rules (emulator/ec2_tags.go) already treat them so. The suffix must stay
    case-sensitive.
  • Two producers writing the same key with different casing must not both survive into the
    context, or a lookup becomes order-dependent — which the event log must never be.

Acceptance criteria

  • A policy naming ec2:createaction, AWS:RequestTag/Env or any other case variant is
    evaluated identically to its canonical spelling, in both Allow and Deny position.
  • The tag-key suffix of aws:RequestTag/* / aws:ResourceTag/* remains case-sensitive, with
    a test pinning both halves of that split.
  • Null and unsetConditionKeys resolve names the same way as conditionMatches.
  • The AWS sentence above is quoted at the implementation site as provenance.
  • docs/services.md states the rule and the tag-suffix exception; the case-sensitivity
    caveat recorded under ec2,iam: the second ec2:CreateTags authorization pass for a resource-creating action that carries tags #691 is replaced by the implemented behaviour.
  • CHANGELOG.md records this under ### Fixed, noting both failure directions.
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions