Skip to content

tagging: TagResources bypasses the Kinesis per-stream tag quota, and no service's quota is enforced on that path #1000

Closed

Description

@scttfrdmn

Surfaced by #965, which made Kinesis's AddTagsToStream enforce the published fifty-tag-per-stream quota and deliberately left the other door open rather than half-closing it.

The gap

AddTagsToStream now refuses a request that would leave a stream holding more than fifty tags, with LimitExceededException/400. The Resource Groups Tagging API reaches the same tag set — TagResources on a stream ARN resolves through the Kinesis arm of TaggingPlugin.resolveARN and merges into the same KinesisStream.Tags map via mergeResourceTags — and enforces nothing. So:

TagResources  { ResourceARNList: [stream ARN], Tags: <60 tags> }   -> 200, 60 tags stored
ListTagsForStream                                                  -> an array longer than its own published maximum
AddTagsToStream { Tags: { "one": "more" } }                        -> LimitExceededException

The stream ends up in a state its owning service will not let a caller create, which is the same shape of inconsistency #965 existed to close, arriving by the other path. It is also #765's cross-readability criterion pointing the other way: the two paths agree about where the tags live (since #966 they share one ARN parser) and disagree about what may be written there.

Why it was not fixed in #965

mergeResourceTags is one helper serving sixteen namespaces, and TagResources does not fail a request outright — it publishes a FailedResourcesMap keyed by resource ARN, each entry carrying ErrorCode, ErrorMessage and StatusCode, precisely so a batch can partly succeed. Refusing one stream in a five-resource request therefore means:

  • a per-namespace quota predicate the merge path can consult, where today the merge arms know nothing but how to decode their own record;
  • the right ErrorCode in FailedResourcesMap for a quota refusal (RGTA publishes its own ErrorCode values as "the error code of the common error", so whether the underlying service's LimitExceededException or an RGTA code belongs there needs checking against API_TagResources);
  • and a decision about whether a request naming one over-quota stream and four fine resources tags the four — which AWS's shape says yes to and substrate's all-or-nothing tagging helper currently does not model.

Substrate enforces no tag quota for any service in the RGTA path today, so this is not a Kinesis-specific hole; Kinesis is simply the first service whose own operation enforces one, which is what makes the asymmetry visible.

Acceptance criteria

  • TagResources on a Kinesis stream ARN refuses a request that would take the stream over fifty tags, reporting the refusal in FailedResourcesMap under the ARN rather than failing the whole call — verified against API_TagResources' published FailedResourcesMap shape and ErrorCode semantics.
  • Which ErrorCode and StatusCode the entry carries is verified against AWS rather than assumed, and stated as substrate's reading if AWS does not settle it.
  • A request naming one over-quota stream and one other taggable resource tags the other resource, per the operation's partial-failure shape — or, if substrate's tagging helper cannot do that yet, the all-or-nothing behaviour is recorded explicitly and split into its own issue rather than left implicit.
  • The quota predicate is shared with AddTagsToStream rather than duplicated, so the two paths cannot disagree about the limit — the arrangement kinesis: no handler decodes StreamARN, so a caller holding a stream ARN cannot address the stream #966 established for the two paths' ARN parsing.
  • UntagResource/UntagResources freeing slots lets a later TagResources succeed, so the limit is a function of current state.
  • Whether the same treatment is owed to the other fifteen namespaces is answered on the record: which of them publish a per-resource tag quota, and whether enforcing one service's and not the others' is coherent. It may be that the honest outcome is a general mechanism, in which case that is the finding.
  • Tests assert the status and the code (fix(kms): NotFoundException is HTTP 400, and InvalidRequest is not a KMS code #923) and go over the wire (cfn: the aws:cloudformation:* stamp covers EC2 only, so the rest of a stack is unstamped #765).
  • docs/services.md's Kinesis section replaces its note that the tagging API does not enforce the quota.

Activity

  1. added this to the v0.119.0 milestone on Sep 17, 2026
  2. added
    type: bug
    on Sep 17, 2026
  3. scttfrdmn commented on Sep 18, 2026

    @scttfrdmn
    OwnerAuthor

    Premise corrections before the PR opens, per the v0.119.0 plan. Verified at 70071bc.

    The core claim holds. mergeResourceTags (tagging_plugin.go:1997) consults no quota on any arm — nothing in tagging_plugin.go references any tag-limit checker at all — so TagResources can push a Kinesis stream past fifty tags, after which AddTagsToStream refuses every further add.

    Two of the issue’s premises are false, and both are shipped in the docs.

    1. It is 23 arms, not sixteen. mergeResourceTags has 23 namespace cases and resolveARN has 23 service cases: s3, lambda, sqs, dynamodb, ec2, iam, apigateway, states, ecr, ecs, cognito-idp, kinesis, rds, acm, cloudfront, kms, sns, secretsmanager, ssm, elasticache, efs, glue, elb.

    2. Kinesis is not the first service to enforce a tag quota, so the bypass is not one service wide. Four services already enforce a fifty-tag per-resource quota through their own operations:

    Service Constant Code Status
    EC2 ec2MaxTagsPerResource (ec2_tags.go:45) TagLimitExceeded 400
    IAM iamMaxTagsPerResource (iam_tag_validation.go:109) LimitExceeded 409
    ELBv2 elbMaxTagsPerResource (elb_tags.go:38) TooManyTags 400
    AWS Config cfgsvcMaxTags (configservice_types.go:416) TooManyTagsException 400

    Three of those four have an RGTA arm — EC2, IAM and ELBv2 — so the bypass spans four services, not one, and a fix that hooks only Kinesis leaves three of them open. (Config has no RGTA arm, so its quota is not reachable this way.)

    Both falsehoods are stated in shipped prose and this issue corrects them:

    • docs/services.md (Kinesis, How many tags a stream may carry): "TagResources merges tags for sixteen services through one helper" and "substrate models no tag quota for any other service either." The second sentence is the damaging one — a consumer reading it concludes no service enforces a quota, when four do.
    • CHANGELOG.md:2922: the same "merges tags for sixteen services through one helper".

    What already exists, so is not work:

    • tagResources (tagging_plugin.go:1381-1405) already builds a per-resource FailedResourcesMap at HTTP 200, so the AC’s "tags the other four" is the existing shape rather than something to add.
    • kinesisCheckTagQuota (kinesis_tag_quota.go:107) already has a signature that can be called directly: (target, existing, adding) *AWSError.

    What is missing is a third arm in tagMergeFailure (tagging_plugin.go:1533) mapping an *AWSError to {ErrorCode, ErrorMessage, StatusCode} instead of falling through to its InternalServiceException/500 default — a quota refusal that surfaces as a 500 is worse than the bypass, because it blames substrate for the caller’s request.

    Where the AWS citation sits. API_TagResources publishes "Each resource can have up to 50 tags" on its own page, so the shared rule is AWS-backed at the RGTA level and does not have to be borrowed from each owning service. FailureInfo’s ErrorCode publishes two Valid Values while its own prose admits the owning service’s code, so putting a service-specific code (TagLimitExceeded, LimitExceeded, TooManyTags, LimitExceededException) in the entry is substrate’s reading of AWS disagreeing with itself — recorded, not resolved.

  4. added a commit that references this issue on Sep 19, 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