Skip to content

fix: encode S3 session prefixes so one id cannot alias another - #478

Open
Oskii wants to merge 1 commit into
anthropics:mainfrom
Oskii:encode-s3-session-keys
Open

Oskii wants to merge 1 commit into
anthropics:mainfrom
Oskii:encode-s3-session-keys

Conversation

@Oskii

@Oskii Oskii commented Sep 24, 2026 •

Copy link
Copy Markdown

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 s with subpath x is stored under p/s/x/. Session id s/x is stored under the same p/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

  • encodeURIComponent each of projectKey, sessionId, and subpath inside keyPrefix and projectPrefix.
  • decodeURIComponent the session id and subpath when listSessions and listSubkeys read them back out of the object key. A component that is not valid encoding is skipped.
  • Add a unit test where session s plus subpath x and session id s/x write two different prefixes and each load returns only its own entry.

Joining raw project, session, and subpath strings with slashes let session s plus subpath x address the same objects as session id s/x.
@Oskii Oskii changed the title There is a security vulnerability. fix: encode S3 session prefixes so one id cannot alias another Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant