Badge Details Leak Across Facility Sites
Level 2 · node · Security · Missing site-scoped authorization on badge detail lookup
Scenario
A fictional multi-site facility service manages access badges. Each badge has a site ID and badge ID, and a site manager must only view badges belonging to that site. List queries are already site-scoped, but the detail endpoint returns a badge from another site when its ID is known. Inspect the repository, service, and controller lookup path.
Requirements
Check both the requested site ID and the badge's owning site for detail reads. A badge belonging to another site must raise an error just like an unknown badge. Preserve same-site reads, site-scoped lists, missing-badge errors, and stored data. Do not add external packages.
Acceptance criteria
- Only badges belonging to the requested site can be read in detail.
- A badge from another site is inaccessible even when its ID is known.
- Site isolation still holds after a successful same-site lookup.
- An unknown badge produces an error.
- Listing returns only badges for the requested site.
- Reads and lists do not mutate stored badge data.