Model tool errors send the absolute host path to the provider when a path contains NUL

Aberta
#130 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
go
Domínio
security, tooling

Direção de pesquisa

Read resolve and pathError in internal/agent/tools/tools.go alongside walk.Resolve in internal/walk/walk.go, then run go test ./internal/agent/tools ./internal/walk to see the current behavior. Compare with the control-character check the git tools already use in internal/agent/tools/git.go:41, and extend TestOutsideFileIsNeverReadable in tools_test.go so it asserts on error text, not just content. Done means no tool result, including path-resolution and post-listing removal failures, contains an absolute path.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

good first issue privacy severity: low

Summary

The model tools strip host paths from OS errors on purpose ("The full text names host paths, which the model does not need and the provider should not see", internal/agent/tools/tools.go:384-385). Path-resolution errors bypass that: a model-supplied path containing a NUL byte returns an error that includes the absolute path of the operator's checkout, and that error goes to the provider as a tool result.

Where

  • internal/walk/walk.go:360-366 (Resolve wraps the EvalSymlinks error whole)
  • internal/agent/tools/tools.go:299-302 (resolve passes it to pathError)
  • internal/agent/tools/tools.go:376-382 (pathError keeps err.Error())
  • internal/agent/tools/tools.go:384-392 (reason, which is not used on this path)
  • internal/agent/tools/tools_test.go:770-812 (TestOutsideFileIsNeverReadable checks content, not error text)

Details

// walk.Resolve
resolved, err := filepath.EvalSymlinks(joined)
if err != nil {
    if os.IsNotExist(err) { ... }
    return "", fmt.Errorf("path %q: %w", untrusted, err)
}

A NUL byte makes Lstat fail with EINVAL, and the *fs.PathError text carries the absolute path. Reproduced with a test using the package's own helpers: read_file {"path":"README.md\u0000"} returned read_file: path "README.md\x00": Lstat <absolute target dir>\README.md : invalid argument; .... list_dir and grep do the same. reason has no test coverage.

Impact

The operator's absolute checkout path, which usually contains their OS user name, is sent to the model provider. Target content can steer the model into making such a call. Low: the provider already receives source code, and nothing but the path leaks.

Suggested fix

  • Refuse a path containing NUL or other control characters in resolve (or walk.Resolve) before touching the filesystem, as the git tools already do (internal/agent/tools/git.go:41).
  • Make pathError pass a wrapped *fs.PathError through reason so it loses its Path.

Acceptance criteria

  • No tool result contains the absolute target path, for any input.
  • TestOutsideFileIsNeverReadable also asserts that no result contains the parent directory path.
  • A unit test of reason with an *fs.PathError returns the cause without the path.
  • A test where a file is removed after the registry listed it checks that read_file and grep errors name only the relative path.

Getting started

  • Relevant files: internal/agent/tools/tools.go, internal/walk/walk.go, internal/agent/tools/tools_test.go
  • How to run tests: go test ./internal/agent/tools ./internal/walk
  • Related docs: docs/PRIVACY.md

Filed by repo-audit/full-audit at fffef43. Severity: low. Effort: S. audit-key: privacy|internal/agent/tools/tools.go|pathError

Linguagem predominante
Go
Estrelas
0
Forks
1
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de TMHSDigital/Spackle

Todas as issues de TMHSDigital/Spackle

Issues semelhantes

Mais issues de Go

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.