Skip to content

🛡️ Sentinel: [CRITICAL] Restrict shell_execute to allowed commands - #35

Closed
JustinWoodring wants to merge 1 commit into
mainfrom
sentinel-shell-execute-fix-15446079692671839145
Closed

🛡️ Sentinel: [CRITICAL] Restrict shell_execute to allowed commands#35
JustinWoodring wants to merge 1 commit into
mainfrom
sentinel-shell-execute-fix-15446079692671839145

Conversation

@JustinWoodring

Copy link
Copy Markdown
Owner

This PR addresses a critical security vulnerability in slatron-server's Rhai scripting engine. Previously, the shell_execute function allowed execution of arbitrary shell commands. This change introduces:

  1. Allowlist Enforcement: shell_execute is now restricted to a predefined list of safe commands: yt-dlp, ffmpeg, and ffprobe.
  2. Argument Sanitization: For yt-dlp, the --exec argument is explicitly blocked to prevent command injection/bypass.
  3. Security Tests: New tests in src/rhai_engine/security_test.rs verify that unauthorized commands (like ls) and dangerous arguments are correctly rejected with a "Security Alert".

This change prevents RCE via malicious or compromised scripts.


PR created automatically by Jules for task 15446079692671839145 started by @JustinWoodring

- Implements an allowlist for `shell_execute` in `slatron-server` (only `yt-dlp`, `ffmpeg`, `ffprobe` allowed).
- Blocks potentially dangerous `--exec` argument for `yt-dlp` to prevent RCE.
- Adds regression tests in `src/rhai_engine/security_test.rs` to verify blocked commands and arguments.

This addresses a critical vulnerability where arbitrary shell commands could be executed via Rhai scripts.

Co-authored-by: JustinWoodring <41842051+JustinWoodring@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.

@claude

claude Bot commented Feb 3, 2026

Copy link
Copy Markdown

Code Review

Good security improvement overall! This PR successfully restricts shell_execute from allowing arbitrary commands to a small allowlist. However, I found one security concern that should be addressed:

Security Issue: Incomplete argument restrictions for ffmpeg

Location:

// Security Check: Block dangerous args for specific commands
if cmd == "yt-dlp" {
for arg in &args {
let s = arg.to_string();
if s.starts_with("--exec") {
let err_msg = format!(
"Security Alert: Argument '{}' is blocked for command '{}'.",
s, cmd
);
tracing::error!("{}", err_msg);
let mut map = rhai::Map::new();
map.insert("code".into(), (-1 as i64).into());
map.insert("stdout".into(), "".into());
map.insert("stderr".into(), err_msg.into());
return map;
}
}
}

While the PR correctly blocks --exec for yt-dlp, ffmpeg and ffprobe are allowed without argument restrictions. This creates a security bypass opportunity.

Malicious content_loader scripts could exploit ffmpeg to overwrite arbitrary files and achieve code execution. For example, downloading malicious content from a remote URL and writing it to shell config files.

Context:
This doesn't block the PR since it's still a net security improvement over the previous state where ANY command could be executed. However, ffmpeg has many dangerous capabilities including arbitrary file I/O and network access that should be restricted.

Recommendation:
Add argument restrictions for ffmpeg/ffprobe similar to yt-dlp, such as blocking the -y flag, restricting output paths to safe directories, and validating remote URL inputs.

Otherwise, excellent work on the security hardening and comprehensive test coverage!

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