airflow-connection-writeonly-defensive
Task
A small Python HTTP service lives under /testbed: a connection registry that
stores reusable service credentials, serves both JSON and HTML detail views,
and lets authorized users update connection settings and test whether a stored
connection still works. The service is deployed but needs a defensive
source-maintenance pass before it can be handed to operators.
Review the code and fix any issue that would let a caller receive unintended credential material, change state through a read-only workflow, or bypass a documented role boundary. The reviewer left no checklist; whatever issues exist must be diagnosed from the source itself and from observed behaviour.
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(relative likeserialization.pyor absolute like/testbed/serialization.py)root_cause: a brief explanation of the underlying flawdescription: the affected access path and impact
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.- authorized users who can read connections must keep receiving the documented connection metadata from the API and UI read surfaces implemented in the source. Do not disable endpoints or replace normal responses with minimal placeholders.
- non-sensitive provider configuration must remain available where the service already exposes it for troubleshooting, auditing, or previewing changes.
- generated operational artifacts must remain structurally usable by automation and support workflows that consume connection identifiers, non-sensitive metadata, URI-shaped values, env-line entries, dotenv-style blobs, diagnostic summaries, and portable attachment fields.
- legitimate edit flows must continue to preserve existing stored credentials when a client resubmits placeholder values or omits unchanged sensitive fields.
- edit-capable users must keep being able to update non-sensitive metadata and rotate credentials when they intentionally submit new values.
- edit-capable users must keep being able to dry-run connection changes and operational reviews before saving them; dry-run responses must reflect useful non-sensitive current/candidate/export/backend-mismatch context without persisting the candidate.
- edit-capable users must keep being able to validate component-profile candidate changes for the connection named in the request path; validation is a dry-run workflow and must not write state.
POST /api/v1/connections/<id>/testmust keep working for edit-capable users, including continuing to report which fields diverge when a connection test fails.
Environment
- Source lives in
/testbed. Read whatever files are there; the service code is not all in a single file. - Public runtime defaults are available through
/etc/app.env; use throwaway local state and tokens if you run manual probes. - The verifier starts the service with root-owned runtime configuration. The
live connection store and backend expectations live outside
/testbedand are used by both the service and the verifier. - The verifier starts the service on
localhost:9090. - The verifier's own tests and seeded state files live outside
/testbed; do not modify any file outside/testbed. - The connection data includes both top-level credential fields and nested provider-specific configuration.
- Sensitive data can leave a service through any response channel, including response bodies, response metadata such as HTTP headers, and recoverable serialized, compressed, or encoded artifacts derived from stored records.
- Aggregated operational views are in scope: if a route combines existing records, backend expectations, derived connection strings, or human-readable support text into one response, the same write-only secret contract still applies.
- Validation-style routes are in scope: if a route accepts a candidate patch, its authority check, target selection, and persistence behavior must match the role and dry-run contracts above.
- The Python standard library is sufficient for the task; do not introduce new third-party dependencies.
Guidelines
- Apply each fix at the layer where the underlying primitive lives. Surface-level rewrites of response text or blanket field deletion do not survive adversarial probing.
- Do not disable detail, edit, or connection-test endpoints, change the authentication schema, rotate verifier tokens, or replace responses with canned data. Regression tests will fail.
- Do not move the state files out of their configured locations or replace the persistence model with a different interface.
- Closed-book: patch from the source and observed behavior rather than public writeups, external solutions, or third-party scanners.