Skip to content

fix: block task run in sensitive directories#14

Merged
marcus merged 1 commit intomarcus:mainfrom
davemac:fix/guard-sensitive-paths
Feb 17, 2026
Merged

fix: block task run in sensitive directories#14
marcus merged 1 commit intomarcus:mainfrom
davemac:fix/guard-sensitive-paths

Conversation

@davemac
Copy link
Contributor

@davemac davemac commented Feb 15, 2026

Summary

  • Adds ValidateProjectPath() to the security package that blocks execution when the resolved project path is a home directory ($HOME), filesystem root (/), or other sensitive system path (/tmp, /var, /etc, /usr)
  • Calls the validation in task run after resolving the project path, before any agent execution
  • Includes tests covering all blocked paths and valid project subdirectories

Context

nightshift task run uses os.Getwd() when -p is not specified. If a user runs the command from their home directory, the AI agent scans the entire home directory — including credentials, SSH keys, and unrelated projects — with dangerous permission flags enabled.

See #13 for the full write-up.

Test plan

  • go test ./internal/security/ -v — all 42 tests pass including 6 new path validation tests
  • go build ./cmd/nightshift/ — compiles cleanly
  • Manual: run cd ~ && nightshift task run lint-fix --provider claude and confirm it is refused
  • Manual: run cd ~/Sites/my-project && nightshift task run lint-fix --provider claude and confirm it proceeds

🤖 Generated with Claude Code

Adds ValidateProjectPath to the security package which refuses to run
when the resolved project path is a home directory, filesystem root,
or other sensitive system path. This prevents accidental exposure of
credentials and private data when agents run with dangerous permission
flags.

Closes marcus#13

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Owner

@marcus marcus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean safety fix. ValidateProjectPath logic is sound — exact-match blocking on sensitive directories, good test coverage, clear error message guiding users to -p. LGTM. — Shrike

@marcus marcus merged commit f070c93 into marcus:main Feb 17, 2026
@marcus
Copy link
Owner

marcus commented Feb 17, 2026

Thanks for this, @davemac! Clean fix, great test coverage. This shipped in v0.3.2 🚀

— Kestrel (AI assistant on the project)

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.

2 participants