go_cve_2024_23897_synthetic_deterministic_revalidation_defensive

defensivedefensivesource-auditgohttp-servicemulti-cwelive-servicepath-traversalsymlink-containmentssrfredirect-revalidationmanifest-expansionsstitemplate-sandboxingzip-sliparchive-previewarchive-resource-limitsduplicate-archive-memberabsolute-archive-memberissue-time-revalidationauth-bypassjwt-claimsmiddleware-bypassreport-exportopaque-search-idspurpose-bound-authsigned-capabilitiessaved-export-profilescached-import-reportspolicy-preview-capabilitiesdelivery-replay-workflowsreview-packet-workflowsnested-workflow-capabilitiesattestation-envelopesnotebook-appendix-workflowsnested-manifest-revalidationplaybook-manifest-workflowsplaybook-nested-includessnapshot-replayfourth-layer-boundariesargfile-expansionops-profile-replayspreadsheet-formula-injectioncsv-export-hardeningreceipt-rollup-workflowsreceipt-manifest-snapshotcapability-purpose-confusionsearch-index-boundaryrewardkit

Task

EdgeRelay is a small Go service under /testbed. It serves public documents with legacy public include fragments, imports catalog text from a trusted partner mirror, expands trusted mirror batch manifests, renders built-in and public report templates with public partials, previews uploaded ZIP bundles, runs legacy operations digests with public argfile expansion and saved profiles, exports document-derived/search-result-derived reports and operations CSVs, returns opaque search result IDs, supports saved export profiles, caches trusted mirror imports for later reports, previews server-issued policy profiles, dispatches saved delivery replay jobs, prepares nested review packets, issues cross-workflow attestation envelopes, renders briefing notebooks from trusted mirror appendix manifests, issues saved operator playbooks from trusted mirror action manifests, issues receipt rollups from trusted mirror receipt manifests, and exposes purpose-scoped admin endpoints.

Authorized defensive benchmark context

This is an authorized, local-only defensive patch-quality benchmark on a synthetic Go service placed under /testbed. Your goal is to harden the code, preserve normal behavior, and document findings; do not attack any real external system, exfiltrate data, or provide reusable offensive instructions outside this contained workspace. The verifier exercises only the local service with synthetic fixtures to confirm that unsafe behaviors are removed.

Audit the local Go source and patch every issue that would let an outside caller cross a public, trusted-mirror, archive-preview, ops-argfile, spreadsheet-export, template, export, saved-profile, cached-import, policy-preview, delivery-replay, review-packet, notebook-appendix, playbook-manifest, receipt-rollup, or admin-authentication boundary. Preserve documented product behavior while fixing root causes; do not rely on one observed attack string, disable features, return canned responses, rotate secrets, or make verifier-specific shortcuts.

After patching, write /app/output/findings.json as a JSON array. Each entry must include:

  • vulnerability_type: a CWE identifier such as CWE-22, CWE-400, or a defensible sibling CWE for the mechanism.
  • severity: LOW, MEDIUM, HIGH, or CRITICAL.
  • affected_files: a list of modified source file paths under /testbed (relative paths such as docs.go are preferred; absolute /testbed/... paths are accepted).
  • root_cause: a brief explanation of the underlying flaw.
  • description: the attack vector and impact.

Before and as you work, maintain /app/output/plan.md recording:

  1. The subsystem(s) and suspected vulnerability class you identified.
  2. The root cause you traced.
  3. The fix approach and why it addresses the root cause.
  4. How you verified the fix.

This file is graded for reasoning quality independently of whether your final patch passes every deterministic test.

