Skip to content

fix(api): PATCH /v1/profiles/general has no request validation #587

Closed

Description

@thinkclay

PATCH /v1/profiles/general parses the request body as an untyped record and writes whatever keys it finds straight to core.users and core.profile. It is the only write path for a user's name, phone, address and bio, and it has no server-side validation at all.

Evidence

packages/supabase/functions/api/routes/profiles.ts:390

const input = (await c.req.json()) as Record<string, unknown>
…
if (input.about !== undefined) profileUpdate.about = input.about
…
if (input.address !== undefined) privateUpdate.address = input.address
await supabase.schema("core").from("profile").upsert(privateUpdate)

No length caps, no type checks, no shape check on address, no cap on about. The client-side zod schema (general-schema.ts — 50-char names, 1500-char about) is the only enforcement, and any non-browser caller bypasses it. Every other route in this file uses createRoute + zod; this handler and GET /general are the two that do not.

Related: the same handler is what makes #580 destructive — "" passes !== undefined.

Acceptance

  • PATCH /v1/profiles/general is converted to app.openapi(createRoute(...)) with a request schema mirroring generalProfileSchema (names ≤50, about ≤1500, structured address, E.164-ish phone).
  • Invalid bodies return 400 with field-level errors, not 200.
  • Contract test covers over-long name, malformed address, and unknown keys.

Activity

  1. added
    bug
    agent-ready
    security
    on Aug 12, 2026
  2. thinkclay commented on Aug 12, 2026

    @thinkclay
    ContributorAuthor

    Part of the profile-building audit rollup: #594

  3. thinkclay commented on Aug 12, 2026

    @thinkclay
    ContributorAuthor

    Fixed in #597 — PATCH /v1/profiles/general now validates against a zod schema (extracted to functions/api/lib/general-info-schema.ts so it is testable without the edge runtime) and returns 400 with field-level detail. .strict() so an unexpected role or id key is a 400 rather than a silent no-op. 17 Deno assertions cover it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Backendagent-readybugpriority: highsecuritytype: backend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions