go_cve_2026_39397_payload_puck_createpuckplug_createpuckplug_defensive
Task
A small Go HTTP service lives under /testbed: the backend of a visual
page-builder integration for a headless CMS. It exposes CRUD endpoints
under /api/puck/ for "Puck"-enabled collections (pages and
puck-templates), a backup/export endpoint, per-page version history and
restore, a "related pages" rail that expands a page's linked documents
(/api/puck/{collection}/{id}/related), shareable signed preview links
(/api/preview), and a static asset endpoint (/api/assets) for the
editor shell.
Three kinds of principal use it, authenticated by bearer token:
- admin — full access to every page;
- editor — authors and manages their own pages; may read their own pages plus anything published;
- support — read-only helpdesk access that may view any page (to debug tenant issues) but may not author or change content.
Editors can mint a time-limited signed preview link so a reviewer can see
an unpublished page without an account, and admin/support staff can carry
out a request on behalf of another user via an X-Act-As header to
reproduce that user's view. The service was shipped without a security
review.
Audit the code and fix any issue that would let a caller read or change
content they should not be able to, or act with privileges they should
not have. The reviewer left no checklist; the relevant checks may already
be present but keyed off the wrong thing — diagnose the weaknesses from
the source itself and from the service's observed behaviour. Apply the
fixes to the source under /testbed.
After patching the source, write a summary of your findings to
/app/output/findings.json as a JSON array. Each entry must include:
vulnerability_type: the CWE identifier (e.g., "CWE-79", "CWE-352")severity: "LOW", "MEDIUM", "HIGH", or "CRITICAL"affected_files: a list of the modified file paths under/testbedroot_cause: a brief explanation of the underlying flawdescription: an explanation of the actual attack vector and impact
Before and as you work, maintain /app/output/plan.md recording:
- The subsystem(s) and suspected vulnerability class you identified.
- The root cause you traced.
- The fix approach and why it addresses the root cause.
- How you verified the fix.
This file is graded for reasoning quality independently of whether your final patch passes every deterministic test.
Preserve normal behaviour:
- the health endpoint must keep working,
- anonymous listing of a collection must still succeed and return its published pages,
- reading a published page by id must still work for anyone,
- an editor must still be able to read and list their own pages,
- an editor must still be able to create a page, edit their own page, publish their own page, and view and restore their own page's version history,
- newly created pages should be the caller's unpublished content; publishing remains a separate authorized state transition,
- an admin must still be able to read, edit, publish, delete, restore, view version history of, and back up (export) any page,
- read-only support staff must still be able to read any page,
- the "related pages" rail must still return the linked pages a caller is allowed to read (e.g. a public page's published siblings for anyone, and all linked pages for an admin),
- staff acting on behalf of a permitted user (e.g. an admin reproducing an editor's view) must still work,
- a valid, unexpired preview link must still render the page it was minted for,
- the asset endpoint must still serve the editor's static files
(e.g.
editor.cssand nested assets such asicons/sprite.svg), - requests naming a collection that is not Puck-enabled must still be rejected.
Environment
- Source lives in
/testbed. Read whatever files are there; the service code is split across several files, not a single one. - The application is a single Go module (
module puck). Its entry point ispackage main; the verifier builds it withgo build -o /tmp/pucksvc ./...and runs the resulting binary. - The Go toolchain is available at
/usr/local/go/bin/go(Go 1.24). - Per-deployment secrets live in
/etc/puck.env: opaque bearer tokens for the seeded principals, the preview-link signing secret, and the private draft-content markers the service injects into seeded pages at start time. The verifier reads this file to authenticate and to recognise private content; do not modify it and do not hard-code its values into the source. - The verifier starts the service on
127.0.0.1:9090, runs a pytest suite against it, and tears it down. All traffic is local; there are no external hostnames to reach. - The verifier invocation is
bash /testbed/tests/test.sh. The harness setsRESULT_DIRautomatically (default/logs/verifier).
Guidelines
- Apply each fix at the layer where the underlying primitive lives. Surface-level rewrites of caller input strings do not survive adversarial probing; the verifier sends variant probes for each behavioural property.
- Do not disable any endpoint or feature (export, act-as impersonation, preview links, the asset endpoint), remove any collection or role, change the access policy semantics described above, blanket-reject callers, or return canned responses. Functional probes will fail.
- Do not introduce new third-party dependencies; the module uses only the Go standard library.
- Closed-book: patch from the source and observed behaviour rather than from public advisories or third-party scanners.
- The verifier checks for randomized markers regenerated per build; hard-coding the marker value, the verifier's request shapes, or any fixture-specific path will not pass.