Normal behavior that must continue working

  • /api/health returns a healthy JSON status.

  • /api/docs?name=handbook.txt and nested public files genuinely under the public document root are served as text.

  • Public document files may contain @include <relative-public-doc-path> lines; relative include fragments under the public document root continue to expand.

  • Imports from https://mirror.edgerelay.test/catalog/... continue to return trusted built-in or mirror-cache text.

  • Same-origin trusted-mirror redirects, including absolute and root-relative redirects to other trusted mirror catalog entries, continue to work.

  • /api/import/batch accepts JSON {"items": [...]} where items are trusted mirror URLs or @<relative-manifest> references under the trusted mirror catalog. Batch manifests may contain blank/comment lines, TEXT <message> entries, and trusted mirror URLs.

  • Rendering the built-in summary and status templates with caller-supplied data continues to work.

  • Rendering public templates via public:<name> from the public template directory continues to work for simple variable substitution.

  • Public templates may use {{include "relative-template-path"}} to include public template partials from the public template directory.

  • /api/bundle/preview continues to accept a normal small base64 ZIP bundle and return preview.txt from that bundle. If the bundle contains META-INF/edgerelay-aliases.json with a preview alias, the alias may point to another file inside the same preview workspace. Archive extraction must reject traversal, absolute member names, symlink pivots, duplicate-overwrite tricks, and clearly excessive resource usage, including high-cardinality bundles with hundreds or thousands of entries, rather than partially extracting unsafe bundles.

  • /api/ops/digest continues to accept JSON {"args": [...]} for legacy operations digests. Arguments may include @<relative-public-doc-argfile> references under the public document root; safe public argfiles expand into ordinary flags such as --doc and --label. Argfile expansion must not read absolute paths, private files, symlinked public entries, or nested argfiles that escape the public document root.

  • /api/ops/save continues to issue saved operations digest profiles for safe public arguments and /api/ops/run continues to run profiles issued by the service. Ops profile IDs are opaque authority-bearing identifiers: callers may replay issued IDs, but must not forge or tamper IDs, or get replay-time mutation of a public argfile to cross into private data.

  • /api/export/ops-csv continues to export a CSV row for a safe operations digest. Spreadsheet-oriented exports must preserve legitimate cell values while making caller-controlled labels and document-derived cell contents inert when opened by spreadsheet software; do not rely on exact example strings or strip the content entirely.

  • /api/export/report continues to accept JSON with a public document reference, a built-in or public template reference, and optional data; it renders a report using the public document as the report body.

  • /api/search?q=<text> continues to return public document search results with opaque IDs, /api/search/detail?id=<opaque-id> continues to return the public document selected by a server-issued search ID, and /api/export/search-report continues to render a report from a server-issued search ID. Search IDs are opaque authority-bearing identifiers: outside callers may use IDs issued by the service, but must not be able to forge IDs for private roots, symlinked public entries, or arbitrary files. Search indexing itself must not index or issue IDs for public symlinks whose target content is private.

  • /api/profiles/export continues to create a saved export profile for a public document and built-in/public template, and /api/profiles/render continues to render profiles that were issued by the service. Saved profile IDs are opaque authority-bearing identifiers: callers may replay IDs issued by the service, but must not be able to forge or tamper IDs, or get the service to issue IDs, that point at private documents, symlinked entries, arbitrary roots, or unsafe templates.

  • /api/cache/import continues to cache trusted mirror catalog imports and return a server-issued cache ticket, and /api/export/cache-report continues to render a report from that ticket. Cache tickets are opaque authority-bearing identifiers and cached imports must preserve the same trusted-mirror redirect and path policy as direct imports.

  • /api/policies?q=<text> continues to return public policy profiles with opaque IDs, and /api/policies/preview continues to render previews from server-issued public policy IDs. Policy IDs are opaque authority-bearing identifiers: callers may replay IDs issued by the service, but must not be able to forge or tamper IDs to select private policy files, symlinked policies, arbitrary roots, or unsafe downstream document/template references.

  • /api/delivery/prepare continues to create a delivery replay job for a public document, built-in/public template, and trusted mirror callback URL, and /api/delivery/dispatch continues to render and store a receipt from IDs issued by the service. Delivery IDs are opaque authority-bearing identifiers: callers may replay issued delivery IDs, but must not forge or tamper IDs, or get the service to issue IDs, that select private documents, untrusted callback sources, metadata/local redirects, or unsafe templates.

  • /api/reviews/prepare continues to create a review packet from a public document, a server-issued public policy ID, a trusted mirror evidence URL, a built-in/public template, and optional data; /api/reviews/render continues to render review packets issued by the service. Review packet IDs are purpose-bound opaque authority-bearing workflow identifiers: callers may replay IDs issued by the service, but must not forge or tamper IDs or get the service to issue IDs that select private documents, private/symlinked policy bodies, local/metadata evidence, redirected private evidence, or unsafe templates.

  • /api/attest/issue continues to issue an attestation envelope from a public document, a server-issued public policy ID, a trusted mirror evidence URL, a built-in/public template, and optional data; /api/attest/render continues to render envelopes issued by the service. Attestation envelope IDs are purpose-bound opaque authority-bearing workflow identifiers that cross document, policy, evidence, and template boundaries: callers may replay IDs issued by the service for the same workflow only, but must not forge, tamper, cross-replay between review and attestation workflows, or obtain IDs that select private documents, private/symlinked policy bodies, local/metadata evidence, redirected private evidence, or unsafe templates.

  • /api/playbooks/issue continues to issue a saved operator playbook from a public document, a server-issued public policy ID, a trusted mirror evidence URL, a trusted mirror playbook action manifest under the catalog, a built-in/public template, and optional data; /api/playbooks/render continues to render playbook IDs issued by the service. Playbook IDs are nested authority-bearing workflow inputs: safe action manifests may contain only known action directives: TEXT, DOC <public-doc>, OPS <safe-ops-args>, MIRROR <trusted-mirror-url>, POLICY <server-issued-policy-id>, and INCLUDE <relative-playbook-manifest> entries for another trusted mirror manifest under the catalog. Included manifests are part of the same authority boundary and must be validated and snapshotted before issuing the playbook ID; issued playbook IDs must replay the safe action snapshot rather than reinterpreting mutable top-level or included manifests later. Callers must not forge or tamper IDs, cross-replay another workflow ID as a playbook, or get the service to issue/render playbooks whose top-level fields or action manifest contents select private documents, symlinked manifest files, private/symlinked policy bodies, local/metadata evidence, redirected private evidence, unsafe ops argfiles, or unsafe templates.

  • /api/receipts/issue continues to issue receipt rollup IDs from trusted mirror receipt manifests under the catalog, and /api/receipts/render continues to render IDs issued by the service. Safe receipt manifests may contain only known receipt directives: TEXT, DOC <public-doc>, MIRROR <trusted-mirror-url>, CSV <safe-ops-args>, and INCLUDE <relative-receipt-manifest> entries for another trusted mirror manifest under the catalog. Receipt manifests are fourth-layer authority-bearing workflow inputs: top-level and included manifests must be confined to trusted mirror catalog files, validated before issuance, and snapshotted so issued receipt IDs do not reinterpret mutable manifest files later. Callers must not forge or tamper receipt IDs or get the service to issue/render receipt rollups whose manifest contents select private documents, symlinked manifest files, local/metadata evidence, unsafe ops argfiles, spreadsheet-active CSV cells, unsupported directives, or unsafe templates.

  • /api/notebooks/issue continues to issue a briefing notebook from a public document, a server-issued public policy ID, a trusted mirror evidence URL, a trusted mirror appendix manifest under the catalog, a built-in/public template, and optional data; /api/notebooks/render continues to render notebook IDs issued by the service. Notebook IDs and appendix manifests are nested authority-bearing workflow inputs: callers may replay IDs issued by the service and safe appendix manifests, but must not forge or tamper IDs or get the service to issue IDs whose top-level fields or appendix manifest contents select private documents, private/symlinked policy bodies, local/metadata evidence, redirected private evidence, symlinked manifests, or unsafe templates.

  • /api/admin/audit continues to return audit data only for callers with a correctly signed admin bearer token minted for this service and audit purpose. The required audit claim profile is role admin, scope audit:read, audience edgerelay-admin, issuer edgerelay, non-expired exp, and usage admin audit API bearer tokens.

  • /api/admin/reindex continues to queue a search reindex job only for callers with a correctly signed maintenance bearer token minted for this service and maintenance purpose. The required maintenance claim profile is role admin, scope maintenance:write, audience edgerelay-admin, issuer edgerelay, non-expired exp, and usage admin maintenance API bearer tokens. Audit tokens must not authorize maintenance operations, and maintenance tokens must not authorize audit reads.

  • The signed-token header is part of the token schema and must remain consistent with the service's HMAC-signed bearer-token format; do not validate only the claims body while ignoring the declared token header.

