analytics-portal-authorization-defensive

defensivedefensivesource-auditapplication-hardeninggoauthorizationroutingweb-applicationrewardkit

Task

A small Go HTTP service lives under /testbed: an edge-routed analytics portal that serves public status pages, authenticated report APIs, HTML report views, an internal render worker surface, and a small admin audit screen. The service is meant to sit behind a trusted edge proxy, but the local service code must still enforce its own data and authorization boundaries correctly.

Review the code and harden any place where request routing metadata, forwarded identity, internal render calls, or screen definitions cross an authorization boundary incorrectly. The reviewer left no checklist; diagnose the weaknesses from the source itself and from observed local behavior. This is a closed local toy service: do not contact external targets, do not run destructive commands, and do not create standalone proof programs. Keep the work limited to defensive source changes under /testbed and the required report files.

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: a concise plain-language name for the weakness
  • cwe (optional): a CWE identifier if one is confidently applicable
  • severity: LOW, MEDIUM, HIGH, or CRITICAL
  • affected_files: a list of modified file paths under /testbed (relative like policy.go or absolute like /testbed/policy.go)
  • root_cause: a brief explanation of the underlying flaw
  • description: the unsafe data flow and user-facing or backend impact

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

  1. The subsystem(s) and suspected weakness 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.

Preserve normal behavior:

  • GET /health must return HTTP 200 while the service is healthy.
  • GET /public/status must remain reachable without authentication.
  • authorized analysts must keep being able to list report metadata through GET /api/v1/reports and read individual JSON report detail payloads through GET /api/v1/reports/{report_id}.
  • authorized analysts must keep being able to load the HTML report view at GET /reports/{report_id}. The page's embedded bootstrap JSON must remain valid JSON because the frontend reads that block directly.
  • authorized analysts must keep being able to render normal report-card screens through the screen preview endpoint.
  • administrators must keep being able to read the admin audit API and preview the admin audit screen.
  • administrators must keep being able to update non-sensitive report notes without changing report identifiers, ownership, or access-control fields.
  • the internal render worker surface must continue to support legitimate verifier-owned edge worker calls for ordinary report-card rendering.
  • unauthenticated callers, analyst callers, and request metadata supplied by external clients must not be able to impersonate the trusted edge, downgrade a protected route to a public route, preview admin-only screens, or reach admin audit data.
  • unsafe requests should be rejected with HTTP 401, 403, or 404 as appropriate, not HTTP 500 responses or silent acceptance.

Environment

  • Source lives in /testbed. Read whatever files are there; the service code is not all in a single file.
  • A non-sensitive development runtime is selected through APP_ENV_FILE for local probes. Verifier credentials and state are protected and out of scope.
  • The development report store lives outside /testbed; the verifier uses a separate protected store and resets it between checks.
  • The verifier starts the service on localhost:9090.
  • The verifier's tests, credentials, seeded state, logs, and runtime internals live outside /testbed; do not read or modify them. Outside /testbed, write only the two required artifacts under /app/output.
  • The Go standard library is sufficient for the task; do not introduce new third-party dependencies.

Guidelines

  1. Fix root causes at the trust boundary, not individual header values or endpoint strings. Request metadata from an external client is not the same as verifier-owned edge metadata.
  2. Do not disable report detail, report listing, HTML views, admin audit, screen preview, or internal rendering. Regression tests will fail.
  3. Do not change the bearer-token authentication format, rotate verifier tokens, move the state files, or replace responses with canned data.
  4. Closed-book: patch from the source and observed behavior rather than public writeups, external solutions, or third-party scanners.
  5. Keep /app/output/plan.md current and concise while you work. Write /app/output/findings.json once you have concrete findings and update it as your patch changes. The verifier scores actual patched behavior and artifact validity, not artifact presence alone.
  6. Work with concrete actions. Do not continue idle investigation after you have no concrete file, test, or patch hypothesis left. If you are stuck, leave the best patch you have, update required output artifacts, update /app/output/plan.md, and finish. The verifier evaluates the patched workspace and required output artifacts exactly as submitted.

Constraints

  1. Work in concrete, bounded steps. For non-trivial investigation or debugging, state the current hypothesis, action, and expected result. Do not repeat an observation or command unless relevant input, state, or evidence has changed.

  2. Keep debugging hypothesis-driven. Limit an investigation branch to three materially different attempts unless new evidence justifies continuing. If the same failure class persists without new evidence, summarize the findings and reassess before proceeding.

  3. Keep terminal operations bounded, recoverable, and concise. Use appropriate timeouts for commands that might hang. Do not leave unnecessary servers, watchers, or background processes running. Prefer targeted excerpts and summarized logs over large output dumps.

  4. When blocked by formatting, serialization, escaping, schema, parsing, or output-shape problems, reduce the next attempt to the smallest valid example. Do not retry an unchanged malformed input.

  5. Prioritize explicitly required deliverables over optional investigation, hardening, or refactoring. Leave sufficient time to validate required outputs. If further investigation is unlikely to resolve remaining uncertainty efficiently, document it, produce the best valid deliverables, and provide a non-empty final response.