Skip to content

[Security Issue] Apply secure_filename to snapshot_path for security hardening #688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shyun020
Copy link

Description

  • Security fix – Resolved a path injection vulnerability in the snapshot_path parameter.

This change uses secure_filename from werkzeug.utils to sanitize the snapshot_path value obtained from user input, preventing malicious path traversal or unauthorized file access.

Problem

Previously, the snapshot_path parameter was used without validation. An attacker could exploit this by passing values like ../../etc/passwd, potentially gaining access to sensitive files on the server. This posed a serious path injection security risk.

Code Change

from werkzeug.utils import secure_filename

snapshot_path = secure_filename(request.args.get("snapshot_path"))

The secure_filename function ensures the input is converted to a safe, valid filename, effectively blocking directory traversal attempts.

Test Plan

  • Attempted path injection using snapshot_path=../../etc/passwd
  • Before fix: Able to access unintended paths
  • After fix: Filename is sanitized (e.g., becomes etc_passwd), preventing unauthorized access

@shyun020 shyun020 requested a review from Seagh0098 April 14, 2025 01:51
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