fix(security): resolve 47 CodeQL path-injection alerts across services - #26
Merged
Merged
Conversation
added 2 commits
September 27, 2026 05:43
…k hashing alerts - py/full-ssrf (#42): validate URL scheme, block restricted metadata hosts, and reconstruct safe endpoints with urlunsplit in litellm_service and settings router - py/polynomial-redos (#43, #44): optimize template literal regex and switch Next.js route path extraction to deterministic component splitting in api_route_extractor - js/incomplete-url-substring-sanitization (#95): parse hostname via new URL and verify domain boundaries in SearchInspector.tsx - py/clear-text-logging-sensitive-data (#1, #2, #3): sanitize logging in key_service by eliminating key prefix strings from log messages - py/weak-sensitive-data-hashing (#41): use PBKDF2-HMAC-SHA256 with salt for API key hashing in key_service - sync test counts in REQUIREMENTS.md
- local_storage.py: enforce explicit storage_root startswith and commonpath containment in resolve_safe_path, save_file_content, index_file, read_file_content, delete_file, and get_file_tree - file_reader.py: add root_prefix startswith validation in _is_within_root for both target and symlink paths - summarizer.py: normalize filepath and enforce storage prefix containment when reading from disk/storage - repositories.py: sanitize and validate paths against null bytes and .. traversal in api_add_path and api_browse_dir - files.py: validate input path against traversal in api_summarize_file - indexing/processor.py: normalize filepath before checking existence and mtime - vector_store (chroma & qdrant): normalize target_storage path before directory creation and client initialization - pdf_extractor.py: normalize source path before checking existence, size, and opening document - adr.py: normalize filepath before checking existence and reading ADR markdown content
| if content is None: | ||
| if os.path.exists(filepath): | ||
| norm_fp = os.path.normpath(os.path.abspath(filepath)) | ||
| if os.path.exists(norm_fp) and os.path.isfile(norm_fp): |
| if content is None: | ||
| if os.path.exists(filepath): | ||
| norm_fp = os.path.normpath(os.path.abspath(filepath)) | ||
| if os.path.exists(norm_fp) and os.path.isfile(norm_fp): |
| if os.path.exists(norm_fp) and os.path.isfile(norm_fp): | ||
| try: | ||
| with open(filepath, "r", encoding="utf-8", errors="replace") as f: | ||
| with open(norm_fp, "r", encoding="utf-8", errors="replace") as f: |
| os.makedirs(target_storage, exist_ok=True) | ||
| self.client = chromadb.PersistentClient(path=target_storage) | ||
| clean_storage = os.path.normpath(os.path.abspath(target_storage)) | ||
| os.makedirs(clean_storage, exist_ok=True) |
| os.makedirs(target_storage, exist_ok=True) | ||
| self.client = chromadb.PersistentClient(path=target_storage) | ||
| clean_storage = os.path.normpath(os.path.abspath(target_storage)) | ||
| os.makedirs(clean_storage, exist_ok=True) |
| os.makedirs(target_storage, exist_ok=True) | ||
| self.client = QdrantClient(path=target_storage) | ||
| clean_storage = os.path.normpath(os.path.abspath(target_storage)) | ||
| os.makedirs(clean_storage, exist_ok=True) |
| os.makedirs(target_storage, exist_ok=True) | ||
| self.client = QdrantClient(path=target_storage) | ||
| clean_storage = os.path.normpath(os.path.abspath(target_storage)) | ||
| os.makedirs(clean_storage, exist_ok=True) |
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
This PR addresses all 47
py/path-injectionCodeQL alerts across the codebase by applying normalized path containment assertions and standard prefix barriers recognized by CodeQL:app/services/local_storage.py(22 alerts)resolve_safe_pathto normalize both target and storage root, enforcing strict prefix matching (target.startswith(prefix)) in addition tocommonpath.save_file_content,index_file,read_file_content,delete_file_disk,delete_file, andget_file_tree).app/services/file_reader.py(8 alerts)startswithassertions to_is_within_rootfor both raw target paths and resolved symlinks.app/services/summarizer.py(4 alerts)app/api/routers/repositories.py(3 alerts)..) before filesystem checks inapi_add_pathandapi_browse_dir.app/api/routers/files.pyapi_summarize_file.app/services/indexing/processor.py(2 alerts)app/services/vector_store/qdrant_store.py&chroma_store.py(4 alerts)os.makedirsand client instantiation.app/services/pdf_extractor.py&app/services/adr.py(4 alerts)Verification