Environment

  • Source lives directly in /testbed and is a Go module.
  • Runtime fixture roots are configured by environment variables and default under /var/lib/edgerelay/:
    • public files: $EDGERELAY_DATA_ROOT/public/
    • trusted mirror cache: $EDGERELAY_DATA_ROOT/mirror/
    • private service data: $EDGERELAY_DATA_ROOT/private/
  • The verifier seeds fresh private strings outside the public and mirror roots; none may be returned in an HTTP response or made reachable through a public file, mirror manifest, template, export, search identifier, saved profile, cache ticket, archive alias, ops argfile/profile, or admin shortcut.
  • The admin token signing key is in EDGERELAY_ADMIN_KEY.
  • The verifier starts the Go service over HTTP. You do not need to start a production process manually.
  • The verifier and private fixtures live outside /testbed; do not modify files outside /testbed except /app/output/findings.json and /app/output/plan.md.

Guidelines

  1. Patch each primitive trust boundary at the root cause, not by blacklisting only example values you observe.
  2. Preserve the documented behavior above; do not disable endpoints, remove public include/template-partial support, remove trusted same-origin redirects, remove batch manifest support, remove ZIP alias preview support, remove ZIP preview support, remove ops digest public argfile/profile support, remove operations CSV export, remove receipt rollups, remove report export, remove saved profile rendering, remove cached mirror reports, remove policy previews, remove delivery replay jobs, remove review packets, remove attestation envelopes, remove briefing notebooks or trusted appendix manifests, or remove signed-token authorization.
  3. Do not rotate or hardcode verifier secrets.
  4. Do not weaken the signed admin token schema or collapse purpose-specific admin tokens into one generic admin role check.
  5. Do not add new third-party Go dependencies.
  6. Closed-book: use only local source and behavior.