← Model losses

Head-to-head comparison

xai / grok-4.7-efficient / high / high effort preferred over xai / grok-4.7-efficient / low / low 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.

xai / grok-4.7-efficient / high / high effort answer

The in-progress and progressive review-pack readers serve storage under `ProcessingJob.output_path` with no tenant or pack binding. That is an unauthorized read, including cross-tenant, when that column names another pack. The worker-token inspection fence has a separate fail-open binding bug, but this packet does not show a completed data read from it.

## Primary path: unconfined job `output_path`

**Conclusion.** A caller who passes `_get_inspection` for inspection I can read objects under whatever prefix is stored on a linked job, including another municipality’s pack. Authorization is on the inspection row. The storage key is not checked against `scope.own_org_id`, the inspection id, or the pack tree. Confidence is high that the read is unbounded; the writer of `output_path` is outside this packet.

Evidence:

- `serve_review_pack_file` uses `job.output_path` as `pack_key` when `inspection.review_pack_path` is empty, then serves `{pack_key}/{file_path}` (`review_pack.py` 4070–4097, 4121, 4168–4361). `file_path` is only traversal- and `certification/`-checked (4058–4066). That includes `inspection.json` and `track_data.json`, returned in the response body (4174–4239, 4260–4347).
- `serve_in_progress_file` does the same for `fps/` and `modules/observations/`, and falls through to `output_path` even after `review_pack_path` is set if that file is missing (2424–2431, 2445–2475). `get_in_progress_fps_count` lists `{output_path}/fps` the same way (2338–2380).
- Job lookup is `ProcessingJob.media_file_id == media_id` plus status and a non-empty `output_path`. There is no `municipality_id` predicate (2446–2466, 4084–4096). The media lookup is `inspection_id` + `media_type == "video"` only — unlike `get_media_info`, which also requires `MediaFile.municipality_id == scope.own_org_id` (2435–2439 vs 1926–1931).
- The same file already treats worker-authored storage keys as untrusted for video: manifest `video_path` must pass `_confine_to_pack_tenant` or it is not served (2656–2666, helper 1194–1208). These three readers never call that helper.

**Preconditions.**

1. Caller is a normal user who can read inspection I (`get_media_user`, `get_media_tenant_scope`, `_get_inspection`).
2. A non-deleted video `MediaFile` is linked to I, and a `review_pack` or `embedded_import` job for that media has a non-empty `output_path` in `pending`/`running`, or `completed` if no active job matches.
3. `output_path` is a storage prefix the app backend can read that is not I’s pack — for example `review-packs/{other_municipality_id}/...`. Who writes that column is not in this packet. Comments describe it as the in-progress job output (2325–2328, 4069–4072).
4. Full-pack read via `serve_review_pack_file` also needs `inspection.review_pack_path` empty. Frame and observation-image reads via `serve_in_progress_file` do not.

**Affected action.** Read of whatever objects exist under that prefix and match the route’s path rules: full pack JSON and track data when the pack is not finalized; fps frames and `modules/observations/` images either way, including nearest-frame fallback (2477–2488, 4363–4374). Storage responses may be presigned redirects (`get_response`).

**Minimal mitigation.** Do not use `output_path` as a storage root until it is confined to a server-derived prefix for this municipality and this inspection (stricter than a two-segment prefix). Reject or ignore a completed-job fallback once `review_pack_path` is set. Add `MediaFile.municipality_id == scope.own_org_id` and a job municipality check on these lookups. On mismatch, 404 and do not call storage.

**Regression.** Tenant A inspection with empty `review_pack_path`, linked video media, job `output_path` set to tenant B’s pack prefix. `GET /review-pack/{A}/inspection.json`, `GET .../track_data.json`, `GET .../in-progress/fps/frame_000001.jpg`, and `GET .../in-progress/fps-count` must 404/403 and must not read B’s keys. Repeat the in-progress GETs after `review_pack_path` is set and the requested frame is absent from A’s pack.

## Second concrete fence bug (no completed read in this packet)

`validate_worker_job_request` pins `worker_job_inspection_id` from `MediaFile.inspection_id` (worker_job_tokens.py 232, 267, 285, 303). The `Inspection` outer join requires `Inspection.municipality_id == ProcessingJob.municipality_id` and `deleted_at IS NULL` (237–244), but a failed join does not clear or reject that media foreign key. `pipe_id` becomes null; the foreign inspection id is still bound if the claim snapshot stored the same id (289–305). `enforce_worker_job_resource` then allows a supplied inspection id that string-matches that state and does not re-check municipality (342–364).

