Repository navigation
Conversation
Joining raw project, session, and subpath strings with slashes let session s plus subpath x address the same objects as session id s/x.
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.
What is the fix?
The S3 example builds an object prefix by sticking the project, the session id, and the subpath together with slashes. It does not encode those pieces first. S3 then treats that string as a folder. If a caller can choose the session id, they can pick a string that selects another session's folder.
Session
swith subpathxis stored underp/s/x/. Session ids/xis stored under the samep/s/x/. A load, a list, or a delete on one of those names reads or removes the other's transcript. Checking who the user is does not fix this. The application allows one pair of names. The store addresses the other pair's objects.What
Percent-encode each S3 key component before joining it with
/, and decode those components when listing sessions and subpaths, so a slash in one id cannot select another session's prefix.Why
The adapter is reference code that the README tells people to copy. The ids are documented as opaque, which means they are allowed to contain slashes. Without encoding, two different tuples share one prefix, and every read and delete on that prefix hits both.
How
encodeURIComponenteach ofprojectKey,sessionId, andsubpathinsidekeyPrefixandprojectPrefix.decodeURIComponentthe session id and subpath whenlistSessionsandlistSubkeysread them back out of the object key. A component that is not valid encoding is skipped.splus subpathxand session ids/xwrite two different prefixes and eachloadreturns only its own entry.