Skip to content

HIGH: Chat endpoints use body wallet instead of JWT-authenticated wallet #99

@rz1989s

Description

@rz1989s

Description

Both /api/chat and /api/chat/stream destructure wallet from req.body:

const { messages, wallet } = req.body  // untrusted!

They use this body-supplied wallet for session resolution (line 124/152), ignoring the JWT-authenticated req.wallet. Authenticated user A can pass wallet: "<user B>" in the request body and resolve user B's session context.

File

packages/agent/src/index.ts:113,141

Fix

Use (req as any).wallet from JWT instead of req.body.wallet:

const wallet = (req as unknown as Record<string, unknown>).wallet as string
const { messages } = req.body

Priority

HIGH — session impersonation via body parameter

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsecuritySecurity improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions