AI-written Rust gets a verification test on AppArmor

Canonical is funding researchers at the University of Bristol to find out whether language models can turn production C into safe, maintainable Rust without changing what the software does. They are testing it on two security-critical parts of Ubuntu: AppArmor, which confines applications, and snap-confine, which builds the sandboxed environments snaps run in.
Canonical isn’t planning to rewrite either component in Rust any time soon, The New Stack reported on August 19. The project is meant to establish what evidence maintainers would need before they trusted an automated translation of code that ships in production. That reverses the usual pitch for AI code tools. Getting a model to write a lot of Rust is treated as the easy part. Showing that the output does exactly what the C did is the actual research question.
How the pipeline checks its own output
The proposed system has three stages. A language model writes the Rust. A verification stage then compares the new implementation with the original C. When the two disagree, a repair stage fixes the generated code.
The comparison carries the most weight, because generated Rust can compile cleanly and still behave differently from the C it replaces. Ordinary test suites only catch the differences someone thought to write a test for. So the Bristol team plans to combine fuzzing, which hammers both programs with large volumes of generated inputs and watches for diverging results, with formal program analysis, which reasons about the code’s behaviour directly. Between them, the two methods are supposed to surface mismatches that conventional tests may miss.
Once a mismatch turns up, symbolic repair takes over: it diagnoses the exact failure and fixes the code directly. That feedback is also how the project expects to tackle its second problem, translations that lean too heavily on unsafe Rust.
The unsafe shortcut
Rust’s unsafe blocks allow operations that safe Rust forbids, including some kinds of raw pointer manipulation. For a translator, they are a way to carry difficult C constructs across while staying close to the original. But relying on them too heavily brings back many of the memory-safety risks the port was supposed to remove, and risks carrying the same bugs into the Rust code.
Idiomatic Rust usually means more than new syntax. Data structures and lifetimes (the compiler’s rules for how long a reference stays valid) often have to change across several functions or whole modules. So the target is narrow: Rust safe enough to deliver the language’s benefits and close enough in behaviour to the C that maintainers can trust it. Rewriting in Rust can eliminate whole classes of vulnerabilities, such as use-after-free bugs and buffer overflows. An automated translator can still introduce a logic error, though.
Why AppArmor and snap-confine
AppArmor is a Linux security module that restricts what applications can access according to defined policies. Its userspace tooling, written in a mix of C, Python and C++, has to parse, compile and load those policies correctly. A Rust port that interprets a policy differently from the existing implementation could compile perfectly and still be wrong, and here mistakes in the translation could have security consequences.
Snap-confine poses a related problem. It helps set up the execution environment and confinement used by snaps, so the Bristol team has to show that the translated version behaves like the original C there too. Beyond these two programs, Canonical wants to know whether the approach scales to entire repositories with hundreds of thousands of lines of C.
Canonical has been here
Canonical has recent first-hand experience of the gap this project targets. Starting with Ubuntu 25.10, it replaced GNU Coreutils with uutils Coreutils and sudo with sudo-rs, Rust implementations meant as drop-in replacements. Because of known incompatibilities, Ubuntu’s own documentation shows some commands kept on the GNU versions: chmod, chown, cp, df, mv, rm and true in 25.10, then cp, df, mv, rm and true in 26.04 LTS.
The holdouts had concrete causes. Canonical kept cp, mv and rm on GNU in 26.04 because of TOCTOU issues found in an audit, It’s FOSS reported. TOCTOU (time-of-check to time-of-use) bugs are race conditions where a file changes between the moment it is checked and the moment it is used. Canonical had commissioned two audit rounds from Zellic between December 2025 and March 2026, which together raised 113 issues, 44 of them assigned CVEs; Canonical says the vast majority have been resolved. Then in July, the uutils cp went back into the Ubuntu archive and came straight out again after it broke live image builds, with the fix going upstream.
That episode matches the Bristol problem statement closely: Rust code that built and still did something different from the tool it replaced. The uutils project treats any divergence from GNU as a bug.
Later, Ubuntu 26.10 finished the coreutils migration, moving its last holdouts, cp, mv and rm, from GNU Coreutils to uutils.
Up next
One-click GitHub import lands in AI Studio Build, Video
One click pulls an existing GitHub repo into Google AI Studio Build, and the connection holds after the import. Edits then sync both ways between the repo and the app, per Google’s AI Studio channels.
Related stories
- Bun’s half-million lines of Zig became Rust in eleven days
- OpenAI opens internal models to four outside safety labs
- Frontier Model Forum rates cyber jailbreaks on four scores
- A perfect refusal score isn’t a safer model, Anthropic says
- Anthropic touts 94.2% true positives; curl rejected 19 of 34
- OpenAI can halt any research job’s output within 35 seconds
Comments
No comments yet. Be the first.
Join the conversation
Sign in to leave a comment. It appears after moderation.

