Skip to content

Security: fix remote file write and shell injection in template extensions#2107

Open
johnpippett wants to merge 2 commits into
danielmiessler:mainfrom
johnpippett:security/critical-fixes-2026-04-28
Open

Security: fix remote file write and shell injection in template extensions#2107
johnpippett wants to merge 2 commits into
danielmiessler:mainfrom
johnpippett:security/critical-fixes-2026-04-28

Conversation

@johnpippett
Copy link
Copy Markdown

Fixes two critical security findings:

  1. **Remote arbitrary file write via **: Added guard so file changes are only auto-applied in CLI mode, not via REST API. Hardened path containment checks in using + .
  2. Arbitrary shell execution via template extensions: Replaced with direct command execution using , eliminating command injection.

Changes are minimal and backward-compatible.

…attern

- internal/core/chatter.go: disable auto-application of file changes in API
  mode (opts.UpdateChan != nil). The REST API accepts PatternName from the
  JSON body; allowing unsupervised file writes via the API is a remote
  arbitrary file write vulnerability.

- internal/domain/file_manager.go: replace weak strings.Contains(path, "..")
  defense with proper path containment checks. Reject absolute paths and
  verify the resolved path is within the project root using filepath.Clean
  and prefix matching.
Switch from strings.HasPrefix to filepath.Rel for verifying that the
resolved target path stays within the project root. This correctly
handles edge cases such as a project root of '/' and is more idiomatic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant