← Model losses

Head-to-head comparison

openai / gpt-6.1-sol / low / low effort preferred over cursor / composer-2.5 / Composer 2.5 default / unknown effort · clear win.

Primary judge: Sol 6.1, requested Low. Effective provider effort and internal attempts were not verified. A close win is still a scored preference; it does not establish a material defect.

Reviewed public evidence

Task goal

Perform a source-grounded authorization and tenant-isolation review of review-pack access and worker-job token boundaries. Identify only a concrete cross-tenant, unauthorized-read/write, or token-confusion path supported by the code; give required preconditions, affected data/action, minimal mitigation, and regression coverage. Do not infer exploitability from names alone.

openai / gpt-6.1-sol / low / low effort answer

## Conditional finding: video resolution bypasses certification read authorization

**The supplied code establishes a read-bypass path, conditional on control of `review_manifest.json`; it does not establish how an attacker obtains that control.** Confidence: high in the bypass, uncertain in attacker reachability. Assessment was direct and independent.

### Evidence and reproducible trigger

In `[REDACTED: private project name]/backend/app/routers/review_pack.py`:

- Certification access requires the assigned reviewer’s home organization, slot, and email (1368–1427).
- Generic file serving explicitly blocks the `certification` directory (4058–4066).
- However, `GET /review-pack/{inspection_id}/video` reads `video_path` from the manifest and serves the corresponding pack-relative object without that private-path check (2638–2655). `_validate_path` only rejects absolute paths and `..` components (1163–1179).

**Required preconditions:**
1. A local certification pack contains another reviewer’s draft or locked packet.
2. The requester passes ordinary media authentication and inspection tenant checks, but is not the assigned reviewer.
3. Someone can author or alter that pack’s manifest.
4. No `.mp4` under `video/` takes precedence.

Set:
```json
{"video_path":"certification/stage1/<slot>.draft.json"}
```

Then request:
```http
GET /api/v1/review-pack/<inspection_id>/video
```

The route serves the draft bytes labeled `video/mp4`, bypassing reviewer assignment checks. The same path applies to an existing locked packet. This is an **unauthorized same-tenant read**, not an established cross-tenant exploit.

### Minimal mitigation and regression coverage

Reject private certification paths before **either** manifest-directed storage lookup in the video route. Apply the check to the resolved pack-relative destination, including direct-key resolution.

Regression tests:
- An unassigned, otherwise authorized media reader cannot retrieve drafts, locks, or manifests through `/video`.
- Mixed-case `Certification` and direct storage-key variants are also denied.
- Legitimate pack-relative and tenant-confined video references still work.

### Limits and discarded hypotheses

- The packet does **not** demonstrate that a worker-job bearer can write this manifest. Its allowlist excludes review-pack routes (`worker_job_tokens.py`:78–93, 207–216).
- Cross-tenant media/job associations and unscoped boot writes require caller, model, or RLS evidence outside this packet; they are not demonstrated exploits.
- JWT decoding and downstream enforcement dependencies are outside the packet, so no token-confusion finding is established.

**Next useful action:** add the video-path privacy regression test, then separately verify who can author manifests to determine practical exposure.

cursor / composer-2.5 / Composer 2.5 default / unknown effort answer

## Evidence packet: review-pack access and worker-job token boundaries

### 1. Conclusion (primary finding)

**Finding:** Progressive / in-progress review-pack reads use `ProcessingJob.output_path` as the storage root **without** tying that path to the request tenant (or to the inspection’s municipality), unlike manifest `video_path` handling which uses `_confine_to_pack_tenant`.

**Confidence:** High that the authorization gap exists in the admitted snapshot; medium that it becomes **cross-tenant** in production (depends on who can set `output_path`).

**Locations (packet):**

- `serve_in_progress_file`: resolves `pack_key` from `job.output_path`, then `file_key = f"{job.output_path}/{file_path}"` and serves via storage (approx. lines 2445–2475 in `review_pack.py`).
- `serve_review_pack_file`: when `inspection.review_pack_path` is empty, selects a `ProcessingJob` by `media_file_id` only (no `ProcessingJob.municipality_id` / path check), sets `pack_key = job.output_path`, then serves `f"{pack_key}/{file_path}"` (approx. 4073–4121, 4094–4096).
- Same pattern in `get_in_progress_fps_count` (`fps_prefix = f"{job.output_path}/fps"`, approx. 2378).
- Contrast: `serve_review_pack_video` confines manifest `video_path` with `_confine_to_pack_tenant(video_path_str, pack_key)` before `storage.get_response` (approx. 2656–2666).
- `_confine_to_pack_tenant` itself only checks shared **first two** path segments with `pack_key` (approx. 1194–1208); it is **not** applied to `job.output_path`.

**Preconditions:**

1. Caller passes normal review-pack auth: `get_media_user` + `get_media_tenant_scope` and `_get_inspection(inspection_id, …, scope)` (tenant-scoped inspection).
2. Pack is read through the in-progress path (`review_pack_path` empty or in-progress route), and a `ProcessingJob` row is selected for the inspection’s video `media_file_id`.
3. That job’s `output_path` points at storage under another tenant’s prefix (e.g. `review-packs/{other_municipality_id}/…` or another org’s `media/{slug}/…`). The packet does not show how `output_path` is written; any path that can set it (worker, job completion, ops/DB) satisfies this.

