Repository navigation
fix(agent): reject unsafe ChatAgent session ids - #342
Merged
Merged
Conversation
BaaRai
approved these changes
Nov 18, 2026
BaaRai
left a comment
Owner
There was a problem hiding this comment.
Reviewed: the id charset and the session-dir containment check both hold, unsafe ids fail before the provider is called, and the tests pass. CI green.
Chat joined sessionID into <workDir>/sessions with no allow-list, so ".." or a separator would escape that directory. Production callers use conv-<id>, but the exported method accepted any string. Accept only [A-Za-z0-9_-] up to 64 bytes, then confirm the cleaned path still sits under sessions/.
BaaRai
force-pushed
the
fix/chat-session-id
branch
from
November 18, 2026 21:40
44ad728 to
2a9743e
Compare
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.
ChatAgent.ChatjoinedsessionIDinto<workDir>/sessions/<id>and used that path as the tool CWD,ToolOutputDir, and the noa archive name. There was no check for..or separators. The HTTP caller passesconv-<int64>, but the exported method accepted any string.The id must now match
[A-Za-z0-9_-](at most 64 bytes). Afterfilepath.Join, the cleaned path must still sit under<workDir>/sessions. Existing test ids (conv-stable,conv-hook-reach, …) stay valid.Tested:
go test ./agent -run "TestValidChatSessionID|TestChatRejectsUnsafeSessionID|TestChatSessionIdentityWithoutTranscript|TestChatMissingTranscriptStartsFresh"pass.