Repository navigation
Description
CloudFront implements TagResource and ListTagsForResource and not UntagResource, so a tag substrate accepts on a distribution can never be removed. Worse than the missing operation: an UntagResource request is misrouted to TagResource, which writes the distribution back unchanged and answers success, so a caller removing a tag is told it worked and the tag is still there.
The dispatch has two arms where AWS has three
CloudFrontPlugin.HandleRequest (emulator/cloudfront_plugin.go:69-72) handles TagResource and ListTagsForResource. There is no UntagResource arm, and parseCloudFrontOperation never returns that name.
The misroute, precisely
AWS sends an untag as POST /2020-05-31/tagging?Operation=Untag&Resource=<arn> with a <TagKeys> body. parseCloudFrontOperation (:80-113) checks the query parameters first:
if method == http.MethodPost {
if op, ok := params["Operation"]; ok && strings.EqualFold(op, "Tag") {
return "TagResource", ""
}
}
if params["Resource"] != "" {
switch method {
case http.MethodGet:
return "ListTagsForResource", ""
case http.MethodPost:
return "TagResource", ""
}
}Operation=Untag fails the EqualFold(op, "Tag") test at the first arm — and then falls into the second, which maps any POST carrying a Resource parameter to TagResource. The /tagging path arm at :106-112 does the same.
tagResource (:455) then reads Resource, loads the distribution, and decodes the body as Tags>Items>Tag:
if len(req.Body) > 0 {
_ = xml.NewDecoder(bytes.NewReader(req.Body)).Decode(&xmlTags)
}A <TagKeys> document matches no Tag element, and the decode error is discarded, so xmlTags.Items is empty, the loop adds nothing, and the distribution is marshalled back byte-identical and stored. The response is the tagging success. There is no error, no warning, and no change.
So the failure is not "operation not supported" — which a caller could handle — but a successful no-op: UntagResource answers 2xx, ListTagsForResource still reports the tag, and nothing anywhere says the removal did not happen. This is the same class as the applyTagsToResource silent-200 defect that v0.115.0 removed for ECS.
Acceptance criteria
-
parseCloudFrontOperationreturnsUntagResourceforPOST …?Operation=Untag, and stops mapping everyResource-bearing POST toTagResource— an unrecognizedOperationvalue must not fall through to a write. - An
UntagResourcehandler removes the keys named in the<TagKeys><Items><Key>body from the distribution's tags, verified against the AWS API reference for the request shape. - Removing a key that is not present succeeds, per AWS's documented behaviour for the operation (verify — do not assume).
-
ListTagsForResourcereports the tag gone after an untag, asserted through the wire rather than from state. - The Resource Groups Tagging API's
UntagResourcesreaches CloudFront through the same path, or it is recorded why it does not —tagging_plugin.goresolves CloudFront ARNs today, so an untag there has the same hole. - A test that the misroute is closed: an
Operation=Untagrequest must not answer the tagging success while leaving the tags unchanged. This is the assertion that fails today.
Found while auditing tagging reachability for the v0.116.0 cut.
Activity
fix(cloudfront): add UntagResource, and stop routing an untag to the …
fix(cloudfront): add UntagResource, and stop routing an untag to the …
feat(#1277): the CloudFront origin access control family, and a tagge…