Answer an unknown public link the same as an expired one - #725
Merged
Conversation
The page a public link resolves to is reachable without signing in. A hash that had expired or been used up got the permission-denied page; a hash nobody ever issued let a not-found exception escape to the generic handler, which rendered it through this action's plain-text type as the bare string 'Link not found'. So the two were distinguishable from outside. Nobody can walk the hash space — they are long random strings — but it told whoever was already holding one whether it had ever been real, which is not something this endpoint should answer. Catch it and fall through to the same refusal, logging the hash that was tried so an operator can still see it.
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.
The bug
The page a public link resolves to is reachable without signing in, and it answered two different ways:
Link not foundThe second is not a deliberate response at all — the not-found exception escaped the controller to the generic handler, which rendered it through this action's plain-text type.
So the two were distinguishable from outside. Nobody can walk the hash space — they are long random strings — but it told whoever was already holding a hash whether it had ever been real, which is not something this endpoint should answer.
Found while covering the link refusals (#723), where it was recorded rather than fixed.
The fix
Catch it and fall through to the same refusal. The hash that was tried is logged, so an operator can still see it.
Testing
The test that recorded the difference now asserts the sameness — it goes through the same body checker as the expired and used-up cases, which is the point: all three answers are the one answer.
Both suites green: 3074 unit, 837 integration.