Skip to content

fix: BOLA/IDOR: enforce process ownership on process and file APIs#306

Open
ShreyasW-Microsoft wants to merge 1 commit into
devfrom
psl-sw/resolve-incident
Open

fix: BOLA/IDOR: enforce process ownership on process and file APIs#306
ShreyasW-Microsoft wants to merge 1 commit into
devfrom
psl-sw/resolve-incident

Conversation

@ShreyasW-Microsoft

Copy link
Copy Markdown
Contributor

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.

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>
@github-actions

Copy link
Copy Markdown

Coverage

Coverage Report •
FileStmtsMissCoverMissing
src/backend-api/src/app/libs/services
   authorization.py15286%31, 34
src/backend-api/src/app/routers
   router_files.py61296%59, 66
   router_process.py3463889%60, 70–71, 139, 143, 150, 160, 239, 243, 250, 298–300, 324, 331, 385, 392, 457, 498–500, 527, 587, 619–621, 648, 721–723, 748, 784, 787, 803–804, 810–812
TOTAL313820593% 

Tests Skipped Failures Errors Time
602 0 💤 0 ❌ 0 🔥 25.207s ⏱️

@github-actions

Copy link
Copy Markdown

Coverage

Processor Coverage Report •
FileStmtsMissCoverMissing
TOTAL600984086% 
report-only-changed-files is enabled. No files were changed during this commit :)

Tests Skipped Failures Errors Time
834 0 💤 0 ❌ 0 🔥 20.894s ⏱️

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py before 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")
@ShreyasW-Microsoft ShreyasW-Microsoft changed the title Fix BOLA/IDOR: enforce process ownership on process and file APIs fix: BOLA/IDOR: enforce process ownership on process and file APIs Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants