Skip to content

CloudFront has no UntagResource, and an untag request is misrouted to TagResource and answers success #883

Closed

Description

@scttfrdmn

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

  • parseCloudFrontOperation returns UntagResource for POST …?Operation=Untag, and stops mapping every Resource-bearing POST to TagResource — an unrecognized Operation value must not fall through to a write.
  • An UntagResource handler 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).
  • ListTagsForResource reports the tag gone after an untag, asserted through the wire rather than from state.
  • The Resource Groups Tagging API's UntagResources reaches CloudFront through the same path, or it is recorded why it does not — tagging_plugin.go resolves CloudFront ARNs today, so an untag there has the same hole.
  • A test that the misroute is closed: an Operation=Untag request 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

  1. added
    type: bug
    on Sep 15, 2026
  2. added this to the v0.117.0 milestone on Sep 15, 2026
  3. added a commit that references this issue on Sep 26, 2026
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

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions