Skip to content

Sanitize uploaded filenames to prevent directory traversal attacks - #2

Closed
Ariel-Gal with Copilot wants to merge 3 commits into
Developmentfrom
copilot/sub-pr-1
Closed

Sanitize uploaded filenames to prevent directory traversal attacks#2
Ariel-Gal with Copilot wants to merge 3 commits into
Developmentfrom
copilot/sub-pr-1

Conversation

Copilot AI commented Jan 18, 2026

Copy link
Copy Markdown
Contributor

Addresses security vulnerability where user-provided filenames were used directly in file operations, allowing potential directory traversal attacks (e.g., ../../etc/passwd).

Changes

  • Import secure_filename from werkzeug.utils
  • Sanitize filenames before saving in /preview and /upload endpoints (image uploads)
  • Sanitize filename parameter in /get_preview/<filename> endpoint
# Before
file.save(os.path.join(session_images_path, file.filename))

# After
safe_filename = secure_filename(file.filename)
file.save(os.path.join(session_images_path, safe_filename))

The secure_filename() function strips directory components and dangerous characters from user-provided filenames.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 18, 2026 21:06
…y traversal attacks

Co-authored-by: Ariel-Gal <82096633+Ariel-Gal@users.noreply.github.com>
…raversal

Co-authored-by: Ariel-Gal <82096633+Ariel-Gal@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on Google Fonts integration enhancements Sanitize uploaded filenames to prevent directory traversal attacks Jan 18, 2026
Copilot AI requested a review from Ariel-Gal January 18, 2026 21:09
@Ariel-Gal Ariel-Gal closed this Jan 19, 2026
@Ariel-Gal
Ariel-Gal deleted the copilot/sub-pr-1 branch January 19, 2026 10:27
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