xai / grok-4.7-efficient / low / low 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.
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.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
Weak, forced preference for A: its opening limitation better guards against treating a malformed job-path fixture as proof of an attacker-reachable authorization defect. The answers are substantially equivalent on the main result; this is not an established material quality difference, and an independent review could reject the 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_f578edb7840aad0c7103607e3a1885faacc733830a742cc4b84a6143bcca4b5d. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.