← Model losses

Head-to-head comparison

openai / gpt-6.1-sol / high / high effort preferred over cursor / composer-2.5 / Composer 2.5 default / unknown effort · close 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 / high / high effort answer

## Finding: manifest-directed video serving can bypass certification read authorization

**Conditional, source-grounded unauthorized-read path; high confidence in the routing behavior.**

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

- Certification access checks the assigned reviewer’s email and slot (`1368–1427`).
- Generic file serving explicitly blocks `certification/` artifacts (`4058–4066`).
- However, `/review-pack/{inspection_id}/video` reads `review_manifest.json["video_path"]`, checks only for absolute paths/traversal, then serves the referenced object without certification authorization (`2638–2655`). `_validate_path` does not reject certification paths (`1163–1179`).

### Required preconditions and reproducible trigger

1. A caller passes ordinary media authentication and `_get_inspection` for inspection **I**, but is not its assigned certification reviewer.
2. I has a pack containing a restricted certification artifact, for example `certification/stage1/reviewer.draft.json`.
3. No `.mp4` is selected from the pack’s `video/` directory.
4. The pack’s manifest contains:
   ```json
   {"video_path": "certification/stage1/reviewer.draft.json"}
   ```
5. Request `GET /api/v1/review-pack/I/video`.

The endpoint passes path validation and returns the restricted artifact through `storage.get_response`. Labelling its contents `video/mp4` does not enforce authorization.

**Affected data:** certification assignments, reviewer drafts, or locked packets referenced by the manifest. This establishes an unauthorized-read path, not a demonstrated cross-tenant write.

### Minimal mitigation

Apply certification-object exclusion to **both** manifest resolution branches before storage access (`2650–2666`). For direct storage keys, authorize and classify the resolved object; checking only the raw path’s first component is insufficient.

### Regression coverage

- An ordinary media reader who is not assigned to certification cannot retrieve a draft, manifest, or locked packet through `/video`, using either pack-relative or direct-key manifest references.
- Assert restricted keys are never passed to `storage.get_response`.
- Normal published videos still work, and assigned reviewers retain access through the certification API.

## Limits and discarded hypotheses

The packet does **not** establish who can create or change `review_manifest.json`; therefore, it does not prove an ordinary user or leaked worker token can arrange the prerequisite reference.

No additional concrete worker-token confusion path is established: the supplied validator checks route/method, tenant, terminal status, and immutable resource binding (`worker_job_tokens.py:193–305`). Its dependency integration and downstream enforcement remain outside the packet.

Likewise, `review_boot.py:170,196` loads inspections by ID without an explicit tenant predicate, but no supplied caller establishes attacker-controlled IDs or unauthorized invocation; that alone is not a finding.

**Next useful action:** add the manifest-reference regression test and close the alternate-serving authorization gap. This assessment was performed directly and independently on the supplied snapshot.

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

A more directly supports fixing a demonstrated inconsistency between reviewer-only object policy and alternate object serving. This is a weak, forced preference, not an established material quality difference: both findings remain conditional on reference provenance, and an independent review could favor B's broader tenant-root coverage.

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_51f22097adacce489c296ead3854da420e165a28a10b265e73a8b35ea207278a. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.