fix(cli): validate cluster machine id and labels before they reach the remote shell - #2861
fix(cli): validate cluster machine id and labels before they reach the remote shell#2861phil-opp wants to merge 1 commit into
Conversation
…e remote shell
`dora cluster up` interpolates each `machine.id` and every label
key/value verbatim into the command it runs over SSH:
nohup dora daemon --machine-id {id} --labels {k}={v},... \
> /tmp/dora-daemon-{id}.log 2>&1 &
`ClusterConfig::validate()` only checked that the id was non-empty and
unique, so a value containing whitespace or shell metacharacters would
corrupt that command and the log path — e.g. `id: "a b"` word-splits the
arguments, and a label value like `x;rm -rf /` (or a `$(...)`/backtick
in the id) executes arbitrary commands on the remote host.
Restrict `machine.id` and every label key/value to the same safe
identifier charset dora already enforces for node and data ids
(`[a-zA-Z0-9_.-]`, see `libraries/message/src/id.rs`) via a shared
`validate_shell_safe` helper. `host`/`user` are deliberately left
unrestricted: they are network addresses that legitimately carry other
characters (e.g. IPv6 literals) and are folded into the ssh *target*,
not the remote command string. Hostname-style ids and normal labels
(`jetson-01`, `gpu=true`, `arch=arm64`) remain valid. Adds tests for a
rejected id, a rejected label value, and the accepted cases.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0142J7B2578ixrh77kNDNJry
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
Automated review by Claude — this is a fully automated review; no human has vetted it. No issues found. Restricting Generated by Claude Code |
|
🤖 Automated review by Claude — this review is fully automated and has not been vetted by a human. The
Minor, pre-existing and out of scope for this PR: Generated by Claude Code |
Issue
dora cluster upinterpolates eachmachine.idand every label key/value verbatim into the command it runs over SSH (binaries/cli/src/command/cluster/up.rs, viaformat_labels_arginmod.rs):ClusterConfig::validate()only checked that the id was non-empty and unique, so a value containing whitespace or shell metacharacters would corrupt that command and the log path:id: "a b"word-splits the daemon arguments.gpu: "x;rm -rf /"— or a$(...)/backtick in the id — executes arbitrary commands on the remote host.The
cluster.ymlis operator-authored, so this is a robustness / footgun issue rather than a remote-exploit path, but a malformed value fails confusingly (or dangerously) instead of being rejected up front.Fix
Restrict
machine.idand every label key/value to the same safe identifier charset dora already enforces for node and data ids —[a-zA-Z0-9_.-](seelibraries/message/src/id.rs) — via a sharedvalidate_shell_safehelper called fromvalidate().host/userare deliberately left unrestricted: they are network addresses that legitimately carry characters outside this set (e.g. IPv6 literals) and are folded into the ssh target rather than the remote command string. Hostname-style ids and normal labels (jetson-01,gpu=true,arch=arm64) remain valid.Validation
cluster::configtests still pass (16 total).cargo test -p dora-cli,cargo clippy -p dora-cli --all-targets -- -D warnings, andcargo fmt --all -- --checkall pass.🤖 This is a machine-generated pull request opened by Claude Code. A human maintainer should review before merging.
🤖 Generated with Claude Code
https://claude.ai/code/session_0142J7B2578ixrh77kNDNJry
Generated by Claude Code