Skip to content

fix(security): resolve path-injection CodeQL alerts (#3164)#3182

Merged
mrveiss merged 1 commit intoDev_new_guifrom
fix/3164-path-injection
Apr 1, 2026
Merged

fix(security): resolve path-injection CodeQL alerts (#3164)#3182
mrveiss merged 1 commit intoDev_new_guifrom
fix/3164-path-injection

Conversation

@mrveiss
Copy link
Copy Markdown
Owner

@mrveiss mrveiss commented Apr 1, 2026

Summary

Changes

autobot-backend/agents/npu_code_search_agent.py (+4 lines)

Added validate_path(file_path) before aiofiles.open() in four methods that retrieve file paths from Redis (external data source) and use them to open files:

  • _search_file_exact — exact-match search reads file content from Redis-stored path
  • _search_file_regex — regex search reads file content from Redis-stored path
  • _search_file_semantic — semantic search reads file content from Redis-stored path
  • _get_file_context — context line lookup reads file content from NPU result metadata path

autobot-backend/api/analytics_performance.py (+5 lines)

Added validate_path(path) import and call in analyze_path endpoint before passing user-supplied path query parameter to _get_files_to_analyze(). Uses default allowed roots (/opt/autobot, /tmp).

autobot-backend/api/codebase_analytics/endpoints/environment.py (+8 lines)

Added path security validation in get_env_recommendations endpoint. Previously the user-supplied path query param was passed directly to _fetch_live_env_recommendations() then analyzer.analyze_codebase(path) without validation. Now uses the existing _validate_env_path_security() helper (already used by the sibling analyze_environment endpoint).

autobot-backend/services/fast_document_scanner.py (+12 lines)

Added validate_path() call in get_parsed_man_page() before passing file_path to parser.parse_man_page(Path(file_path)). Restricts allowed roots to system man page directories (/usr/share/man, /usr/local/share/man) consistent with the existing validation in read_man_page_content() in the same file.

Already Validated (no changes needed)

The following listed files already had complete path validation applied in prior work:
data_storage.py, filesystem_mcp.py, git_mcp.py, logs.py, chat_sessions.py, session.py, vnc_manager.py, prompts.py, reports.py, ownership.py (both), environment.py (other endpoints), secure_sandbox_executor.py (uses tempfile only)

Test plan

  • Verify no import errors: python -c "from autobot_shared.security.path_validator import validate_path"
  • Verify path traversal is blocked: request with path=../../etc/passwd returns 4xx
  • Verify legitimate paths within allowed roots still work
  • CodeQL re-scan should show reduction in py/path-injection alerts

🤖 Generated with Claude Code

)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mrveiss mrveiss merged commit 4adc1af into Dev_new_gui Apr 1, 2026
1 of 4 checks passed
@mrveiss mrveiss deleted the fix/3164-path-injection branch April 1, 2026 18: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.

1 participant