Skip to content

fix(agent): reject unsafe ChatAgent session ids - #342

Merged
BaaRai merged 1 commit into
BaaRai:mainfrom
Coff0xc:fix/chat-session-id
Nov 18, 2026
Merged

BaaRai merged 1 commit into
BaaRai:mainfrom
Coff0xc:fix/chat-session-id

Conversation

@Coff0xc

@Coff0xc Coff0xc commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

ChatAgent.Chat joined sessionID into <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 passes conv-<int64>, but the exported method accepted any string.

The id must now match [A-Za-z0-9_-] (at most 64 bytes). After filepath.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.

Copilot AI balanced review requested due to automatic review settings November 18, 2026 17:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@BaaRai BaaRai left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
BaaRai force-pushed the fix/chat-session-id branch from 44ad728 to 2a9743e Compare November 18, 2026 21:40
@BaaRai
BaaRai merged commit 83a1d17 into BaaRai:main Nov 18, 2026
5 checks passed
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.

3 participants