Skip to content

Confirmation response attachments not validated on WebSocket path #32

@unspecifiedcoder

Description

@unspecifiedcoder

Summary

The REST endpoint POST /api/automations/confirmations/:id/respond validates the request body via Zod in src/server/routes/automations.ts. The corresponding WebSocket handler in src/server/routes/ws/commands/confirmation-response.ts forwards message.data to handleConfirmationResponse and bus.publish with no validation.

A malformed client payload (or one from a compromised client process such as a browser extension or embedded webview) can therefore inject content into the model prompt via formatConfirmationAttachmentBlock in src/server/processor/confirmation/confirmation.service.ts, which formats the attachment list into an <attached_files> block fed back to the LLM.

Impact

Prompt-injection foothold, not a direct file-read vulnerability — the agent still has to call read_file, which is gated by the sensitive-path check covered by tests/server/security/tool-protection.test.ts. But:

  • attachments may be an arbitrarily large array, becoming a large prompt suffix
  • path may be a non-string (number, object, prototype-shaped value)
  • The asymmetry (REST validated, WS not) is hard to spot from the call sites and easy to regress

Proposed fix

Extract the response schema into a shared module under src/server/processor/confirmation/ and consume it from both transports. Cap attachments-per-response, path length, and name length.

I have a fix ready locally and will open a PR shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions