Skip to content

πŸ›‘οΈ Sentinel: [CRITICAL] Fix path traversal in snapshot commands#39

Open
bitcoiner-dev wants to merge 1 commit into
masterfrom
sentinel/fix-snapshot-path-traversal-12040537447863696327
Open

πŸ›‘οΈ Sentinel: [CRITICAL] Fix path traversal in snapshot commands#39
bitcoiner-dev wants to merge 1 commit into
masterfrom
sentinel/fix-snapshot-path-traversal-12040537447863696327

Conversation

@bitcoiner-dev
Copy link
Copy Markdown
Owner

🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: Path Traversal in the Snapshot commands. The application was interpolating a user-supplied string (name) directly into snap_dir.join(format!("{name}.json")). Without validation, passing absolute paths (e.g. /etc/passwd) or relative upward traversals (e.g. ../../../some-file) caused Path::join to escape the intended snap_dir boundary. This permitted arbitrary file read (during Restore) and arbitrary file overwrite (during Save) with application permissions.
🎯 Impact: An attacker could craft a malicious payload (via the CLI argument for a snapshot name) to either read out arbitrary file data (exposing sensitive files like configurations or key material) or overwrite files on the system, leading to privilege escalation or complete system compromise in automated environments.
πŸ”§ Fix: Implemented validate_file_name in src/utils.rs which applies a strict allowlist constraint on file name parts (alphanumeric, -, and _). Intercepted user input in SnapshotAction::Save and SnapshotAction::Restore and applied this validation prior to path joining. Added rigorous unit tests.
βœ… Verification: Run cargo test --bin zinc-cli to ensure the validation logic correctly rejects inputs containing ../ or / separators, and ensures existing Save and Restore operations remain fully functional.


PR created automatically by Jules for task 12040537447863696327 started by @bitcoiner-dev

Implemented a `validate_file_name` function to restrict user-supplied snapshot names strictly to alphanumeric characters, dashes, and underscores. Applied this validation to the Save and Restore commands in `src/commands/snapshot.rs` to ensure input values cannot manipulate `PathBuf::join` via relative or absolute path structures (`../` or `/`), closing a critical arbitrary file write/read vulnerability.

Co-authored-by: bitcoiner-dev <75873427+bitcoiner-dev@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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