Skip to content

Implement path traversal protection and rate limiting#136

Open
ThilakesB wants to merge 1 commit into
sutanjoyb:masterfrom
ThilakesB:master
Open

Implement path traversal protection and rate limiting#136
ThilakesB wants to merge 1 commit into
sutanjoyb:masterfrom
ThilakesB:master

Conversation

@ThilakesB

Copy link
Copy Markdown

Added path traversal protection to file upload handling and re-enabled rate limiting for the verify chain endpoint.

Added path traversal protection to file upload handling and re-enabled rate limiting for the verify chain endpoint.
Copilot AI review requested due to automatic review settings May 10, 2026 16:38

Copilot AI left a comment

Copy link
Copy Markdown

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 strengthens the FastAPI service’s defenses by hardening file-path handling for the SSE analysis endpoint and restoring request throttling on the chain verification endpoint.

Changes:

  • Added path traversal protection to /analyze-process by resolving and constraining file_path to UPLOAD_DIR.
  • Updated /analyze-process to analyze the validated safe_path instead of the raw client-supplied file_path.
  • Re-enabled SlowAPI rate limiting on /verify-chain (30/minute).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread main.py
Comment on lines +301 to +307
safe_path = os.path.realpath(file_path)
upload_dir_real = os.path.realpath(UPLOAD_DIR)
if not safe_path.startswith(upload_dir_real + os.sep):
raise HTTPException(
status_code=400,
detail="Invalid file path. Access outside upload directory is not permitted."
)
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