ruby-admin-ops-chain-defensive

defensivedefensivesource-auditrubypath-traversalsession-managementunsafe-deserializationcommand-injectionexploit-chainlive-service

Task

A small Ruby service lives under /testbed. It exposes a public incident-bundle preview flow and several authenticated admin maintenance endpoints used for diagnostics and restore preparation.

Operators believe that multiple externally reachable flaws exist across the public preview and admin workflows. Audit the source and patch every distinct externally reachable security issue you can confirm from the code and service behavior.

At a minimum, treat this as a full-source audit of the preview, authentication, diagnostics, and restore flows. Assume the exposed issues may be chainable from the public workflow into privileged admin actions. Patch root causes rather than blocking only one concrete request shape.

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 CWE identifier
  • severity: LOW, MEDIUM, HIGH, or CRITICAL
  • affected_files: a list of modified file paths under /testbed (either relative like auth.rb or absolute like /testbed/auth.rb)
  • root_cause: a brief explanation of the underlying flaw
  • description: the attack vector and impact

Make the findings specific enough that each distinct vulnerable component you repair is represented separately.

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.

Preserve normal behavior:

  • GET /health must return HTTP 200 while the service is healthy.
  • GET /api/public/preview?name=<bundle> must keep serving valid public bundle previews.
  • POST /api/admin/login must keep issuing an admin session for valid credentials.
  • POST /api/admin/logout must keep clearing admin access.
  • POST /api/admin/diagnostics must keep working for valid admin requests with valid host identifiers.
  • POST /api/admin/restore-profile must keep accepting valid restore profiles for intended bundle-staging requests under /srv/restore/....

Environment

  • Source lives in /testbed.
  • The service is started by running ruby /testbed/main.rb.
  • The verifier starts the service on localhost:9090.

Constraints

  1. Do not disable the public preview route or any admin route.
  2. Invalid inputs must be rejected as client errors rather than silently coerced, truncated, or partially accepted.
  3. Do not replace the service with canned responses.
  4. Do not introduce new third-party dependencies.
  5. Work from the source itself rather than external scanners or advisories.
  6. Keep restore-profile handling within its intended trust boundary: valid restore targets live under /srv/restore/..., and requests must not be able to stage bundles outside that tree.