Repository navigation
Description
What
ec2:CreateTags takes ResourceId.N — a caller can tag an instance, a VPC and three subnets
in one call. Substrate authorizes that call against one ARN.
buildResourceARN's ec2 arm reads only InstanceId.1 (emulator/authz.go:555), which a
CreateTags request never carries, so the resource resolves to "*" and the decision is made
against a single value regardless of how many resources the request names. Per the mechanism
correction on #662, a request resource of "*" matches only a statement whose own Resource
entry begins with * — so the practical outcome is that an ARN-scoped Deny on any one of
the named resources never matches, and a broad Allow carries the whole call.
#662 explicitly scopes this out ("Whether ec2:CreateTags on launch needs the same treatment
… belongs in its own issue"). This is that issue, widened to CreateTags generally rather than
only its launch form.
What is not the problem
addRequestTags' ec2 arm (emulator/authz.go:834-857) is already correct and deliberately so
— it walks every tag in the request regardless of which resource type the specification is
scoped to, with a comment recording why narrowing it would silently weaken policy evaluation
(#468). Condition-key population is fine. Resource resolution is the gap.
Why it matters
The tag-based guardrail is the most common way a consumer fences off production: Deny ec2:CreateTags on arn:aws:ec2:*:*:vpc/*, or an aws:ResourceTag condition that must hold
on the resource being tagged. Neither survives a multi-resource call today. Worse, per-resource
tags cannot participate at all: a condition about the resource's existing tags is evaluated
against whatever "*" resolves to, so aws:ResourceTag on a CreateTags call is
unenforceable no matter how the policy is written.
DeleteTags has the identical shape and should be fixed in the same change.
The mechanism already exists
CheckAccess takes []authzResource — (ARN, tags) pairs, all of which must allow, each ARN
matched against its own tags — built by #660 and given its second caller by #662. This is its
third.
ec2TaggableStateKey (emulator/ec2_plugin.go:2417-2444) already maps an ID prefix to a state
key and is the natural source for per-resource tags: it is exactly the resolution CreateTags
itself uses to decide which resources a call touches, so reusing it keeps the decision and the
write agreeing about the resource set. Note that its allowlist omits vol- (see #670), so a
volume tagged today is both unauthorized-against and silently not tagged; the two fixes should
land aware of each other.
Acceptance criteria
-
CreateTagsnaming N resources is authorized against N ARNs, all of which must allow. - An ARN-scoped
Denyon any one named resource denies the whole call, with the failing
ARN in the message. - Each ARN is matched against its own existing tags, so an
aws:ResourceTagcondition
about a VPC cannot be satisfied by a tag on an instance in the same call. -
DeleteTagsgets the same treatment. - An ID prefix substrate does not recognize does not silently widen to
"*"— decide and
document whether it denies or is skipped. - The permission boundary is checked against every resource, not just the first (the
survivor mutation found in Organizations: MoveAccount does not authorize against SourceParentId/DestinationParentId, only AccountId #660). - Other EC2 operations keep today's single-resource decision; this is not a service-wide
change. - Tests fail before the change; an e2e journey drives it through the SDK.
-
docs/services.md' multi-resource authorization note extended toCreateTags/
DeleteTags. -
CHANGELOG.mdunder## [Unreleased], with a compatibility note: a broad-allow policy
that previously permitted a multi-resource tagging call may now be denied.
Activity
fix(ec2,iam): authorize every ID an EC2 request names (#744) (#763)
fix(ec2): the operation decides whether a request has a resource (#799)