π‘οΈ Sentinel: [CRITICAL] Fix Path Truncation Vulnerability in Model Path Validation#3516
π‘οΈ Sentinel: [CRITICAL] Fix Path Truncation Vulnerability in Model Path Validation#3516EffortlessSteven wants to merge 1 commit 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. |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
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 |
π¨ Severity
CRITICAL
π‘ Vulnerability
The
validate_model_requestfunction inbitnet-server/src/security.rsdid not validate if the provided model path contains null bytes (\0). When these paths are passed to underlying C libraries (like llama.cpp) or OS filesystem APIs, the string is truncated at the null byte. This allows attackers to bypass validation checks (e.g., extension checks like.gguf) by appending a null byte followed by the required extension, while the underlying system operates on the truncated path.π― Impact
An attacker could bypass the
model_path.ends_with(".gguf")validation by supplying a path like/etc/passwd\0.gguf. The validation logic in Rust sees a valid path ending in.gguf, but the underlying C/OS layer truncates it at the null byte, resulting in unauthorized file access to/etc/passwd.π§ Fix
Added a check in
validate_model_requestto explicitly reject any model path containing a null byte (\0), returning anInvalidFieldValueerror. Also added a unit testtest_model_path_null_byte_rejectionto ensure this behavior is correct.β Verification
cargo fmt --allcargo clippy -p bitnet-server -- -D warningscargo test -p bitnet-server --lib security::tests::test_model_path_null_byte_rejectionPR created automatically by Jules for task 14837676839331371447 started by @EffortlessSteven