Skip to content

iam: the keys the bundled policies condition on have no producer #730

Closed

Description

@scttfrdmn

Found while implementing #714. The operator families are now complete, which makes the
remaining gap a producer gap rather than an evaluation gap: an operator can only be as useful
as the keys it can compare, and the keys substrate's own bundled policies condition on have no
producer at all.

The bundled catalog conditions on six keys substrate never populates

All 32 Condition blocks in emulator/iam_managed.go use operators substrate now evaluates,
so no bundled decision changed in v0.107.0. But every key they name is absent from the request
context:

Key Named by
iam:PassedToService The iam:PassRole grants
iam:AWSServiceName The service-linked-role grants
aws:CalledViaLast The via-service grants
elasticloadbalancing:CreateAction The ELB tag-on-create grant
devops-guru:ServiceNames The DevOps Guru grant
ec2:ResourceTag/<key> The EC2 grants — substrate produces aws:ResourceTag/<key>

Each is a false deny, and today in the safe direction: all 32 blocks sit on an Allow, so such
a statement grants nothing rather than a Deny going inert. That safety is a property of the
current catalog, not of the design — one bundled Deny with a condition would invert it.

ec2:ResourceTag/<key> is the cheapest and most valuable: substrate already resolves
aws:ResourceTag/<key> from each resource the request names, so the EC2-scoped spelling is the
same lookup under a second prefix. AWS documents both, and its own examples use the
service-scoped form.

No policy-variable substitution

A ${aws:username} in a resource ARN or a condition value is compared literally. The bundled
IAMUserChangePassword policy (emulator/iam_managed.go:126) scopes its Resource to
arn:aws:iam::*:user/${aws:username}, so it matches no user. AWS substitutes the value before
evaluating. Documented in docs/services.md as of v0.107.0; not implemented.

Note the ordering constraint: substitution needs aws:username to have a producer, which is
the first half of this issue.

No write-time validation of operator names

Real IAM rejects {"NotAnOperator": {...}} with MalformedPolicyDocument when the document is
submitted. Substrate accepts it, stores it, and discards it at evaluation — where v0.107.0 now
makes it deny rather than (under a set qualifier) grant. Denying is the safe reading, but the
refusal belongs at PutUserPolicy/CreatePolicy time, where a caller can act on it.

One caution, from #714: iam_set_qualifiers_test.go:234 pins "forallvalues:StringEquals" as a
non-match at evaluation. AWS's case-insensitivity covers condition-key names, not operator
names (#704), so validating operator names must not move that assertion to submission without
deciding deliberately that it should.

Acceptance criteria

  • ec2:ResourceTag/<key> is populated alongside aws:ResourceTag/<key> from the same
    resource lookup, and the bundled EC2 grants are shown to evaluate.
  • Each remaining key either gets a producer or is documented as unproducible with the reason.
  • Policy-variable substitution for the keys that have producers, or a recorded decision not
    to implement it.
  • Write-time operator-name validation answering MalformedPolicyDocument, with the
    forallvalues: assertion's placement decided explicitly.
  • docs/services.md's producer table and the no-producer list updated to match.

Activity

  1. added this to the v0.108.0 milestone on Aug 22, 2026
  2. scttfrdmn commented on Aug 22, 2026

    @scttfrdmn
    OwnerAuthor

    Shipped in v0.108.0 (#751). All five acceptance criteria are met; two carry a caveat worth
    recording, both filed rather than left implicit.

    • ec2:ResourceTag/<key> populated from the same tag set — done, and it needed more than the
      one-line addition the issue predicted. The prefix alone was inert: authorization resolved an EC2
      request to a real ARN and to that resource's tags only when the request named InstanceId, and
      the operations the two bundled statements govern name none of them that way. GroupId,
      RouteTableId and InternetGatewayId now resolve too, through one lookup shared by the ARN
      builder and the tag reader.

      Caveat: a policy of your own written against ec2:ResourceTag/<key> now evaluates end to end
      (verified live), but ManagedCloudformationResourcesCleanupPolicy's own statement is still
      unsatisfiable for a second, independent reason — nothing in substrate produces the
      aws:cloudformation:stack-name tag it names. CreateTags refuses a caller-supplied aws: key
      exactly as AWS does, and the CloudFormation deployer does not tag the resources a stack creates.
      Filed as cfn: the deployer does not apply stack tags to the resources it creates #746. AmazonEKSClusterPolicyENIDelete likewise stays inert, because substrate stores
      no standalone taggable ENI record.

    • A producer or a documented reason for each remaining key — documented, and the census in the
      issue was one short: codestar-notifications:NotificationsForResource (6 of the 32 condition
      blocks, the third-largest group) was absent from docs/ entirely. The table now carries six
      rows, each with its reason. The two most feasible are filed: iam: CreateServiceLinkedRole, so iam:AWSServiceName has a producer #747
      (CreateServiceLinkedRole → iam:AWSServiceName, 11 blocks) and elbv2: tagging, so elasticloadbalancing:CreateAction has a producer #748 (ELB tagging →
      elasticloadbalancing:CreateAction).

    • Policy-variable substitution, or a recorded decision not to — the second alternative, with
      the reasoning in docs/services.md: for the one bundled policy that uses a variable, AWS's own
      rule ("an unresolved variable in Resource will not match any resource") means substrate's
      literal comparison already gives AWS's answer. The divergence that remains is NotResource and
      negated operators, where AWS says an unresolved variable does match. The ordering constraint
      is stated honestly: aws:username needs a producer first, and it cannot be the ARN's last
      component — that yields the session name for an assumed role, where AWS documents
      aws:username as absent. Filed as iam: policy variables are compared literally, so a negated ${aws:username} is more permissive than on AWS #745.

    • Write-time operator-name validation — all four submitting paths (CreateRole,
      UpdateAssumeRolePolicy, CreatePolicy, and the shared handler behind
      PutUserPolicy/PutRolePolicy/PutGroupPolicy) answer MalformedPolicyDocument / 400 naming
      the operator, and store nothing. The vocabulary is not restated: recognition asks the evaluator
      itself, so the two cannot drift. Validation is on the submission paths only, never in
      PolicyDocument.UnmarshalJSON, which also runs on every read from state — validating there
      would make an already-stored document permanently unloadable. iam_set_qualifiers_test.go's
      "forallvalues:StringEquals" assertion stays at evaluation and stays green: AWS's
      case-insensitivity covers condition key names, not operator names. Predicted blast radius
      across the suite was 0 test failures; observed 0.

    • docs/services.md updated — the producer table gains ec2:ResourceTag/<key>, the
      no-producer list became a table with a reason per key, and a new subsection records which
      request parameters resolve to a resource and which still resolve to *, each with its reason.

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