Skip to content

fix(server): task output tail rejects provider ids that would escape the session directory - #39842

Closed
IzonIcy wants to merge 1 commit into
pingdotgg:mainfrom
IzonIcy:fix/claude-task-output-id-validation
Closed

IzonIcy wants to merge 1 commit into
pingdotgg:mainfrom
IzonIcy:fix/claude-task-output-id-validation

Conversation

@IzonIcy

@IzonIcy IzonIcy commented Nov 20, 2026

Copy link
Copy Markdown

Problem

ClaudeTaskOutputTail.locate builds path.join(root, project, sessionId, "tasks", ${taskId}.output) from the session_id and task_id on a provider task_started message. Neither value is validated. path.join normalizes .., so a malformed or spoofed id reads a file outside the session directory and streams its contents to the client as command output. Reported in #26489.

Change

Reject ids that are not plain tokens (/^[A-Za-z0-9_-]+$/) before the tailer starts. That pattern admits no .. segment, no path separator, and no drive prefix, so path.join cannot leave the session directory. A rejected id drops the live tail only; the tool result still carries the final read, so nothing else degrades.

The guard sits at the entry point rather than inside locate because the pattern already makes a separate containment check unreachable, and locate is module-private with one caller.

Scope

Fixes #26489. One underlying problem, one source file plus its test.

A strict-pattern rejection is smaller and more obviously correct than resolving the path and comparing it against the session root. If maintainers prefer containment as defence in depth, it can be added inside locate without changing the tests.

Verification

Two tests in ClaudeTaskOutputTail.test.ts:

  • does not follow a task id that would leave the session directory writes a file one level above the session's tasks directory and passes taskId: "../leak". Without the change the tailer finds it and offers secret\n; with the change it offers nothing.
  • does not follow a session id that would leave the project directory exercises the same shape on the session id.

Both fail against the unmodified file and pass with it:

$ vp test run src/orchestration-v2/Adapters/ClaudeTaskOutputTail.test.ts
before:  Tests  2 failed | 5 passed (7)
after:   Tests  7 passed (7)

apps/server typechecks clean (effect-tsgo tsrs --noEmit, exit 0, no findings in the changed file).

I did not run the full repository suite. The change is confined to this module and its test file.

Agent: deepseek-v4.1-flash on Capy.

…irectory

A task_started event's session and task ids become path segments under the
Claude temp root. path.join normalizes '..', so a malformed or spoofed id
could read a file outside the session's tasks directory and stream it to the
client as command output. Reject ids that are not plain tokens before the
tailer starts; the tool result still carries the final read.

Reported in pingdotgg#26489.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 18:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T18:36:08.564663Z e65b3f0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e65b3f08a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

stop: yield* Deferred.make<void>(),
onChunk: (chunk) => Queue.offer(chunks, chunk),
}).pipe(Effect.forkScoped);
yield* Effect.sleep("200 millis");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the real-time waits from these tests

Both new traversal tests call Effect.sleep("200 millis") inside it.live, so the configured t3code/no-real-time-wait-in-tests rule reports them and check:changed cannot pass. Coordinate the fiber result with the queue or a deferred instead of using a wall-clock window; the second test repeats this at line 143.

AGENTS.md reference: AGENTS.md:L115-L123

Useful? React with 👍 / 👎.

@juliusmarminge

Copy link
Copy Markdown
Member

Thanks for this. #36216 makes the same change and is the one being kept.

#36216 already rejects the same session and task IDs before output discovery. Its regression covers both traversal cases without the timed waits added here, so it is the smaller equivalent fix to keep.

Your report and the need for ID validation still stand; the existing pull request addresses the same underlying problem.

Closing as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Claude background-task output tail reads filesystem paths built from unvalidated provider stream ids

3 participants