Repository navigation
fix(ec2): the operation decides whether a request has a resource - #799
Merged
Merged
Conversation
Whether an EC2 request has a resource is a property of the operation, not of the parameters the request carries. AWS documents ec2:DescribeInstances as supporting no resource-level permissions, so a policy scoping it to an instance ARN grants nothing there — and granted precisely those instances here, because ec2AuthzNamedResources resolved InstanceId, GroupId, RouteTableId and InternetGatewayId for any operation carrying one and never looked at req.Operation. That is the direction that matters: it grants. A consumer's test scoping a describe to one instance passed against substrate and the deployment behind it failed on AWS, which is the precise failure substrate exists to prevent. docs/services.md recorded the divergence as deliberately left, on the reading that gating the resolver was a question about the resolution rather than about the batch #744 was fixing; this closes it. An ID is now resolved only when AWS documents the operation as supporting that resource type, read from the vendored Service Reference Information table rather than from a hand-written operation list, so it cannot fall behind an operation substrate adds later. An operation absent from that table is also decided against "*" — the same answer AWS gives an action with no published resource types, and the safe direction of the two, since a resource narrower than the one AWS would use is a grant substrate would be inventing. The early return also skips the state reads ec2TaggableResource performs for a pg- or key- ID. The three EC2 resolvers already gated on their operation are untouched: CreateTags and DeleteTags (#674) and RunInstances (#662). AWS scopes all three to resource types, so the gate confirms them rather than narrowing them. Two consequences, both pinned by tests rather than left to be rediscovered. DescribePlacementGroups, which reads pg- IDs through the overloaded GroupId, is now decided against "*"; the name-form placement-group ARN translation is still exercised by CreateTags, which AWS does scope to placement-group. And an ec2:ResourceTag/<key> condition on a describe can no longer match, because with the request resource "*" there is no resource whose tags to read — AWS's behavior too, and why the bundled policies put those conditions on the mutating operations. Three existing tests changed rather than being deleted: DescribeInstances' row in TestEC2_Authz_SingleResourceOperationsAreUnchanged now asserts "*", TestEC2_Authz_BatchDenialIsReplayStable drives TerminateInstances so its ordering assertion is not vacuous, and the placement-group row moved out of the four-parameter expansion table into the new gate test. Closes #762.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Whether an EC2 request has a resource is a property of the operation, not of the
parameters the request carries.
ec2AuthzNamedResourcesresolvedInstanceId,GroupId,RouteTableIdandInternetGatewayIdinto per-resource ARNs for any operation carrying one — it never looked atreq.Operation. AWS documentsec2:DescribeInstancesas supporting no resource-levelpermissions, so a policy scoping it to an instance ARN grants nothing there and granted exactly
those instances here.
That is the direction that matters: it grants. A consumer's test scoping a describe to one
instance passed against substrate while the deployment behind it failed on AWS — the precise
failure substrate exists to prevent.
docs/services.mdrecorded the divergence as deliberatelyleft, on the reading that gating the resolver was a question about the resolution rather than
about the batch #744 was fixing. This closes it.
The gate
An ID is resolved only when AWS documents the operation as supporting that resource type, read
from the table #797 vendored — not a hand-written operation list, so it cannot fall behind
an operation substrate adds later. The early return also skips the state reads
ec2TaggableResourceperforms for apg-orkey-ID.An operation absent from the table is also decided against
*: the same answer AWS gives anaction with no published resource types, and the safe direction of the two, since a resource
narrower than the one AWS would use is a grant substrate would be inventing.
make authz-reference-checkis what stops a stale snapshot from widening a decision quietly.The three EC2 resolvers already gated on their operation are untouched —
CreateTags/DeleteTags(#674) and
RunInstances(#662) — and AWS scopes all three to resource types, so the gateconfirms them rather than narrowing them.
Two consequences, pinned rather than left to be rediscovered
DescribePlacementGroupsis now decided against*. It readspg-IDs through theoverloaded
GroupId, which was the specific over-reachdocs/services.mdadmitted. Thename-form placement-group ARN translation is still exercised by
CreateTags, which AWS doesscope to
placement-group.ec2:ResourceTag/<key>condition on a describe can no longer match, because with therequest resource
*there is no resource whose tags to read. That is AWS's behavior too — AWScannot evaluate a resource tag for an action with no resource — and it is why the bundled
policies put those conditions on the mutating operations. Its own test says so, so it reads as
a decision rather than a regression.
Three existing tests changed rather than deleted
Each failed before the change, which is the fail-before evidence:
TestEC2_Authz_SingleResourceOperationsAreUnchanged—DescribeInstances' row now asserts*.TestEC2_Authz_BatchDenialIsReplayStable— drivesTerminateInstances; on a describe theordering assertion would be vacuous.
TestEC2_Authz_AllFourIDParametersExpand— the placement-group row moved into the new gatetest, where it asserts the opposite answer.
Verification
Closes #762.