[audit] Security, AX compliance, missing tests, error handling #4

Open
opened 2026-03-22 16:41:02 +00:00 by Virgil · 5 comments
Member

Full audit:

  1. Security: path traversal, injection, panics on untrusted input, race conditions
  2. AX compliance: os.Getenv → core.Env, filepath.* → core.Path*, fmt.Sprintf → core.Sprintf, strings.* → core.*, errors.New/fmt.Errorf → core.E
  3. Missing tests: exported functions without test coverage
  4. Error handling: silently dropped errors, bare panics, missing nil checks
  5. UK English: American spellings in comments/docs
  6. Missing usage-example comments on exported identifiers
  7. Missing SPDX licence headers

Report all findings with severity and file:line. Do NOT fix.

Full audit: 1. Security: path traversal, injection, panics on untrusted input, race conditions 2. AX compliance: os.Getenv → core.Env, filepath.* → core.Path*, fmt.Sprintf → core.Sprintf, strings.* → core.*, errors.New/fmt.Errorf → core.E 3. Missing tests: exported functions without test coverage 4. Error handling: silently dropped errors, bare panics, missing nil checks 5. UK English: American spellings in comments/docs 6. Missing usage-example comments on exported identifiers 7. Missing SPDX licence headers Report all findings with severity and file:line. Do NOT fix.
Author
Member

Codex Audit Findings

HIGH (1)

  1. Symlink traversal in ingest — crafted docs tree reads/embeds files outside requested root (ingest.go:90, :116)

MEDIUM (4)

  1. AddRAGSubcommands non-idempotent, panics on repeat registration (cmd_commands.go:16, cmd_rag.go:33)
  2. Public API panics on nil dependencies instead of returning errors (query.go:54, ingest.go:69)
  3. Ingest silently drops per-file/per-chunk failures (ingest.go:111, :117, :133)
  4. Zero test coverage on exported integration boundaries (helpers.go:46, ollama.go)
## Codex Audit Findings ### HIGH (1) 1. Symlink traversal in ingest — crafted docs tree reads/embeds files outside requested root (ingest.go:90, :116) ### MEDIUM (4) 2. AddRAGSubcommands non-idempotent, panics on repeat registration (cmd_commands.go:16, cmd_rag.go:33) 3. Public API panics on nil dependencies instead of returning errors (query.go:54, ingest.go:69) 4. Ingest silently drops per-file/per-chunk failures (ingest.go:111, :117, :133) 5. Zero test coverage on exported integration boundaries (helpers.go:46, ollama.go)
Author
Member

Fix Applied

Commit 2e8bc5a: fix(rag): harden ingest and command registration

  • Symlink traversal fixed in ingest
  • AddRAGSubcommands idempotent (no repeat panic)
  • Nil dependency guards with new dependencies.go
  • Silently dropped failures now surfaced
  • 525 additions across 13 files, comprehensive tests added
## Fix Applied Commit 2e8bc5a: fix(rag): harden ingest and command registration - Symlink traversal fixed in ingest - AddRAGSubcommands idempotent (no repeat panic) - Nil dependency guards with new dependencies.go - Silently dropped failures now surfaced - 525 additions across 13 files, comprehensive tests added
Author
Member

Verification: FAIL (reproduced)

MEDIUM: Symlinked root dirs don't ingest — Ingest resolves real root into rootDir but WalkDir starts from absDir. filepath.WalkDir doesn't traverse symlink root. Needs: walk from rootDir not absDir (ingest.go:76/:104).

## Verification: FAIL (reproduced) MEDIUM: Symlinked root dirs don't ingest — Ingest resolves real root into rootDir but WalkDir starts from absDir. filepath.WalkDir doesn't traverse symlink root. Needs: walk from rootDir not absDir (ingest.go:76/:104).
Author
Member

Fix Round 2

Commit 993a804: fix(ingest): walk resolved root dir

  • WalkDir now uses rootDir (resolved symlinks) not absDir
  • 30-line symlink root test added
    Dispatching verification.
## Fix Round 2 Commit 993a804: fix(ingest): walk resolved root dir - WalkDir now uses rootDir (resolved symlinks) not absDir - 30-line symlink root test added Dispatching verification.
Author
Member

Verification Round 2: FAIL

HIGH: TOCTOU race in Ingest — validates path during walk (ingest.go:104) but reopens cached pathname later with coreio.Local.Read (ingest.go:152). File can be swapped to symlink between check and read.

This is a fundamental TOCTOU — needs open-then-validate (open file first, then check fd's real path) or O_NOFOLLOW. Round 3 fix may not be sufficient for automated resolution — escalating to needs-human.

## Verification Round 2: FAIL HIGH: TOCTOU race in Ingest — validates path during walk (ingest.go:104) but reopens cached pathname later with coreio.Local.Read (ingest.go:152). File can be swapped to symlink between check and read. This is a fundamental TOCTOU — needs open-then-validate (open file first, then check fd's real path) or O_NOFOLLOW. Round 3 fix may not be sufficient for automated resolution — escalating to needs-human.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

-

Dependencies

No dependencies set.

Reference
core/go-rag#4
No description provided.