Sanitize upload filename — path traversal in import route #3

Open
opened 2026-06-06 19:58:10 +00:00 by tonym · 0 comments

Severity: critical
Category: security
Location: app.py:436

Problem

upload_path = os.path.join(DATA_DIR, file.filename) uses the raw browser filename. A name like ../transactions.json overwrites arbitrary files / clobbers the main data file.

Suggested fix

Use werkzeug.utils.secure_filename() and save into a dedicated uploads/ subdir, separate from the JSON data files.

Filed by automated code review.

**Severity:** critical **Category:** security **Location:** `app.py:436` ### Problem `upload_path = os.path.join(DATA_DIR, file.filename)` uses the raw browser filename. A name like `../transactions.json` overwrites arbitrary files / clobbers the main data file. ### Suggested fix Use `werkzeug.utils.secure_filename()` and save into a dedicated `uploads/` subdir, separate from the JSON data files. _Filed by automated code review._
tonym added the
security
severity:critical
labels 2026-06-06 19:58:10 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bonna61/Moon-Household-Budget#3
No description provided.