fix(resume): Scope resume download to the caller's troop - #1249
Open
jeromehardaway wants to merge 3 commits into
Open
fix(resume): Scope resume download to the caller's troop#1249jeromehardaway wants to merge 3 commits into
jeromehardaway wants to merge 3 commits into
Conversation
The download proxied to J0dI3 with only the app API key, so any authenticated user could download another user's resume by guessing a sessionId. It now forwards the caller's troop_id and X-Troop-Token (like the other resume endpoints) so J0dI3 enforces session ownership, and rejects callers with no linked troop before any download.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR closes a security gap in the J0dI3 resume download proxy by scoping the upstream download request to the authenticated caller’s troop context, preventing cross-user resume downloads via guessed/enumerated sessionIds.
Changes:
- Forward
troop_id(query param) andX-Troop-Token(header) to J0dI3 for/jobs/resume/download/:sessionId. - Return
400early when the caller lacks required troop context, and propagate upstream authorization statuses (e.g.,403) instead of masking them. - Add Vitest coverage to ensure troop scoping is forwarded, missing-troop callers are rejected pre-upstream, and J0dI3
403is propagated.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/pages/api/j0di3/jobs/resume/download/[sessionId].ts |
Adds troop scoping (troop_id + X-Troop-Token) to the resume download request and preserves upstream auth status codes. |
__tests__/pages/api/j0di3/resume-download.test.ts |
Adds tests validating troop scoping, early 400 behavior, and upstream 403 propagation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
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.
Problem
GET /api/j0di3/jobs/resume/download/[sessionId]authenticated the caller but proxied to J0dI3 with only the app-levelX-API-Key— it never scoped the request to the caller's troop. J0dI3 had no way to know who was asking, so any authenticated user could download another user's resume by guessing/enumerating asessionId.Fix
Forward the caller's troop context —
troop_id(query param) andX-Troop-Token(header) — exactly as every other resume endpoint (upload,upload-and-score) and the sharedj0di3-proxyalready do. J0dI3, which owns the session→troop mapping, then enforces that the session belongs to the requesting troop. Callers with no linked troop are rejected (400) before any download.Boundary note
The app keeps no local
session→trooprecord, so the definitive403 for a cross-user sessionIdis enforced by J0dI3 given the troop scoping this PR adds. Worth confirming J0dI3 rejects a mismatchedtroop_id/session — if it doesn't, that's a J0dI3-side follow-up.Verification
New tests (
__tests__/pages/api/j0di3/resume-download.test.ts, 3 passing): the request is troop-scoped (troop_id + X-Troop-Token forwarded); a caller with no troop is 400'd before any J0dI3 call; a J0dI3 403 is propagated to the client.npm run typecheck— pass.Closes #1198