🛡️ Sentinel: [CRITICAL] Fix Path Truncation Vulnerability#3488
🛡️ Sentinel: [CRITICAL] Fix Path Truncation Vulnerability#3488EffortlessSteven wants to merge 2 commits intomainfrom
Conversation
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request addresses a path truncation vulnerability by implementing a null byte check in the model path validation and documenting the vulnerability in the sentinel log. A review comment suggests broadening this check to include all control characters using char::is_control for improved security and to prevent issues like log injection.
|
|
||
| // Prevent path traversal attacks | ||
| if model_path.contains("..") || model_path.contains("~") { | ||
| if model_path.contains("..") || model_path.contains("~") || model_path.contains('\0') { |
There was a problem hiding this comment.
While blocking null bytes (\0) is critical to prevent path truncation and extension bypass when interacting with C APIs, it is a security best practice to reject all control characters in user-provided file paths. This broader check helps prevent other potential issues, such as log injection or unexpected behavior in downstream processing. Consider using char::is_control to catch all such characters.
| if model_path.contains("..") || model_path.contains("~") || model_path.contains('\0') { | |
| if model_path.contains("..") || model_path.contains("~") || model_path.contains(char::is_control) { |
🚨 Severity: CRITICAL
💡 Vulnerability: The
validate_model_requestfunction validated file extensions (like.gguf) using string operations but failed to check for null bytes (\0). This could allow attackers to bypass extension validation by appending a null byte followed by the required extension, causing underlying C APIs to load arbitrary files.🎯 Impact: Attackers could potentially bypass file extension checks and load arbitrary files on the filesystem, leading to potential data exposure or code execution.
🔧 Fix: Added an explicit check for null bytes (
\0) in themodel_pathduring validation.✅ Verification: Ran
cargo test -p bitnet-server --lib security::tests::andcargo clippy -p bitnet-server -- -D warnings. Both passed.PR created automatically by Jules for task 830514392079978534 started by @EffortlessSteven