Fix 29 CodeQL alerts: command injection, snprintf overflow, TOCTOU races

- Command injection (CRITICAL): validate shell args before system() in
  update command's unzip and version-check calls
- TOCTOU cli.c: use open(O_CREAT, 0755) + fdopen() to set permissions
  atomically instead of fopen() + chmod() after close
- TOCTOU pass_envscan.c: open file first, then fstat() on fd to check
  size, eliminating stat-then-open race window
- Overflowing snprintf (11 locations): clamp offset after each append
  to prevent unsigned underflow on truncation in cypher.c, store.c,
  http_server.c, test_c_lsp.c
- Add CBM_SNPRINTF_APPEND macro in str_util.h for future safe appends
- CodeQL: remove pull_request trigger (only scan push to main)
- CodeQL gate: increase timeout from 30 to 45 minutes
- Add fuzz testing script (random JSON-RPC + Cypher mutations)
- 12 Scorecard governance alerts dismissed (not code vulnerabilities)
This commit is contained in:
Martin Vogel committed 2026-03-21 22:18:31 +01:00
1 parent 4322116349
commit aa2b60be7d
12 files changed
+291 -39

No files matched your search

-2
View File
@@ -3,8 +3,6 @@ name: CodeQL SAST
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
security-events: write