Skip to content

security: add centralized daemon ID validation#140

Merged
jdx merged 1 commit intomainfrom
security/daemon-id-validation
Jan 19, 2026
Merged

security: add centralized daemon ID validation#140
jdx merged 1 commit intomainfrom
security/daemon-id-validation

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Jan 19, 2026

Summary

  • Adds centralized daemon ID validation to prevent path traversal attacks
  • Consolidates duplicate validation logic from web routes into shared function
  • Validates IDs at the IPC layer before processing requests
  • Includes comprehensive unit tests

Changes

  • src/daemon.rs: New is_valid_daemon_id() and validate_daemon_id() functions with tests
  • src/web/routes/logs.rs: Uses shared validation function
  • src/web/routes/daemons.rs: Uses shared validation function
  • src/supervisor.rs: Validates daemon IDs in Stop, Run, Enable, Disable IPC handlers

Security Impact

Daemon IDs are used to construct log file paths and state file entries. Without validation, a malicious ID like ../etc/passwd could cause path traversal. This change ensures all daemon IDs are validated at API boundaries.

Valid daemon IDs

  • Not empty
  • No path separators (/ or \)
  • No .. (parent directory)
  • No spaces
  • Not . (current directory)
  • Only printable ASCII characters

Test plan

  • Unit tests pass: cargo test daemon::tests
  • Daemon start with valid ID works
  • Daemon start with invalid ID (e.g., foo/bar) returns error
  • Web UI rejects invalid daemon IDs

🤖 Generated with Claude Code


Note

Strengthens input validation and removes duplicate logic by centralizing daemon ID checks.

  • Adds is_valid_daemon_id and validate_daemon_id in src/daemon.rs with comprehensive tests
  • Enforces validation in src/supervisor.rs for Stop, Run, Enable, and Disable IPC handlers (returns IpcResponse::Error on invalid IDs)
  • Refactors src/web/routes/daemons.rs and src/web/routes/logs.rs to use shared validation, removing local validators
  • Minor dependency update in Cargo.lock (adds libc)

Written by Cursor Bugbot for commit 942ecda. This will update automatically on new commits. Configure here.

Adds validation for daemon IDs to prevent path traversal attacks when IDs
are used to construct file paths (logs, state files, etc.).

Changes:
- Add is_valid_daemon_id() and validate_daemon_id() functions to daemon.rs
- Update web routes (logs.rs, daemons.rs) to use shared validation
- Add validation to IPC handlers (Stop, Run, Enable, Disable requests)
- Add comprehensive unit tests for validation

A valid daemon ID:
- Is not empty
- Does not contain path separators (/ or \)
- Does not contain parent directory references (..)
- Does not contain spaces
- Is not "." (current directory)
- Contains only printable ASCII characters

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jdx jdx merged commit 647175a into main Jan 19, 2026
4 checks passed
@jdx jdx deleted the security/daemon-id-validation branch January 19, 2026 03:43
@jdx jdx mentioned this pull request Jan 19, 2026
jdx added a commit that referenced this pull request Jan 19, 2026
## 🤖 New release

* `pitchfork-cli`: 0.3.0 -> 0.3.1

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.3.1](v0.3.0...v0.3.1) -
2026-01-19

### Added

- implement daemon dependency resolution
([#135](#135))
- add restart command to CLI
([#134](#134))

### Fixed

- restart command preserves daemon dependency configuration
([#142](#142))
- add missing depends field to restart command
([#136](#136))
- set IPC socket permissions to 0600 for security
([#133](#133))
- handle shell command parsing errors instead of silently failing
([#132](#132))

### Other

- reduce unnecessary daemon cloning in loops
([#144](#144))
- use periodic log flushing instead of per-line
([#139](#139))
- refresh only tracked PIDs instead of all processes
([#141](#141))
- cache compiled regex patterns
([#143](#143))

### Security

- add rate limiting to IPC server
([#137](#137))
- canonicalize config paths to prevent symlink exploitation
([#138](#138))
- add centralized daemon ID validation
([#140](#140))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Prepares the 0.3.1 release and updates metadata/documentation
accordingly.
> 
> - **Changelog**: Adds `0.3.1` entry detailing added dependency
resolution, new `restart` command, fixes, performance tweaks, and
security hardening
> - **Version bumps**: Updates `version` to `0.3.1` in `Cargo.toml`,
`Cargo.lock`, `docs/cli/commands.json`, `docs/cli/index.md`, and
`pitchfork.usage.kdl`
> - **Docs regen**: Refreshes CLI docs/spec to reflect the new version
(no behavioral changes in this diff)
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9f9d386. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@jdx jdx mentioned this pull request Jan 19, 2026
jdx added a commit that referenced this pull request Jan 19, 2026
## 🤖 New release

* `pitchfork-cli`: 1.0.0

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [1.0.0](https://github.com/jdx/pitchfork/releases/tag/v1.0.0) -
2026-01-19

### Added

- implement daemon dependency resolution
([#135](#135))
- add restart command to CLI
([#134](#134))

### Fixed

- restart command preserves daemon dependency configuration
([#142](#142))
- add missing depends field to restart command
([#136](#136))
- set IPC socket permissions to 0600 for security
([#133](#133))
- handle shell command parsing errors instead of silently failing
([#132](#132))

### Other

- bump version to 1.0.0
([#147](#147))
- release v0.3.1 ([#121](#121))
- reduce unnecessary daemon cloning in loops
([#144](#144))
- use periodic log flushing instead of per-line
([#139](#139))
- refresh only tracked PIDs instead of all processes
([#141](#141))
- cache compiled regex patterns
([#143](#143))

### Security

- add rate limiting to IPC server
([#137](#137))
- canonicalize config paths to prevent symlink exploitation
([#138](#138))
- add centralized daemon ID validation
([#140](#140))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Prepares the 1.0.0 release and updates `CHANGELOG.md` with the
finalized notes.
> 
> - Adds `1.0.0` section: daemon dependency resolution, new CLI
`restart` command, fixes for dependency preservation and shell parsing,
secure IPC socket perms, plus performance/maintenance updates
> - Documents security hardening: IPC rate limiting, config path
canonicalization, centralized daemon ID validation
> - Retains prior `0.3.1` notes for historical context
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
4182984. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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