Repository navigation
fix(#1086): Athena's two listings refuse a token they never issued - #1221
Merged
Merged
Conversation
ListQueryExecutions and ListWorkGroups both carried the pre-#915 idiom that decodes a base64 offset and discards both errors, so a token substrate could not have issued left the offset at zero and the operation answered a well-formed page one — the one wrong answer a paginating caller cannot detect. Both now share decodeOffsetPaginationToken and pageByOffsetToken. Both answer InvalidRequestException/400, published in both operations' own Errors sections, so #671's borrowing question does not arise. Athena has the strongest published footing of the five services left in this class: its NextToken is described, on the request parameter and again on the response element, as "A token generated by the Athena service", so a token no previous response carried is not what the parameter is documented to accept. What stays substrate's reading is only that this input problem is the one the published gloss covers. The published Length constraint of 1-1024 needs no check of its own: the encoder emits a handful of characters, so a longer token already fails the round trip, and the minimum of 1 is why an empty token is an absent one. The ordering criterion is counted rather than sealed. Athena's index loader reports a store failure as an empty index, so a sealed read answers 200 with an empty page — indistinguishable from an empty listing, and the seal would pass whichever side of the read the decode sat on. tokenRefusalCountingState counts reads in Athena's namespace, excluding the server's own authorization reads, and requires a refused request to have made none; a control with an issuable token must reach the index so a zero count cannot pass vacuously. Verified by moving the decode below the read: the subtest fails with one counted read. As at SNS, a token was silently portable between the two listings, and the operation name in the message is what makes that detectable. Part of #1086 — six sites carrying eight operations remain (CloudWatch Logs, Scheduler, Batch), so this does not resolve the issue.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
5 tasks
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.
ListQueryExecutionsandListWorkGroupscarried the pre-#915 idiom —base64.StdEncoding.DecodeStringthenstrconv.Atoi, both errors discarded — so a token substrate could not have issued left the offset at zero and the operation answered a well-formed page one. Both now sharedecodeOffsetPaginationTokenandpageByOffsetToken.Provenance
InvalidRequestException/400, published in both operations' own Errors sections and already this plugin's code for a malformed input at five other doors, so #671's borrowing question does not arise.Athena has the strongest published footing of the five services left in this class, and it is not the Errors section:
NextTokenis described, on the request parameter and again on the response element, as "A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated." A token no previous response carried is not what the parameter is documented to accept. What stays substrate's reading is only that this input problem is the one theInvalidRequestExceptiongloss covers — neither page publishes a code AWS attributes to a token, and Athena's common-errors page carries nothing about one either.The published Length constraint (1–1024, on both the request and the response) needs no check of its own: the encoder emits a handful of characters, so every longer token already fails the issuability round trip, and the minimum of 1 is why an empty
NextTokenis an absent token rather than an invalid one.The ordering criterion is counted, not sealed
The sealed-store assertion every other site in this class uses cannot work here.
athenaLoadStringIndexreports a store failure as an empty index, so a sealed read answers200with an empty page — indistinguishable from an empty listing, which means the seal would pass whichever side of the read the decode sat on.tokenRefusalCountingStatecounts reads in Athena's namespace and requires a refused request to have made none. Two things make that honest: the count is scoped to the plugin's namespace, because the server authorizes every request first and reads the principal and its policies out ofiambefore any plugin is dispatched to (unscoped, the count is 2 before the handler runs); and a control with a token the operation could have issued must reach the index, so a count of zero cannot pass by never reaching the handler. Verified to have teeth by temporarily moving the decode below the index read — the subtest fails with one counted read.Also in here
ListQueryExecutions' token decodes cleanly underListWorkGroups. The round-trip rule cannot catch it; the operation name in the message is what makes it detectable. A subtest pins that such a token is still accepted, so the docs claim and the behaviour agree. Still live at Batch, whose three describes share one paginator.docs/services.mdsaid "seven sites" remained after the SNS PR; the correct figure was eight, and after this one it is six sites carrying eight operations. Corrected. ("Sites" means decode locations: SNS was 2, not 3, because its two subscription listings shared one decode.)MaxResultsrange is not fixed — a value above 50 is accepted and one at or below zero is rewritten to 50. The rewrite is namedathenaListDefaultPageSizeand documented as substrate's choice, since neither page publishes a default. Named in the docs so the token fix is not read as covering it.Verification
Full gate clean:
gofmt/build/vet,golangci-lint0 issues,make test(race), Go 1.26.6 coverage 86.0% emulator / 85.5% total (floor 85.5/85.0), docs reference + drift + versions + authz reference, VitePress build,go vet/go testintest/e2e, and the discarded-unmarshal / version-stamping / tag-releases / wire-bookkeeping checks.Findings recorded on the issue: #1086 (comment)
Part of #1086 — CloudWatch Logs (4 sites), Scheduler (1) and Batch (1 shared paginator behind three describes) remain, so this does not resolve the issue.