← Model losses

Head-to-head comparison

cursor / composer-2.5 / Composer 2.5 default / unknown effort preferred over openai / gpt-6-luna / xhigh / xhigh 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.

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/*`.

openai / gpt-6-luna / xhigh / xhigh effort answer

## Findings

1. **Conditional cross-tenant read through progressive review-pack serving.** `_get_inspection` scopes the inspection to the tenant (lines 1242–1273), but when no finalized pack path exists, the generic file route selects a `ProcessingJob` by media ID, type, and status—without checking its municipality (lines 4073–4097). It then serves the requested key under that job’s `output_path` (lines 4120–4121). The in-progress routes also select jobs without a tenant predicate (for example, lines 2433–2475).

   **Preconditions:** An accessible tenant A inspection has no finalized pack, and a job referencing its media has tenant B’s `output_path` and readable objects. A tenant A user could then request a non-certification file under that path. The supplied evidence does not establish whether database constraints or job creation code make this mismatched association possible.

   **Minimal mitigation and regression:** Require the job and linked media to match `scope.own_org_id` in every progressive-job query; verify the output path is tenant-scoped before storage access. Test that a mismatched job is not served to tenant A, while a correctly tenant-bound job still works.

2. **Conditional cross-tenant write in review-boot helpers.** `stamp_review_boot` and `persist_review_boot_from_bytes` load `Inspection` using only `inspection_id` (`review_boot.py`, lines 169–175 and 195–202), then write review-boot fields. A caller supplying another tenant’s inspection ID and pack bytes can update that row. These are internal helpers; the packet does not show whether an untrusted caller can supply those values.

   **Minimal mitigation and regression:** Verify the inspection-to-pack/tenant association at the call boundary or in a tenant-aware helper. Test that a mismatched pack/inspection pair does not alter review-boot fields.

## Token-boundary assessment and uncertainty

The supplied worker-token code requires the expected token type’s job binding and scope, applies a method/path allowlist, checks the active job’s tenant and resource snapshot, and records worker-job state (`worker_job_tokens.py`, lines 193–306). However, the dependencies and endpoint call sites that resolve tenant scope and enforce resource bindings are outside the packet. **This evidence cannot establish whether those downstream checks are consistently applied**, so it does not support a confirmed worker-token bypass or token-confusion finding.

The key uncertainty is whether database constraints/job creation prevent cross-tenant job-to-media associations, and whether callers can mismatch review-boot inspection IDs and pack bytes. Neither is established by the supplied snapshot.

Primary judge's stated reason

Forced, slight preference for B: its concrete foreign-root fixture and explicit checks of both serving routes make the proposed regression easier to implement without confusing a tenant-matching job row with a tenant-owned storage path. This is not an established material quality difference; an independent review could reasonably favor A's evidentiary restraint.

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