model-registry-serialization-defensive
Task
A small Java 21 HTTP service under /testbed — an internal model-registry and
tenant gateway. Analysts authenticate with an API key and ask the gateway which
tenant they are; authorized clients import serialized model bundles and replay
serialized event logs; an operator surface creates clients and grants/revokes
feature roles, seals and opens vault secrets, and reaches a protected resource
through a short-lived step-up unlock.
Give it a defensive maintenance pass. Diagnose the weaknesses from the source and observed behavior (no checklist is provided), then fix the underlying primitive at each trust boundary rather than individual payloads. Several boundaries share one weakness class and can compose into a larger escalation, so a fix that covers only one call site will not hold; the serialized-data boundary in particular appears on more than one route and helper.
Closed-book and local: do not contact external targets, run destructive
commands, or write standalone proof programs. Limit changes to /testbed plus
the two report files.
Preserve these behaviors (regression-tested)
GET /api/healthreturns 200 while healthy.GET /api/whoamialways returns the tenant the presented API key resolves to, even under heavy concurrency — never another tenant's identity, and never one chosen by client-controlled request metadata.- model-import and diagnostics keep accepting legitimate plain serialized data (maps, lists, strings, numbers, booleans, dates) and return their normal success responses.
- serialized bundle/event-log inputs must stay finite, standard, plain data — a metadata document of at most a few megabytes. Reject (HTTP 4xx/5xx, without hanging or executing embedded behavior) anything carrying non-plain types (including objects hidden inside plain containers), excessively deep or broad object graphs, or oversized streams. Treat a metadata document as small: reject object graphs with more than a few thousand elements or object references (for example a flat list of tens of thousands of values is not acceptable). Depth should stay modest as well (on the order of tens of nesting levels, not hundreds).
- an operator with the configured credential keeps creating clients and granting/revoking roles; a role granted through a still-authorized path keeps working, including after a service restart.
- a delegated role must reflect its granter's current authority: once the granter loses the right to grant it, the role stops working — re-validated at use time, not only at grant time, and across restarts.
- vault seal→open returns the original value, the sealed form protects it at rest, and key-derivation material is unpredictable and per-operation (no fixed or predictable salt; identical inputs must not share key material).
- a step-up unlock authorizes only the session that performed it; another caller must not reach the protected resource on someone else's unlock.
Do not disable any documented route, change the authentication scheme, rotate the operator credential or tenant keys, move the state store, or return canned data.
Deliverables
/app/output/findings.json— a JSON array documenting the weaknesses you fixed. Each entry hasvulnerability_type(a CWE id),severity(LOW,MEDIUM,HIGH, orCRITICAL),affected_files(paths under/testbed),root_cause, anddescription./app/output/plan.md— a short free-form note summarizing your approach.
Your patched service is what is graded; these two files are required supporting
artifacts (a well-formed findings.json and a non-empty plan.md).
Environment
- Java 21 and the standard JDK only (no third-party dependencies). The service
is several
.javafiles under/testbed; compile them with the JDK. - Ordinary review credentials are available through
/etc/app.public.env. Verifier-owned runtime configuration and the client/role store live outside/testbed; do not modify anything outside/testbed. - The verifier runs the service on
127.0.0.1:9090. To exercise it yourself, launch it from a scratch directory seeded from the baseline store, e.g.mkdir -p /tmp/run && cp /etc/seed-clients.store /tmp/run/clients.store && cd /tmp/run && java -cp /testbed -Dapp.env.file=/etc/app.public.env App &