**Preconditions.** Job and media are in municipality A and non-terminal; `MediaFile.inspection_id` points at an inspection that fails the tenant join; claim-time `_worker_job_resource_binding_v1` recorded that same inspection id, with `pipe_id` null and matching `media_file_id` / `video_hash`. The claim writer is outside this packet. Allowlisted consumers (`GET /api/v1/inspections/\d+`, profile-bank routes) are also outside it, so this evidence shows a wrong authorization binding, not a finished cross-tenant query.

**Mitigation.** Select `Inspection.id` from the tenant-scoped join. If `MediaFile.inspection_id` is set and that join misses, reject. Inside `validate_worker_job_request`, compare path inspection and organization ids to the binding; do not rely on opt-in helpers. Review-pack routes never call those helpers, and they are not on `_ALLOWED_ROUTES` (78–93), so they are not this bug’s consumers unless `deps.py` skips the path fence.

**Regression.** Media inspection id in municipality B, snapshot equal to that live binding, `pipe_id` null. Validation must 401/403 and must not set `worker_job_inspection_id` to B’s id.

## Discarded

- **`_confine_to_pack_tenant` as a cross-municipality bypass.** It requires a shared two-segment prefix plus a trailing slash (1194–1208), so `review-packs/1/` does not match `review-packs/10/` if the commented layout is real. It does allow any other key under that tenant root, so manifest `video_path` is an unauthorized same-tenant read of another inspection’s object (2638–2666) when the pack has no local mp4 and the relative key misses. That is a real gap in the helper the video route already uses; it is not, by itself, a proven cross-municipality read. Layout of `review_pack_path` is only a comment.
- **Worker allowlist vs path ids.** `GET /api/v1/inspections/\d+` and `GET /api/v1/organizations/\d+/profile-bank/stats` match any id (81–92). The validator never compares those segments to `job_id` / `muni_id` (207–216, 271–274). Whether those routers call `enforce_worker_job_municipality` / `enforce_worker_job_resource` is outside the packet, so this is an incomplete fence, not a demonstrated data leak.
- **`review_boot.py` writes.** `stamp_review_boot` and `persist_review_boot_from_bytes` load `Inspection` by primary key and write `review_boot_json` with no municipality predicate (155–176, 185–202). No caller in this packet passes `inspection_id`. Not a completed cross-tenant write.
- **`_inspection_json_asset_context` and `serve_document`.** They omit municipality filters (339–370, 2523–2537) but use ids or keys already tied to an inspection that `_get_inspection` accepted. A leak needs a pre-existing cross-tenant `asset_id`, observation row, or `storage_key`. Not established here.
- **Token type / secret confusion.** `validate_worker_job_request` does not re-check `type` (193–206). Rejection of non-`access` tokens is documented as living in `deps.py` / `jwt.py`, which are outside the packet. Scope constant `WORKER_PACK_INGEST` is also outside the packet.
- **Baseline `str()` compare and `sub` impersonation.** Municipality is still compared (388–396). `sub` is not checked here; mint-time binding of `user_id` to the uploader is outside the packet.

## Missing evidence

`deps.py`, `jwt.py`, profile-bank and inspection routers, and the claim/worker-queue writer of `output_path`, `config_json`, and `review_manifest.json` are outside the packet. Consequence: worker-token allowlisted routes cannot be confirmed to return another tenant’s rows, and `output_path` / manifest poisoning cannot be tied to a specific in-packet writer. The read side of the `output_path` path does not depend on those files.

## Next action

Add the regression above against `serve_review_pack_file`, `serve_in_progress_file`, and `get_in_progress_fps_count`, and confine `output_path` before any `storage.get` / `list_keys` / `get_response`. Separately, fix the inspection-id select so a failed tenant join cannot become `worker_job_inspection_id`.

xai / grok-4.7-efficient / low / low effort answer

No closed cross-tenant exploit is fully proven inside this packet. The concrete unauthorized-read path the code will execute is unbounded serving of `ProcessingJob.output_path`. Worker-job tokens are not a review-pack credential in this snapshot.

## Finding
**Arbitrary storage read via job `output_path` (cross-tenant if that key is another tenant’s object).**

`GET /review-pack/{inspection_id}/in-progress/{file_path}`, `GET /review-pack/{inspection_id}/in-progress/fps-count`, and the unfinalized fallback in `GET /review-pack/{inspection_id}/{file_path}` authorize the inspection, then read storage from a job path that is not bound to the tenant or the inspection.

Evidence:
- Inspection access is tenant-scoped in `_get_inspection` (`review_pack.py` 1242–1273): `Asset.municipality_id == scope.own_org_id` and `scope.inspection_filter()`.
- The follow-up media lookup does not repeat that check (`2339–2344`, `2435–2439`, `4074–4079`): `MediaFile.inspection_id` + `media_type == "video"` + `active()` only. No `municipality_id`. `.first()` is unordered.
- The job lookup (`2353–2374`, `2446–2466`, `4084–4096`) filters `media_file_id`, job type, and status only. No `ProcessingJob.municipality_id`.
- The handler then serves `{job.output_path}/{file_path}` (`2378`, `2470–2474`, `4095–4121`) with path-traversal checks on `file_path` only. Unlike manifest `video_path` (`2656–2666`), there is no `_confine_to_pack_tenant`.

