Skip to content

Bug: chat attachment caps (count/size/type) are client-side only — chatWithAgentTurn re-enforces none of them #2661

Closed

Description

@yannickmonney

Problem

The chat composer enforces four attachment limits — max 10 files, 200 MB total, 100 MB per file, and an allowed-MIME allowlist — entirely on the client. The server mutation that accepts a turn (chatWithAgentTurn) takes an unbounded attachments[] array with client-supplied fileType/fileSize and never re-validates any of it. The task-attachment path does re-check server-side (convex/tasks/attachments.ts), so this is an inconsistency as well as an abuse vector: a scripted client (or DevTools) can attach arbitrarily many/large/disallowed files to a chat turn.

Current behaviour

Code-grounded (2026-07-11, main @ 94ef84e):

  • convex/agents/chat_turn.ts:55-64,153,367 — chatWithAgentTurn accepts attachments with no count/size/type ceiling; checkUploadPolicy returns "allowed" when the org has no upload policy configured (the default), so nothing bounds it.
  • Contrast convex/tasks/attachments.ts:28,36 — the task path re-enforces size/type server-side.

Repro (authenticated): in DevTools, call the Convex mutation for a chat turn with attachments of 30 entries and a fileSize of 5e8 — accepted, unlike the UI's 10-file / 100 MB guard.

Code pointers

  • convex/agents/chat_turn.ts:55-64,153,367
  • client caps: chat composer upload gate (app/features/chat/... upload hook) — the only place the limits live today
  • convex/tasks/attachments.ts:28,36 — the correct server-side pattern to mirror

Proposed change

Re-enforce the four caps server-side in chatWithAgentTurn (count, total size, per-file size, MIME allowlist), mirroring the task path, independent of whether an org upload policy exists.

Acceptance criteria

  • chatWithAgentTurn rejects over-count / over-size / disallowed-type attachments server-side with a ConvexError
  • Limits match the client caps and the task-path enforcement
  • A test drives the bypass (oversized/over-count) and asserts rejection

Distinct from #1620/#2026/#2048/#2078 (closed — those were client-path bypasses; this is the missing server mirror).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: highsecurityservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions