fix(productentry): return 404 on cross-tenant access — close tenant enumeration leak#218
Merged
CryptoJones merged 1 commit intoMay 19, 2026
Conversation
…e tenant-enumeration leak Same class as the eight prior secure-404 fixes (#174 / #188 / #192 / #196 / #200 / #204 / #210 / #214), applied to the job-cascade- scoped ProductEntry: pentJobId → Job.jobCustId → Customer.custCompId Collapse 403 "exists but not yours" into 404 "Not found." so scoped callers can't enumerate `pentId` populations across the whole tenant table by status code. Pinned in `tests/api/productentry.test.js` with three controller- level unit tests, spying on `auth.getCompanyIdByJobId` (which internally walks the job → customer → company chain). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CryptoJones
added a commit
that referenced
this pull request
May 19, 2026
…enant-enumeration leak (#238) Same class as the 13 prior secure-404 fixes, applied to TimeEntry's getById / update / remove handlers. TimeEntry is direct-company- scoped via `teCompId`. Collapse 403 "exists but not yours" into 404 "Not found." so scoped callers can't enumerate `teId` populations across the whole tenant table by status code. Pinned in `tests/api/timeentry.test.js` with three controller-level unit tests spying on `auth.isMaster` / `auth.getCompanyId`. This completes the secure-404 series for the 14 single-resource domain entities (#174 / #188 / #192 / #196 / #200 / #204 / #210 / #214 / #218 / #222 / #226 / #230 / #234). Two domain controllers remain outside the series: VersionInfo (master-gated; different auth shape) and Customer (large refactor; the `findAndRespond` helper short-circuits to 200+null on a non-existent id which is a separate bug worth its own PR). Co-authored-by: Aaron K. Clark <akclark@thenetwerk.net> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CryptoJones
added a commit
that referenced
this pull request
May 19, 2026
The codebase collapses "exists but not yours" into 404 across every single-row GET / PATCH / DELETE endpoint so a scoped caller can't enumerate another tenant's ID range by status code. The pattern landed across 11 entities (#174, #188, #192, #196, #200, #204, #210, #214, #218, #222, etc.) but the README never mentioned the behavior — operators reading the doc table would reasonably expect 403 on a cross-tenant probe and be surprised by 404. Add a short subsection in the HTTP-conventions block that explains the choice, links the behavior to the same getCompanyId scope check used for 403 paths on other surfaces, and notes that master keys still see all rows. Co-authored-by: Aaron K. Clark <akclark@thenetwerk.net> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #217.
Summary
Same secure-404 pattern as the eight prior fixes, now on the job-cascade-scoped ProductEntry (
pentJobId → Job.jobCustId → Customer.custCompId).Test plan
npm run lintcleannpm test— 666 → 669 (+3 controller-level tests)Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/