[audit] Deep audit — stdlib migration gaps, missing tests, error handling #4

Open
opened 2026-03-22 16:37:32 +00:00 by Virgil · 6 comments
Member

Prior AX sweep found massive stdlib usage:

  • 2 HIGH: os.Getenv(HOME) in local/client.go
  • 80+ MEDIUM: filepath.* across io.go, node.go, s3.go, local/client.go, datanode/client.go, workspace/service.go, sqlite.go, store/medium.go
  • 10+ LOW: fmt.Errorf, errors.New sentinels

This audit should identify: missing test coverage for all Medium types (local, s3, datanode, sqlite, workspace), error handling gaps, and any additional security concerns.

Prior AX sweep found massive stdlib usage: - 2 HIGH: os.Getenv(HOME) in local/client.go - 80+ MEDIUM: filepath.* across io.go, node.go, s3.go, local/client.go, datanode/client.go, workspace/service.go, sqlite.go, store/medium.go - 10+ LOW: fmt.Errorf, errors.New sentinels This audit should identify: missing test coverage for all Medium types (local, s3, datanode, sqlite, workspace), error handling gaps, and any additional security concerns.
Author
Member

Codex Audit Findings

HIGH (2)

  1. Path traversal in workspace/service.go — name/filename not constrained, ../ escapes sandbox (service.go:42-142)
  2. HOME env guard bypassable in local/client.go Delete/DeleteAll (client.go:268, :280)

MEDIUM (2)

  1. S3 partial delete failure silently ignored (s3/s3.go:199, :233)
  2. Datanode suppresses read/open failures during rename, append, rebuild (datanode/client.go: 6 locations)
## Codex Audit Findings ### HIGH (2) 1. Path traversal in workspace/service.go — name/filename not constrained, ../ escapes sandbox (service.go:42-142) 2. HOME env guard bypassable in local/client.go Delete/DeleteAll (client.go:268, :280) ### MEDIUM (2) 3. S3 partial delete failure silently ignored (s3/s3.go:199, :233) 4. Datanode suppresses read/open failures during rename, append, rebuild (datanode/client.go: 6 locations)
Author
Member

Fix Applied

Commit 2acfc3d: fix(io): address audit issue 4 findings

  • Path traversal in workspace/service.go hardened
  • HOME env guard fixed in local/client.go
  • S3 partial delete failures now surfaced
  • Datanode suppressed failures fixed
  • 590 additions across 11 files with tests
## Fix Applied Commit 2acfc3d: fix(io): address audit issue 4 findings - Path traversal in workspace/service.go hardened - HOME env guard fixed in local/client.go - S3 partial delete failures now surfaced - Datanode suppressed failures fixed - 590 additions across 11 files with tests
Author
Member

Verification: FAIL (reproduced)

HIGH: Symlink escape still possible — workspacePath does lexical checks only, SwitchWorkspace accepts symlinked workspace entry that escapes root. Review agent reproduced: SwitchWorkspace('evil') with evil -> /tmp/outside.

Needs: resolve symlinks before path validation (filepath.EvalSymlinks or equivalent).

## Verification: FAIL (reproduced) HIGH: Symlink escape still possible — workspacePath does lexical checks only, SwitchWorkspace accepts symlinked workspace entry that escapes root. Review agent reproduced: SwitchWorkspace('evil') with evil -> /tmp/outside. Needs: resolve symlinks before path validation (filepath.EvalSymlinks or equivalent).
Author
Member

Fix Round 2

Commit def6a8f: Fix workspace symlink escape validation

  • Resolves symlinks before path boundary checks
  • 49 additions (service.go + test)
    Dispatching verification.
## Fix Round 2 Commit def6a8f: Fix workspace symlink escape validation - Resolves symlinks before path boundary checks - 49 additions (service.go + test) Dispatching verification.
Author
Member

Verification Round 2: FAIL

HIGH: Workspace symlink hardening incomplete — activeFilePath doesn't resolve/revalidate symlinks inside files tree. files dir itself or children can be symlinked to escape. io.Local rooted at / means any resolved path is accessible.

Same TOCTOU pattern as go-rag. Needs architectural decision: fd-based ops or sandboxed io.Local root. Escalating to needs-human.

## Verification Round 2: FAIL HIGH: Workspace symlink hardening incomplete — activeFilePath doesn't resolve/revalidate symlinks inside files tree. files dir itself or children can be symlinked to escape. io.Local rooted at / means any resolved path is accessible. Same TOCTOU pattern as go-rag. Needs architectural decision: fd-based ops or sandboxed io.Local root. Escalating to needs-human.
Author
Member

Fact-Finding: API Contract Extraction

Agent built a Go AST parser tool to extract the full API surface across all subpackages (local, s3, datanode, sqlite, workspace). The tool parses exported types, functions, methods with coverage detection.

Approach: AST-based extraction with test reference cross-checking. This tool itself could be reusable for contract extraction across all Go repos.

Full source in agent log — consider extracting into a standalone tool.

## Fact-Finding: API Contract Extraction Agent built a Go AST parser tool to extract the full API surface across all subpackages (local, s3, datanode, sqlite, workspace). The tool parses exported types, functions, methods with coverage detection. Approach: AST-based extraction with test reference cross-checking. This tool itself could be reusable for contract extraction across all Go repos. Full source in agent log — consider extracting into a standalone tool.
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-io#4
No description provided.