Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(security): sanitise entry_id and actor in waitlist patch log (#442) (#137)

Beenu Arora9dbbc3c10894
diff --git a/services/api/app/api/v1/endpoints/waitlist.py b/services/api/app/api/v1/endpoints/waitlist.py
index 115726081..f802347aa 100644
--- a/services/api/app/api/v1/endpoints/waitlist.py
+++ b/services/api/app/api/v1/endpoints/waitlist.py
@@ -420,20 +420,29 @@ async def patch_entry(
detail="Could not update waitlist entry.",
) from exc
- # CodeQL py/log-injection: sanitise inline so the taint tracker
- # sees the .replace() chain directly at the call site. Both values
- # are also Pydantic-validated against ``ALLOWED_WAITLIST_STATUSES``
- # so they can only ever be short safe identifiers, but the inline
- # sanitisation makes the property explicit for static analysis.
+ # CodeQL py/log-injection: sanitise every value inline so the taint
+ # tracker sees the .replace() chain directly at the call site.
+ #
+ # - ``previous`` / ``payload.status`` are Pydantic-validated against
+ # ``ALLOWED_WAITLIST_STATUSES`` (short identifiers, no CR/LF), and
+ # - ``entry_id`` / ``user.user_id`` are typed as ``uuid.UUID`` so the
+ # string form is always ``[0-9a-f-]{36}``,
+ #
+ # but CodeQL's taint tracker treats path params and DB-derived
+ # strings as user-controlled regardless. Making the cleansing
+ # explicit at the call site silences the alert without weakening
+ # any existing guarantee.
safe_previous = (previous or "").replace("\r", "").replace("\n", " ")[:32]
safe_next = (payload.status or "").replace("\r", "").replace("\n", " ")[:32]
+ safe_entry_id = str(entry_id).replace("\r", "").replace("\n", " ")[:36]
+ safe_actor = str(user.user_id).replace("\r", "").replace("\n", " ")[:36]
logger.info(
"waitlist_status_transition",
extra={
- "entry_id": str(entry_id),
+ "entry_id": safe_entry_id,
"previous": safe_previous,
"next": safe_next,
- "actor": str(user.user_id),
+ "actor": safe_actor,
},
)
return _to_wire(row)