You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Finding: cancel_chat_turn answered 403 for another user's conversation, and the same call for an unknown id answered 200 no_active_turn (a write lets an id with no session through as legacy_unowned), so ids were enumerable both ways. The session trace already mapped to 404 with its own private copy of the mapping; the conversation-file owner routes mapped NotSessionOwner inline with a literal body. Three copies of one decision.
Fix: one decision point in security/session_posture.py: session_not_found() (status and body) and validate_strict_hidden(session_id, request, must_exist=...). Turn cancel and trace call it; the file owner routes and unowned_access use session_not_found(). The real denial is still logged server side (_strict_owner_check). An unreadable owner stays 403 (#14033). The STRICT attachment checks in chat_streaming.py return a boolean and never a status, so they reveal nothing.
Exception recorded: the admin-only file routes need no change. Admins pass STRICT for any id and non-admins get the admin gate's 403 for every id, so the response does not depend on whether the id exists.
What Changed
autobot-backend/security/session_posture.py: session_not_found, validate_strict_hidden; unowned_access uses it.
autobot-backend/api/chat_trace.py: private mapping removed, uses the helper.
autobot-backend/api/conversation_files.py: owner routes call validate_strict_hidden(..., must_exist=True); the admin-only routes keep the explicit 403 branch.
autobot-backend/api/chat_turn_17273_test.py: 403 assertion now 404, plus foreign-equals-unknown (byte-identical status and body) and a seam test.
changelog/unreleased/20413-strict-routes-404.md.
Verification
pytest -q api/chat_turn_17273_test.py api/chat_trace_19963_test.py api/conversation_files_owner_routes_20195_test.py: 38 passed. The owner still succeeds (cancel 200; trace 200).
Control: with the four source files restored to origin/main, chat_turn_17273_test.py gives 3 failed, 4 passed (non-owner 404, foreign-equals-unknown, strict-validator seam).
Single-issue rationale: one security defect class (existence leak on STRICT routes) fixed once in the shared helper; it touches no file another open PR holds.
Review follow-up (local commit): api/strict_routes_hidden_20413_test.py pins, for trace and the five file owner routes, foreign == unknown byte-identical, owner succeeds, unreadable owner 403; for the admin-only routes, a non-admin gets the same 403 for existing and unknown ids and an admin passes. Control: with validate_strict_hidden neutralised, 9 tests fail (trace, 4 panel routes, upload, 3 cancel tests).
Notice: 29 open PRs — past the runaway threshold (25)
This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.
This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.
If the queue is draining normally, ignore this. Otherwise:
Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
Look for a loop opening near-identical PRs
Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.
Strict chat routes and existing-only file operations now use shared 404 handling for specified inaccessible conversations. Tests verify matching responses for foreign and unknown conversations and confirm refused cancellation does not change turn state or checkpoints.
Adds session_not_found() and validate_strict_hidden(). The validator maps NotSessionOwner and, when must_exist=True, legacy_unowned to the shared 404 response.
Route integration and validation autobot-backend/api/chat_trace.py, autobot-backend/api/chat_turn.py, autobot-backend/api/conversation_files.py, autobot-backend/api/chat_turn_17273_test.py, changelog/unreleased/20413-strict-routes-404.md
Chat trace and cancellation routes use the shared validator. Existing-only file operations use the shared 404 helper for specified ownership failures. Tests check response equality and cancellation state; the changelog records the response behaviour.
Merge Risk: Low · previous review fdcc8
Unknown-session cancellations by administrators can return success instead of 404. This is a bounded inconsistency; normal-user response hiding is supported, with additional file-route test coverage recommended.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title describes the main change: STRICT chat routes return the same response for another user's session as for an unknown session.
Docstring Coverage
Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 5 files. (1 skipped: 1 unsupported.)
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between abb3d51 and fdcc815.
Files selected for processing: 6
autobot-backend/api/chat_trace.py
autobot-backend/api/chat_turn.py
autobot-backend/api/chat_turn_17273_test.py
autobot-backend/api/conversation_files.py
autobot-backend/security/session_posture.py
changelog/unreleased/20413-strict-routes-404.md
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Security check, traced through the code: a foreign session (NotSessionOwner from _strict_owner_check) and an unknown session (unowned_access for GET, or must_exist on legacy_unowned for the POST) both end in the single session_not_found(), so status and body are byte-identical on trace and cancel. The owner path is intact: owner_match and the admin decisions are returned untouched. An unreadable owner stays 403 independent of the id. The one gap is test coverage of that claim on the GET routes.
Severity
file:line
finding
suggested fix
major
autobot-backend/api/chat_trace.py (_require_readable) and autobot-backend/api/conversation_files.py:85-90
The behaviour changed on two routes with no test change: chat_trace_19963_test.py and conversation_files_owner_routes_20195_test.py are untouched, and the byte-identical foreign-vs-unknown assertion is only written for turn cancel. The trace route's new foreign-vs-unknown equivalence (including the unreadable-owner 403 staying 403) is unproven, and it was the route that carried the old private 404 mapping.
Add a foreign-vs-unknown byte-equality test and an unreadable-owner-stays-403 test for the trace route, parametrized next to the cancel test.
minor
autobot-backend/api/conversation_files.py:85-90
Second implementation left in place: this route still catches NotSessionOwner itself and maps it to session_not_found(), plus its own legacy_unowned check, which is what validate_strict_hidden(..., must_exist=existing_only) now does. It cannot be switched over blindly because existing_only=False re-raises the 403.
Use validate_strict_hidden for the existing_only branch so there is one decision point; keep the 403 branch explicit.
The spy replaces security.session_posture.validate_strict and asserts only that it was called with the session id. It no longer pins that the posture is STRICT or that must_exist is set (the old test pinned the posture). Removing must_exist=True at chat_turn.py:56 would not fail any test, and that argument is what stops a cancel on a nonexistent id from passing.
Add a cancel test on a nonexistent id as a non-admin (expects 404), and an admin control.
nit
changelog/unreleased/20413-strict-routes-404.md:5
pr: 0000 placeholder.
Fill in the PR number if the changelog check expects it.
Head is 0 behind main, 8 changed files (6 ahead; the review-follow-up test file is now pushed). Body claims checked against the head: api/strict_routes_hidden_20413_test.py exists and covers trace, the five file owner routes (foreign == unknown byte-identical, owner succeeds, unreadable owner 403 for any id) and the admin-only routes (same 403 for existing and unknown ids; an admin passes). Turn cancel is pinned in chat_turn_17273_test.py. Both ACs of #20413 are met: every remaining STRICT caller answers a foreign and an unknown id the same, the admin-only exception is recorded with its reason, and a test pins each route. No fixed sleeps, no hardcoded config, no duplicate helper (the private trace mapping and the inline file-route mapping are replaced by session_not_found / validate_strict_hidden), new helpers are under 30 lines, conversation_files.py is 960 lines against a ceiling lowered to 960.
The owner-route comparison pits a foreign id against an unknown one; an existing but unowned session (owner None, exists True) is not compared on the file routes. Non-blocking: the helper's must_exist path is pinned for cancel. Add the third case when the file is next touched.
An admin cancelling an unknown id gets 200 no_active_turn, not 404. Intended and pinned by a test: an admin may already read every session, so no id is revealed to a non-admin. Reply on the thread with that reason.
Threads: 2 unresolved (both CodeRabbit, both addressed above as non-blocking). None resolved by me, since the head code does not itself answer either.
Code review (code-reviewer pass) follow-up at 5acc4dd
Trainmaster item
How it is addressed
File routes: a file that exists but is not owned by the caller must answer byte-equal to the not-found response
Added test_owner_routes_file_in_another_conversation_is_byte_identical_to_an_unknown_file in strict_routes_hidden_20413_test.py (preview, download, delete); the delete 404 echoes the caller's own id, which the test masks before the byte comparison.
Admin cancel of an unknown id returns 200
Intentional; pinned by chat_turn_17273_test.py::test_cancel_on_a_nonexistent_id_is_404_for_a_user_but_not_an_admin. Replied on the thread.
For preview, download and delete, a file that exists in another conversation is requested through the caller's own conversation and compared with an id that does not exist. Status and body must match. Delete echoes the caller's own file id in its 404 detail, so the test masks that id on both sides and compares everything else. Status is also pinned to 403 or 404.
2
LOW
same test
status_code in (403, 404) is loose. The equality assertion is the real check, so this is not blocking.
3
Note
scope
The existing-but-ownerless conversation case on the file routes is not asserted. By design that case is let through as legacy_unowned, not hidden, so there is no byte-equality to pin.
Threads: 1 unresolved on entry (the chat_turn_17273_test.py missing/unowned comparison). The head now pins the missing-conversation case (existing tests) and the existing-file-in-another-conversation case (new test), and the author replied with the test name. Resolved. The other thread (session_posture.py) was already resolved, so no admin-cancel thread is open.
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
phase:M3.9Chat, Agents, Analytics and Settings screens
1 participant
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.
Thinking Path
Finding:
cancel_chat_turnanswered 403 for another user's conversation, and the same call for an unknown id answered 200no_active_turn(a write lets an id with no session through aslegacy_unowned), so ids were enumerable both ways. The session trace already mapped to 404 with its own private copy of the mapping; the conversation-file owner routes mappedNotSessionOwnerinline with a literal body. Three copies of one decision.Fix: one decision point in
security/session_posture.py:session_not_found()(status and body) andvalidate_strict_hidden(session_id, request, must_exist=...). Turn cancel and trace call it; the file owner routes andunowned_accessusesession_not_found(). The real denial is still logged server side (_strict_owner_check). An unreadable owner stays 403 (#14033). The STRICT attachment checks inchat_streaming.pyreturn a boolean and never a status, so they reveal nothing.Exception recorded: the admin-only file routes need no change. Admins pass STRICT for any id and non-admins get the admin gate's 403 for every id, so the response does not depend on whether the id exists.
What Changed
autobot-backend/security/session_posture.py:session_not_found,validate_strict_hidden;unowned_accessuses it.autobot-backend/api/chat_turn.py: usesvalidate_strict_hidden(..., must_exist=True).autobot-backend/api/chat_trace.py: private mapping removed, uses the helper.autobot-backend/api/conversation_files.py: owner routes callvalidate_strict_hidden(..., must_exist=True); the admin-only routes keep the explicit 403 branch.autobot-backend/api/chat_turn_17273_test.py: 403 assertion now 404, plus foreign-equals-unknown (byte-identical status and body) and a seam test.changelog/unreleased/20413-strict-routes-404.md.Verification
pytest -q api/chat_turn_17273_test.py api/chat_trace_19963_test.py api/conversation_files_owner_routes_20195_test.py: 38 passed. The owner still succeeds (cancel 200; trace 200).chat_turn_17273_test.pygives 3 failed, 4 passed (non-owner 404, foreign-equals-unknown, strict-validator seam).test_a_non_owner_gets_the_response_a_missing_session_gets), file owner routes (bug(chat): a file attached to a chat message never reaches the answer #20195 test).Closes #20413
Model Used
Claude Sonnet 5.5
Single-issue rationale: one security defect class (existence leak on STRICT routes) fixed once in the shared helper; it touches no file another open PR holds.
Review follow-up (local commit):
api/strict_routes_hidden_20413_test.pypins, for trace and the five file owner routes, foreign == unknown byte-identical, owner succeeds, unreadable owner 403; for the admin-only routes, a non-admin gets the same 403 for existing and unknown ids and an admin passes. Control: withvalidate_strict_hiddenneutralised, 9 tests fail (trace, 4 panel routes, upload, 3 cancel tests).