Repository navigation
Description
resolveSecretID (emulator/secretsmanager_plugin.go) splits an identifier on : and returns the
last segment, and every one of the ten operations taking a SecretId then keys its load and its
store by the caller's own account and Region. Four defects compound into one: a secret ARN naming
another account or Region addresses the caller's own secret of that name.
This is the rule #826 established for SQS and DynamoDB, #845 carried into the tagging API's resolver,
and #910 (Step Functions), #918 (CloudFront), #922 (KMS) and #925 (SNS) applied service by service:
the account and Region come from the ARN, never from the request context.
Alongside it, the Secrets Manager row of #835: the Resource Groups Tagging API has no
secretsmanager arm at all, so a secret ARN falls to resolveARN's default and comes back as a
FailedResourcesMap entry, and GetResources reports no secrets.
The four defects
-
The account and Region come from the caller. Every handler calls
p.loadSecret(goCtx, ctx.AccountID, ctx.Region, name)with the name the resolver returned, so
arn:aws:secretsmanager:eu-west-1:999988887777:secret:db-password, presented by aus-east-1
caller in111122223333, addresses that caller's owndb-password.UntagResourceis the
damaging direction and answers200while stripping its tags;GetSecretValuereads its value and
DeleteSecretdeletes it. -
The type keyword is never checked. A secret ARN is
arn:{partition}:secretsmanager:{region}:{account}:secret:{name}, whose fifth colon-delimited
segment is the literalsecret. Nothing anchors a match against it, so
arn:aws:secretsmanager:r:a:other:foonames a secret calledfoo. Per Step Functions: all three tag operations take the account from the request, not the ARN, so a foreign-account ARN tags the caller's own state machine #910 the match must be
against the whole segment, not a prefix — otherwisesecretpolicyand any keyword AWS adds
later resolve as a secret. -
The service is never checked. An ARN belonging to another service resolves to its own last
segment as a secret name. -
The length guard falls through to returning the argument, so a malformed ARN —
arn:aws:s3:::b,
a URL, an ARN with too few segments — becomes a name and is looked up as one rather than
refused.
Defect 4 is the one that is not entirely wrong: AWS documents SecretId as "The ARN or name of the
secret", so a bare name is a valid identifier. What is wrong is applying the fallback to anything
beginning arn:, which is a caller who meant an ARN and mistyped it.
What is different about this service
The name/ARN split. A bare name carries no account, which makes the caller's own account the
correct source for that one case and only that one. So the fix is not "never read the request
context" but "the ARN path structurally cannot": the ARN parser takes no account, Region or
*RequestContext parameter, and the name path takes them explicitly.
Acceptance criteria
- An ARN parser that takes no account, Region or
*RequestContext, matching the service and
thesecretkeyword as a whole segment, and refusing an empty Region, account or name with
InvalidParameterException/400. - A bare name still resolves in the caller's account and Region; anything beginning
arn:that
does not parse is refused rather than treated as a name. - The name is the whole remainder after the keyword, so a hierarchical
prod/db/password
round-trips through its own ARN. - All ten
SecretId-taking operations resolve through it, and load and store at the target's
account and Region.DeleteSecretremoves the owning account and Region's index entry, not
the caller's. - The tagging API gains a
secretsmanagerresolveARNarm, amergeResourceTagsarm behind a
colon-terminated taggability guard, and a scanner plus descriptor soGetResourcesreports
secrets. Both APIs go through one key builder, so they cannot disagree about which secret an
ARN names. - Tags are read back through
DescribeSecretper cfn: the aws:cloudformation:* stamp covers EC2 only, so the rest of a stack is unstamped #765 — Secrets Manager publishes no
ListTagsForResource. - Deterministic tag order at every write arm, per tagging: the four merge helpers store a resource's tags in Go map order, so one state hashes two ways #862.
Notes
The colon-terminated guard is required, not optional. secret is a prefix of both secret_names
and secret_version in the same namespace. That is the fifth namespace to collide after
cert/cert_arns, cfdist/cfdist_ids, key/key_ids and topic/topic_names. Reaching a
secret_version: key would be the worst of the three: its value is a caller's secret payload, not
JSON, so a tag merge there would corrupt it.
Out of scope, deliberately. Substrate mints an ARN with no random suffix
(generateSecretARN), where AWS appends - plus six random characters. AWS's own warning — "Do not
end your secret name with a hyphen followed by six characters" — is why that matters: substrate
minting no suffix is what makes ARN-to-name derivation exact here, and adding one would be an
#826-class change to a value CloudFormation records as a PhysicalID and would make the resolver
ambiguous by construction. Separate decision.
Part of #835.
Activity
fix(secretsmanager): a SecretId resolves to the secret its own ARN na…
fix(ssm): a tag call resolves to the resource type it names (#932) (#934