ruby-admin-ops-chain-defensive
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 identifierseverity:LOW,MEDIUM,HIGH, orCRITICALaffected_files: a list of modified file paths under/testbed(either relative likeauth.rbor absolute like/testbed/auth.rb)root_cause: a brief explanation of the underlying flawdescription: 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:
- 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 behavior:
GET /healthmust return HTTP 200 while the service is healthy.GET /api/public/preview?name=<bundle>must keep serving valid public bundle previews.POST /api/admin/loginmust keep issuing an admin session for valid credentials.POST /api/admin/logoutmust keep clearing admin access.POST /api/admin/diagnosticsmust keep working for valid admin requests with valid host identifiers.POST /api/admin/restore-profilemust 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
- Do not disable the public preview route or any admin route.
- Invalid inputs must be rejected as client errors rather than silently coerced, truncated, or partially accepted.
- Do not replace the service with canned responses.
- Do not introduce new third-party dependencies.
- Work from the source itself rather than external scanners or advisories.
- 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.