**Affected data / action:**

- **Unauthorized read** of arbitrary objects under `{output_path}/{file_path}` for allowed relative paths (in-progress: `fps/`, `modules/observations/`; generic catch-all route allows broader `file_path` once `pack_key` is set), including pack JSON, frames, and observation module assets—potentially **another municipality’s** review-pack tree if `output_path` is cross-tenant.

**Minimal mitigation:**

- Before using `job.output_path` as `pack_key`, enforce tenant ownership, e.g.:
  - `ProcessingJob.municipality_id == scope.own_org_id` (and/or match inspection’s municipality), **and**
  - `output_path` matches an expected namespace for that municipality (extend `_confine_to_pack_tenant` or a dedicated `review-packs/{municipality_id}/` / org storage root check), **or**
  - reject if `output_path` does not share the tenant root derived from `scope.own_org_id` / org storage config.
- Mirror the manifest `video_path` pattern (2656–2660) for all job-derived pack roots.

**Regression coverage:**

- Fixture: tenant A inspection + media + active `review_pack` job whose `output_path` is tenant B’s pack prefix; object exists only under B.
- Assert `GET /review-pack/{inspection_id}/in-progress/fps/...` and `GET /review-pack/{inspection_id}/{file}` (with empty `review_pack_path`) return **403 or 404**, not B’s bytes.
- Control: same job with `output_path` under A’s prefix succeeds.
- Optional: assert `ProcessingJob.municipality_id` mismatch fails even if path string looks valid.

---

### 2. Alternatives / discarded hypotheses

| Hypothesis | Verdict in packet |
|------------|-------------------|
| Worker `worker_job` JWT can call `/review-pack/*` | **Rejected:** `validate_worker_job_request` allowlist has no `/review-pack` routes (worker_job_tokens.py 78–93); non-matching path → 403 before DB job binding. |
| Manifest `video_path` cross-tenant via `serve_review_pack_video` | **Mitigated in packet:** `_confine_to_pack_tenant` before direct `video_path` storage read (2656–2660). |
| `review_boot` cross-tenant write | **Uncertain:** `stamp_review_boot` / `persist_review_boot_from_bytes` load `Inspection` by `inspection_id` only (review_boot.py 170–171, 196–197); no `municipality_id` check in this file—exploitability depends on callers (not in packet). |
| Worker token cross-inspection IDOR on `GET /api/v1/inspections/{id}` | **Uncertain:** Token pins `worker_job_inspection_id` on `request.state` (worker_job_tokens.py 303–304); whether the inspections router enforces `enforce_worker_job_resource(..., inspection_id=…)` is **outside** the packet (`app/routers` not admitted). Same-tenant unauthorized read possible if missing; not proven here. |
| Legacy pre-D8 `access` tokens in `processing_config["api_token"]` | **Documented risk** (worker_job_tokens.py 44–47): full user impersonation until expiry—not cross-tenant by itself; token-type confusion with new `worker_job` fence. |

---

### 3. Missing evidence / consequences

- **`deps._resolve_jwt_user`**, inspections/observations/profile-bank routers: whether `enforce_worker_job_resource` / `enforce_worker_job_municipality` cover every allowlisted worker route (consequence: same-tenant IDOR or org-id confusion on `GET .../organizations/{id}/profile-bank/stats`).
- **Job claim / complete** (`worker_queue.py`): how `output_path` and `_worker_job_resource_binding_v1` are set (consequence: how easily precondition #3 is met).
- **RLS / `get_media_tenant_scope`**: whether DB alone prevents cross-tenant `ProcessingJob` rows on media (consequence: whether path confinement is defense-in-depth vs primary control).

---

### 4. Next useful action

Add tenant + storage-root validation on every use of `ProcessingJob.output_path` in `review_pack.py` (in-progress file, fps-count, progressive `serve_review_pack_file` fallback), aligned with `_confine_to_pack_tenant` / `municipality_id`, and land the regression tests above.

**Worker-job fence (in packet):** Path allowlist, job/tenant/resource snapshot checks, and `request.state` pinning (worker_job_tokens.py 181–305) are coherent for admitted worker routes; the clearest **review-pack + tenant** gap in this snapshot is **unconfined `job.output_path`**, not worker JWT access to `/review-pack/*`.

Primary judge's stated reason

B is preferable because its regression trigger targets a specifically evidenced confidentiality policy bypass rather than treating an unchecked storage root as an established authorization gap. This is a clear comparative grounding advantage, not proof of deployed exploitability; manifest-authoring authority remains unresolved.

This reason is the judge's assessment. No independent factual-defect finding is asserted by this record.

Battle wave: 527c366a-0a3f-41a8-8ff5-f886f8eadb49. Pair: brp1_63463fce7a2b9c0093417fcbf4fd8e9c4af65110d3cc06dcf47dd6be3794de07. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.