Repository navigation
Conversation
|
Warning Review limit reachedNext included review available in 5 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: mrveiss/AutoBot-AI/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
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. Comment |
✅ SSOT Configuration Compliance: Passing🎉 No new hardcoded values of either class — Known backlog in |
|
Carried by vehicle #17086, which includes this PR's approved head |
Thinking Path
websocket_stream(autobot-backend/api/intelligent_agent.py) is the WebSockettwin of the authenticated
POST /api/intelligent_agent/process, but it onlycalled
enforce_ws_origin— which by its own docstring passes any client thatomits an
Originheader, i.e. every non-browser caller. Any client could reachagent.process_natural_language_goalwith no credential at all.POST /processrequiresDepends(get_current_user)but never threadscurrent_userintoagent.process_natural_language_goal(request.goal, context=request.context)beyond the auth gate itself — so the fix for theWebSocket doesn't invent new plumbing to pass an identity into the agent either;
it matches
/process's actual behavior: a verified caller is required beforethe goal ever runs.
For the auth mechanism and rejection shape, the issue named
api/voice_stream.py'svoice_stream_wsas the convention to follow exactly.I checked
api/ws_security.py'senforce_ws_authenticationas the issue alsosuggested, but it closes the socket without accepting first (code 1008) —
the opposite of the
voice_stream_ws/api/websockets.py(#2818) conventionthis repo already uses in the most call sites (
api/websockets.pyx3,api/voice_stream.py,api/transcripts.py,api/live_events.py,api/presence_ws.py): authenticate, then on rejectionaccept()thenclose(code=4001, reason=...)so the client gets a real WS close frame insteadof a raw handshake rejection indistinguishable from a missing route (#12366,
#15745).
enforce_ws_authenticationdidn't fit that convention, so I usedauth_middleware.authenticate_websocketdirectly, mirroringvoice_stream_wsline for line.
What Changed
autobot-backend/api/intelligent_agent.pywebsocket_stream: after theexisting
enforce_ws_origincheck, authenticate withauth_middleware.authenticate_websocketbefore anyreceive_json()orget_agent()call. On a missing/invalid token:accept()thenclose(code=4001, reason="Authentication required"), then return — therefused handshake never reaches
process_natural_language_goal.autobot-backend/api/intelligent_agent_ws_auth_17000_test.py(new): 4 testscovering the 4 acceptance criteria.
Not changed: the agent doesn't receive the authenticated principal as a new
parameter, because
/processdoesn't passcurrent_usertoagent.process_natural_language_goaleither — only using it as an auth gate.Threading it through would be new plumbing beyond what
/processdoes.Verification
Local (design aid only — environment is below CI's declared dependency floors;
CI is the evidence):
Also checked:
python3 -m py_compile api/intelligent_agent.py— OKpython3 -m black --check/python3 -m ruff checkon both changed files — cleantools/lint/check_decorator_order.pyon the modified file — no violationsfunction_length_checker.py --whole-fileon the modified file — no violations(
websocket_stream's counted body is unchanged in the 31–50 bucket; thedocstring addition doesn't count toward the limit)
api/intelligent_agent.pyis not inrepo_tests/python_file_size_ratchet_baseline.py(only
intelligence/intelligent_agent.py, a different file, is tracked), sono size-ratchet is at risk
docs/developer/THREAT_MODEL.mddoes not referenceapi/intelligent_agent.pyor
websocket_streamby line number, so no anchor needed updatingModel Used
Claude Sonnet 5
Closes #17000
🤖 Generated with Claude Code
Single-issue rationale
This is a single, self-contained critical security fix (unauthenticated agent WebSocket, #17000) with no other open issue sharing its scope or files. Batching it with unrelated work would only delay a critical fix reaching main.