Repository navigation
Description
Marker: INVESTIGATE — finding from
/security-reviewon PR #599 (2026-04-30). Validated at confidence 9/10. NOT a regression from #590; the gap was introduced by #581 ("voice tool calls + canvas orb", commit7d8abe8) when it merged todev. Filing here so it doesn't get lost.
Summary
The /ws/voice/{voice_session_id} WebSocket validates the JWT signature but never checks that the JWT's user owns the referenced voice session. Any platform-authenticated user holding a valid JWT can connect to any active voice session whose 128-bit voice_session_id they observe (logs, browser network tab, XSS-readable window.location, etc.).
Once connected, the attacker can:
- Eavesdrop on the victim's outbound audio + live transcripts
- Inject audio that gets transcribed and persisted to the victim's chat history under the victim's
user_id - Trigger tool calls audit-logged with
actor_id=<victim's id>, actor_email=<victim's email>— i.e. attributed to the victim
CVSS estimate: 6.5–7.0 (AV:N / AC:H / PR:L / UI:N / C:H / I:H / A:N) — high attack complexity because the 128-bit session id is the de-facto access gate, but the impact when leaked is full session impersonation including misattribution of actions.
Code evidence
src/backend/routers/voice.py — voice_websocket handler:
@router.websocket("/ws/voice/{voice_session_id}")
async def voice_websocket(
websocket: WebSocket,
voice_session_id: str,
token: str = Query(default=None),
):
session = voice_service.get_session(voice_session_id)
if not session:
await websocket.close(code=4004, reason="Voice session not found")
return
if token:
from jose import jwt, JWTError
from config import SECRET_KEY, ALGORITHM
try:
jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM]) # ← payload discarded
except JWTError:
await websocket.close(code=4001, reason="Invalid token")
return
else:
await websocket.close(code=4001, reason="Authentication required")
return
await websocket.accept()What's missing:
jwt.decode()is called and the result is thrown away —subis never extracted- No
db.get_user_by_username(...)lookup session.user_idis never compared against the JWT's user
Exploit chain
- Victim Alice initiates a voice session via
POST /api/agents/alice-agent/voice/start. Response returnsvoice_session_id = vs_<22-char token>. The id is also written to backend INFO logs and lives in Alice's browser scope. - Attacker Bob (any authenticated platform user, including a
user-role account that owns no agents) obtains the id via:- Backend log access (operator/admin)
- XSS in any third-party tool Alice has open that can read
window.location/ Vue store state - Browser network inspection if Bob has shared-screen / pair-programming visibility
- Bob connects:
wss://host/ws/voice/<vs_id>?token=<bob's JWT>. Server validates Bob's JWT signature, accepts the connection, never checks ownership. - Bob has bidirectional access to Alice's voice session for the duration.
Adjacent finding (lower priority — defense in depth)
POST /api/agents/{name}/voice/stop (also in voice.py) uses Depends(get_authorized_agent) to gate access to the path agent ({name}), but the request.voice_session_id from the body is never cross-checked against the path agent or current_user.id. This means any user with access to ANY agent can pass any other user's voice_session_id and forcibly end + persist a transcript to that other user's session.
The security reviewer rejected this as exploitable on its own (requires the same prior leak of the 128-bit id), but it should be fixed in the same PR as the websocket handler — the cross-check pattern is identical.
Acceptance Criteria
-
/ws/voice/{voice_session_id}extractssubfrom the decoded JWT, looks up the user, and rejects with WS close code 4003 ifuser.id != session.user_id -
voice_stoplooks up the session by id first, assertssession.agent_name == name AND session.user_id == current_user.id(or admin), and rejects with 403 otherwise - Unit test: WS handler rejects when JWT user != session owner
- Unit test:
voice_stoprejects body session_id that belongs to a different agent or user - Integration test: end-to-end attack chain returns 4003/403
Defense-in-depth follow-up (separate issue if not bundled)
Rotate /ws/voice/... to per-session ephemeral WS tickets — same single-use ticket pattern that #550 (/ws) and services/ws_ticket_service.py already implement. This means the session id alone is never sufficient to reach the WebSocket; the attacker would need a fresh ticket minted for them, which the ticket service won't do for a session they don't own.
References
- Discovered by:
/security-reviewskill on PR sec(files): close .mcp.json RCE-by-config bypass (AISEC-C2, #590) #599 (feature/590-files-guardrail-bypass), 2026-04-30 - Origin: Voice mode: Gemini Live with tool calls, dynamic prompt injection, and animated orb #581 (commit
7d8abe8, "feat(voice): tool calls + canvas orb for voice chat") - Pattern reference:
services/ws_ticket_service.py— single-use ticket atomic GETDEL with Redis (see SEC: WebSocket JWT passed in URL query param — CSWSH and token leakage #550 for the/wsrollout) - Related: AISEC pentest series (SEC: Redis has no requirepass — agent containers have unauthenticated full read/write access to platform task queue (AISEC-C1) #589, SEC: PUT /api/agents/{name}/files guardrail bypass → .mcp.json write → RCE and Anthropic token exfiltration (AISEC-C2) #590, SEC: /api/token rate limiter is a platform-wide DoS primitive — 4 bad attempts locks out all users for 10 minutes (AISEC-H2) #591, SEC: POST /api/agents/deploy-local bypasses creator role check — any authenticated user can spawn agents (AISEC-H1) #592, SEC: Missing HTTP Security Headers — nginx config hardening #549, SEC: WebSocket JWT passed in URL query param — CSWSH and token leakage #550) — file under same Epic if "AISEC Pentest" gets created
Activity
fix(security): voice WebSocket + stop endpoint missing ownership check (
Release: v0.6.0 (#998)
vybe commentedon Jun 1, 2026
Shipped in v0.6.0 (released via #998).
docs(releases): v0.6.0 release notes archive (#1016)
refactor(auth): INV-8 imperative auth-guard family — consolidate inli…