Skip to content

fix(spec): reject path-traversal spec names#463

Merged
Chemaclass merged 1 commit into
mainfrom
fix/spec-name-path-traversal
Jun 18, 2026
Merged

fix(spec): reject path-traversal spec names#463
Chemaclass merged 1 commit into
mainfrom
fix/spec-name-path-traversal

Conversation

@Chemaclass

Copy link
Copy Markdown
Owner

Summary

  • A spec name: is used verbatim as a filename/directory segment by every adapter. A value like name: ../../../tmp/pwned made sync write a file outside the project tree (path traversal) — verified end-to-end (a crafted command spec wrote /tmp/... outside the project root).
  • Fix: reject any spec name that is not a single safe path segment (no /, \, or ..) at load, with a clear error naming the file.
  • Defense-in-depth: emit.WriteFile now refuses any project-relative output path that climbs above the project root, catching traversals from any source (name, scope, direct Bundle construction).
  • The review-scope traversal was already guarded; this closes the per-entry name vector the bug-hunt surfaced.

Test plan

  • go test ./... (1259 pass) — loader rejection + emit-guard regression tests added
  • agnostic-ai sync --check (clean), golangci-lint clean, gofmt clean

A spec `name:` is used verbatim as a filename or directory segment by
every adapter, so a value like `../../../tmp/pwned` made sync write a
file outside the project tree (path traversal). Reject names that are
not a single safe path segment at load, with a clear error. As
defense-in-depth, emit.WriteFile now refuses any project-relative path
that climbs above the project root.

Adds loader and emit-level regression tests.
@Chemaclass Chemaclass added the bug Something isn't working label Jun 18, 2026
@Chemaclass Chemaclass self-assigned this Jun 18, 2026
@Chemaclass Chemaclass merged commit 58787c0 into main Jun 18, 2026
9 checks passed
@Chemaclass Chemaclass deleted the fix/spec-name-path-traversal branch June 18, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant