Skip to content

fix(security): resolve 50 CodeQL stack-trace-exposure alerts across API routers - #27

Merged
spelech merged 3 commits into
mainfrom
fix/codeql-stack-trace-exposure-alerts
Sep 27, 2026
Merged

spelech merged 3 commits into
mainfrom
fix/codeql-stack-trace-exposure-alerts

Conversation

@spelech

@spelech spelech commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Summary

Resolves 50 CodeQL py/stack-trace-exposure security alerts across ContextCortex backend API router endpoints:

  • app/api/routers/settings.py: Sanitized 21 alerts across endpoints fetching stats, managing Git host credentials, updating tokens, configuring auto-sync, retrieving/clearing diagnostic logs, testing/switching vector stores, discovering models, and updating embedding/file configurations.
  • app/api/routers/storage.py: Sanitized 12 alerts across PDF preview, file upload, file replace, file retrieval, file deletion, and storage file tree endpoints.
  • app/api/routers/repositories.py: Sanitized 10 alerts across repository sync, repo creation, repo deletion, auto-sync toggle, branch discovery, and file browsing endpoints.
  • app/api/routers/navigator.py: Sanitized 3 alerts across symbols lookup, file references, and codebase search endpoints.
  • app/api/routers/graph.py: Sanitized 2 alerts across topology and dependencies graph endpoints.
  • app/api/routers/ingestion.py: Sanitized 1 alert across ingestion status endpoint.
  • app/api/webhooks.py: Sanitized 1 alert on invalid webhook JSON payloads.

All internal exception details and stack traces are logged server-side via logger.error or logger.warning rather than returned to API clients.

Verification

  • Full test suite passed: 524 passed, 2 skipped in 41.33s.

Antigravity Agent added 3 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
…PI routers

- Sanitize exception responses across endpoints in settings.py, storage.py, repositories.py, navigator.py, graph.py, ingestion.py, and webhooks.py.
- Ensure internal exception objects and stack traces are logged server-side rather than leaked to clients.
- Update test error handling assertions to verify 500 status and error presence without relying on exposed internal exception messages.
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)
@spelech
spelech merged commit 3c02adb into main Sep 27, 2026
14 of 15 checks passed
@spelech
spelech deleted the fix/codeql-stack-trace-exposure-alerts branch September 27, 2026 11:12
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