Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ You assist developers working on telegram-archive.
- Create a descriptive branch name (e.g., `feat/add-login`, `fix/button-styling`)
- Open a PR for review before merging
- Do NOT commit directly to main/master branch
- **After every push/merge**, check CI status with `gh run list` or `gh pr checks` and fix any test or lint failures before moving on

## Boundaries

Expand Down
11 changes: 10 additions & 1 deletion src/web/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,16 @@
if not _media_root:
raise HTTPException(status_code=404, detail="Media directory not configured")

resolved = (_media_root / path).resolve()
# Reject path traversal and absolute paths before any filesystem operations
if ".." in path.split("/") or path.startswith("/"):
raise HTTPException(status_code=403, detail="Access denied")

# Construct and resolve path, then verify it stays within media root
candidate = _media_root / path
try:
resolved = candidate.resolve(strict=True)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix

AI about 1 month ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

except (OSError, ValueError):
raise HTTPException(status_code=404, detail="File not found")
if not resolved.is_relative_to(_media_root):
raise HTTPException(status_code=403, detail="Access denied")

Expand Down
Loading