Repository navigation
feat(organizations): validate inline tags on every create path (#578) - #613
Merged
Merged
Conversation
CreateOrganizationalUnit, CreatePolicy and CreateAccount all accept an inline Tags list, and each stored it without running it through the validation TagResource applies. A key TagResource refuses could therefore be planted through a create instead — and an "aws:"-prefixed one would then be readable as aws:ResourceTag by a policy condition, so a tag-gated privilege boundary could be crossed with a key AWS reserves for itself and never lets a caller write. All three now share validateOrgCreateTags, which applies the same key and value shapes plus the per-resource count quota. The count is checked against the request alone, not a merge, since a resource being created carries no tags yet. The refusal comes before anything is written, so a retry does not collide with a duplicate-name exception for a resource the caller does not believe it created; for CreateAccount that means the refusal is synchronous even though the success is not, because a malformed request has nothing to vend. Each Tags field moves from []OrgTag to []orgTagInput so an absent value is distinguishable from an empty string — the first is refused, the second is legal — and orgValidateOUTags, which duplicated a weaker subset of the checks, is deleted. The new test runs one refusal table across all three operations rather than a per-operation copy, so a create that drifts more permissive than TagResource fails rather than being asserted only where someone remembered to. Verified against the botocore Organizations model: the Tags member of all three shapes is the same Tags list TagResource takes. Part of #578.
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.
CreateOrganizationalUnit,CreatePolicyandCreateAccountall accept an inlineTagslist, and each stored it without running it through the validationTagResourceapplies. A keyTagResourcerefuses could therefore be plantedthrough a create instead — and an
aws:-prefixed one would then be readable asaws:ResourceTagby a policy condition, so a tag-gated privilege boundary could becrossed with a key AWS reserves for itself and never lets a caller write.
This was the one genuine gap the tagging lane disclosed when it landed: the three
create handlers belong to other clusters, and the validation helpers were written to
be called from them but were not wired up.
What changed
validateOrgCreateTagsinorganizations_tags.go— the shared entry point. Samekey/value shapes as
TagResourceplus the per-resource count quota. The count ischecked against the request alone rather than a merge, since a resource being
created carries no tags yet.
behind and a retry does not collide with a duplicate-name exception for a resource
the caller does not believe it created. For
CreateAccountthe refusal issynchronous even though the success is not — a malformed request has nothing to
vend.
Tagsfield moves from[]OrgTagto[]orgTagInput, so an absent value isdistinguishable from an empty string (the first is refused, the second is legal).
orgValidateOUTags, which duplicated a weaker subset of the checks, is deleted.Testing
TestOrganizations_CreateOperationsShareTagValidationruns one refusal table acrossall three operations rather than a per-operation copy, so a create that drifts more
permissive than
TagResourcefails rather than being asserted only where someoneremembered to: system tag key, duplicate key, empty key, over-length key, key
outside the pattern, over-length value, over-quota count, plus a legal tag that must
still be accepted.
Mutation check: dropping the
MAX_TAG_LIMIT_EXCEEDEDguard fromvalidateOrgCreateTagsfails the new test on all three operations — CAUGHT.Gate:
gofmt -l .clean,go build ./...,go vet ./...,golangci-lint run ./...(0 issues),make test(race detector) all green.Verified against the botocore Organizations model at
organizations/2016-11-28/service-2.json: theTagsmember of all three createshapes is the same
TagslistTagResourcetakes.Part of #578.