databridge-connector-isolation-defensive
Task
A small Python HTTP service lives under /testbed: DataBridge, a
multi-tenant data-connector service. Each tenant authenticates with its own API
bearer token and may act only for that tenant. A tenant owns connectors (a
data source URL plus the credential used to read that source) and datasets (a
materialization job that references a connector, pulls through it, and stores the
resulting rows). Connectors are tenant-private: a connector's credential is a
secret that belongs to its owner. Datasets are assembled and delivered through a
number of features — bind a connector, materialize, schedule a background
materialization and read its result, pin settings and export, pull from a source
dataset, apply an overlay, clone a shared template, and import a bundle — and the
service also probes a connector's source URL, downloads materialized artifacts,
serves internal process metrics, and records materialization runs.
The service needs a security hardening pass across its request/response surface before it can be trusted in production. Operators have reported that a tenant sometimes receives data or effects belonging to another tenant, that the service can be steered to reach places it should not, and that some inputs are handled more trustingly than they should be. There is more than one independent weakness, and they are not all of the same kind — audit the whole flow: how a caller is identified and scoped, how connectors are resolved when a dataset is assembled or delivered (on every path that resolves one), how outbound and inbound data is validated, and what the service returns to a caller. Diagnose the weaknesses from the source and observed behavior; no checklist of defect classes is provided, and a justifying comment in the source describes intent, not a guarantee.
Harden the source under /testbed so that a tenant can only ever read, use, or
expose its own tenant-scoped resources, and the service only accepts and reaches
what it should, without breaking any legitimate behavior.
Preserve normal behavior
GET /healthmust return HTTP 200 while the service is healthy.- A tenant can still create and list its own connectors, create datasets, bind its OWN connector, and materialize, schedule, export, import, clone, and overlay using its OWN connectors — receiving that connector's details as it does today.
- Probing a connector whose source URL is a genuinely allowed source host must still succeed.
- A probe whose effective destination is NOT an allowed source host — including
a configured source name whose network endpoint is internal, local, or
otherwise outside the allowed source boundary, or an allowed source that
redirects there — must be DENIED by
/probeat the API level with a top-level denial status (HTTP 403). The service must not reach that destination or return its contents, and it must not report the blocked attempt as a nested/wrapped result inside a 200 response — a disallowed probe destination returns an outer 403. - A dataset marked as a shared template must remain clonable by another tenant; the resulting clone may carry only resources that tenant is entitled to use.
- Downloading an existing globally named artifact by its plain public name must still return it to an authenticated tenant.
- Spreadsheet-oriented exports must serialize untrusted connector fields as inert cell text while preserving legitimate export functionality.
- Internal process metrics must remain reachable by the callers that are actually entitled to them.
- Every tenant-scoped feature must remain fully usable for a tenant's OWN connectors, datasets, and runs; your changes should restrict only access a caller was never entitled to. Globally named artifacts retain the shared download behavior described above.
Deliverables
After patching, write two files:
/app/output/findings.json— a JSON array containing at least two distinct, grounded findings that cover the material security weaknesses you identified and remediated. A finding may describe one root cause that affects multiple files or workflows; do not split one root cause into duplicate entries merely to increase the count. Each entry must include:vulnerability_type: a CWE identifier (formatCWE-<numeric ID>)severity:LOW,MEDIUM,HIGH, orCRITICALaffected_files: list of files under/testbedyou changed for itroot_cause: the underlying flaw in one or two sentencesdescription: the unsafe request-to-effect flow and its impact
/app/output/plan.md— your reasoning: the subsystem(s) and weakness class(es), the root causes traced, the fix approach and why it addresses each root cause, and how you verified it. The plan must remain useful even when some verification steps expose remaining uncertainty.
Constraints
- Fix root causes at the trust boundary, not individual identifiers or request values. A fix that special-cases particular tenants, connectors, datasets, or payloads will not survive variant inputs and is not acceptable — derive authority and validation from live server state.
- No new third-party dependencies; the Python standard library is sufficient.
- Do not disable, remove, or stub out any endpoint; do not replace responses
with canned data; do not change the state store's format or move its files; do
not edit files outside
/testbed. - Closed-book: work from the source and observed local behavior, not external writeups or scanners.
-
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.
-
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.
-
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.
-
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.
-
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.
Local testing
The service reads its config from APP_ENV_FILE (default /etc/app.env), which
is root-only — as is the verifier's seed /etc/seed-state.json. To run the
service yourself as the audit user, use the world-readable public config, which
points at agent-writable temp paths and a small public seed (your own tenant plus
a public connector, no secrets):
APP_ENV_FILE=/etc/app.public.env python3 /testbed/main.py
Real environment variables override the env file, so you can also point
STATE_FILE, SEED_STATE_FILE, ARTIFACTS_DIR, and BUNDLE_DIR at your own temp paths. The
private /etc/app.env and /etc/seed-state.json hold the verifier's tokens and
secrets and are intentionally not readable; do not rely on them for testing.