fix: BOLA/IDOR: enforce process ownership on process and file APIs#306
Open
ShreyasW-Microsoft wants to merge 1 commit into
Open
fix: BOLA/IDOR: enforce process ownership on process and file APIs#306ShreyasW-Microsoft wants to merge 1 commit into
ShreyasW-Microsoft wants to merge 1 commit into
Conversation
Add verify_process_ownership helper and apply it to all /api/process/* endpoints and the /api/file/upload endpoint so authenticated callers can only access processes they own. Returns 404 (not 403) for missing or non-owned processes to avoid confirming existence. status/render_status previously had no auth at all; both now authenticate and check ownership. Adds ownership-enforcement tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Coverage Report •
|
|||||||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a BOLA/IDOR vulnerability in the backend API by ensuring that callers can only access processes (and process-scoped files) that they own, returning 404 to avoid leaking the existence of other users’ resources.
Changes:
- Added a shared authorization helper (
verify_process_ownership) to enforce process ownership with a 404-on-mismatch policy. - Enforced ownership checks across process endpoints in
router_process.pybefore performing any process or blob/processor operations. - Expanded router-level unit tests to cover “non-owner” and “missing process” behaviors (404) and ensure side effects are not executed.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/backend-api/src/app/libs/services/authorization.py | Introduces verify_process_ownership to centralize ownership verification and consistent 404 behavior. |
| src/backend-api/src/app/routers/router_process.py | Adds ownership verification to process and file-related process endpoints and ensures HTTPExceptions aren’t masked into 500s. |
| src/backend-api/src/app/routers/router_files.py | Adds ownership enforcement for file upload tied to a process (404 for missing/not-owned). |
| src/backend-api/src/tests/routers/test_router_process.py | Adds default owned-process behavior for mocks and introduces comprehensive non-owner/missing-process endpoint tests. |
| src/backend-api/src/tests/routers/test_router_files.py | Updates process test records to include user_id and adds tests for non-owner/missing-process upload behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
72
to
+78
| process_record = await processRepository.get_async(process_id) | ||
|
|
||
| # Verify the caller owns this process before uploading into it. | ||
| # Return 404 (not 403) so the response does not confirm the | ||
| # existence of processes belonging to other users. | ||
| if not process_record or process_record.user_id != user_id: | ||
| raise HTTPException(status_code=404, detail="Process not found") |
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.
Resolves a BOLA/IDOR vulnerability by enforcing process ownership on process and file APIs. Adds an authorization service, ownership checks in router_process.py and router_files.py, and unit tests.