Skip to content

Potential fix for code scanning alert no. 826: Uncontrolled data used in path expression - #562

Merged
kimocoder merged 1 commit into
masterfrom
alert-autofix-826
Sep 1, 2026
Merged

kimocoder merged 1 commit into
masterfrom
alert-autofix-826

Conversation

@kimocoder

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/kimocoder/wifite2/security/code-scanning/826

Use a stricter allowlist-style approach for static assets: serve only files directly under static/ by filename, rejecting any request containing path separators or traversal-like forms. This preserves current behavior (the code already caches by filename = os.path.basename(file_path)) while eliminating uncontrolled path composition.

Best single fix in wifite/attack/portal/server.py (_serve_static_file):

  1. Normalize requested segment (path[8:]) and reject empty input.
  2. Require the normalized request to equal os.path.basename(...) (no subdirectories).
  3. Use that safe basename for both cache lookup and filesystem join.
  4. Build full_path from static_dir + safe_name, canonicalize once, do one containment check, then isfile.

This removes the duplicate full_path rebuild and duplicate commonpath check, and ensures the sink only receives a validated filename.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

… in path expression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@kimocoder
kimocoder marked this pull request as ready for review September 1, 2026 00:40
@kimocoder
kimocoder merged commit aaa92c0 into master Sep 1, 2026
13 checks passed
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.

1 participant