Affected action: read of whatever object exists at that key. In-progress routes are limited to `fps/` and `modules/observations/`. The generic route, when `review_pack_path` is empty, serves any non-`certification/` relative path, including `inspection.json` and track/video artifacts.

Required preconditions (all visible in this code once the row exists):
1. Caller passes `_get_inspection` for inspection `I`.
2. An active video `MediaFile` has `inspection_id == I`.
3. A `review_pack` or `embedded_import` job for that media id is `pending`, `running`, or `completed`, with non-empty `output_path`.
4. Generic route only: `inspection.review_pack_path` is empty. In-progress routes use `output_path` even when a finalized pack exists, if the requested file is missing there (`2424–2470`).
5. The storage backend has an object at `{output_path}/{file_path}`.

Cross-tenant consequence: if `output_path` is another municipality’s key (shared bucket, opaque keys), this handler returns those bytes. How `output_path` is written is outside the packet, so the write step is not established here. Given such a row, the read is unconditional.

Minimal mitigation: select media and job only when both `municipality_id` values equal `scope.own_org_id`, and reject `output_path` unless it matches a server-built prefix for that inspection (not merely “non-empty”). Do not treat a completed job’s `output_path` as a standing read capability.

Regression: inspection in org A, video media linked to it, job `output_path` under org B’s prefix, object present → 404 and no `storage.get`/`get_response`. Same for in-progress `fps/` and for generic `inspection.json` when `review_pack_path` is null. Control: same-inspection prefix still serves.

## Same-file gap (not cross-tenant by itself)
`serve_review_pack_video` (`2646–2666`) will read a worker-written manifest `video_path` if it only shares the first two segments of `pack_key` (`_confine_to_pack_tenant`, `1194–1208`). That blocks `review-packs/{other_muni}/...` if segment 2 is the municipality id. It does not block another inspection or project under `review-packs/{same_muni}/...`, even though `_get_inspection` applied `inspection_filter()`. Preconditions: no `video/*.mp4`, `{pack}/{video_path}` missing, relative `video_path` exists under that two-segment root. Mitigation: confine to the inspection pack key, not `parts[:2]`. Regression: same-muni, different inspection key → 404.

## Worker-token boundary
No token-confusion path into review-pack is shown. `_ALLOWED_ROUTES` (`78–93`) does not include `/review-pack`. `validate_worker_job_request` 403s before DB work when method/path miss (`207–216`). `sub` remains the uploader, but the fence is type + `scp == [WORKER_PACK_INGEST]` + live job/tenant/resource snapshot (`197–205`, `271–295`). Review-pack routes use `get_media_user` / `require_role` / `require_scope`, not these tokens.

`GET /api/v1/organizations/\d+/profile-bank/stats` is allowlisted without binding the path org id in this function. `enforce_worker_job_municipality` exists (`309–321`) but is not called here. Whether that route calls it is outside the packet; do not treat the route name as a confirmed bypass.

## Discarded
- `_inspection_json_asset_context` (`339–377`) uses a fresh session and omits municipality on `Asset.id` / `observation.inspection_id`. Those predicates are the already-authorized primary keys, so this is not a cross-tenant read by itself.
- `persist_review_boot_from_bytes` / `stamp_review_boot` (`155–208`) write boot JSON by `Inspection` id with no tenant or worker-job check. A foreign id would be a cross-tenant metadata write. No caller in this packet passes that id, so this is not a closed path.
- `serve_document` (`2523–2537`) omits `MediaFile.municipality_id` but still keys off the authorized `inspection_id` and serves that row’s `storage_key`. Cross-tenant only if such a mismatched row already exists; creation is not in this packet.

## Missing dependencies
`app.deps` (whether every non-`access` token hits `validate_worker_job_request`), profile-bank/observations/inspections handlers (whether they call `enforce_worker_job_*`), job-claim code that sets `output_path`, and storage/RLS behavior. Until those are in evidence, do not claim the worker fence is bypassed or that a worker can mint the bad `output_path`.

Next useful action: add the output_path confinement checks and the two regression tests above; separately confirm the org-id stats route calls `enforce_worker_job_municipality` before any tenant read.

Primary judge's stated reason

Forced, weak preference for B: its additional conditional inspection-binding analysis supplies a precise validation invariant and regression target relevant to worker-token isolation. This is not a proven material quality gap; A's restraint is a substantial countervailing benefit, and an independent review could reasonably reject this preference.

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