Rhai is unsound (use after free)
Open
Nobody has claimed this yet.
bug
- Dominant language
- Rust
- Stars
- 5.7k
- Forks
- 249
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 23
Description
Consider the following example:
fn main() {
let global_name: std::rc::Rc<std::cell::RefCell<&'static str>> = Default::default();
let global_name2 = global_name.clone();
{
let mut engine = rhai::Engine::new();
engine.register_fn("hello", move |name: &'static str| {
*global_name.borrow_mut() = name;
});
engine.eval::<()>(r#"hello("some name")"#).unwrap();
}
println!("{:?}", &*global_name2.borrow());
}
rhai v1.19.0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file, test, or entry point is named. Start by reproducing the provided Rust example against rhai v1.19.0, then trace how Engine::register_fn handles the captured callback and the 'static str argument. Done means the example no longer permits use-after-free, with a regression test covering the reported case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- security
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100