fix(security): resolve path-injection CodeQL alerts (#3164)#3182
Merged
mrveiss merged 1 commit intoDev_new_guifrom Apr 1, 2026
Merged
fix(security): resolve path-injection CodeQL alerts (#3164)#3182mrveiss merged 1 commit intoDev_new_guifrom
mrveiss merged 1 commit intoDev_new_guifrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
validate_path()/validate_relative_path()fromautobot_shared.security.path_validatorto all locations where user-controlled paths flow into file system operationsChanges
autobot-backend/agents/npu_code_search_agent.py(+4 lines)Added
validate_path(file_path)beforeaiofiles.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 pathautobot-backend/api/analytics_performance.py(+5 lines)Added
validate_path(path)import and call inanalyze_pathendpoint before passing user-suppliedpathquery 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_recommendationsendpoint. Previously the user-suppliedpathquery param was passed directly to_fetch_live_env_recommendations()thenanalyzer.analyze_codebase(path)without validation. Now uses the existing_validate_env_path_security()helper (already used by the siblinganalyze_environmentendpoint).autobot-backend/services/fast_document_scanner.py(+12 lines)Added
validate_path()call inget_parsed_man_page()before passingfile_pathtoparser.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 inread_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
python -c "from autobot_shared.security.path_validator import validate_path"path=../../etc/passwdreturns 4xx🤖 Generated with Claude Code