Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is Sudo Baron Samedit?

Baron Samedit (CVE-2021-3156) is a heap overflow in sudo that let any local user on an unpatched Linux or macOS system become root, and it had been present for almost ten years.

Illustration for the cybersecurity term Sudo Baron Samedit
Home / Blog / Cybersecurity Terms / What Is Sudo Baron Samedit?
17 November 2026

What Is Sudo Baron Samedit?

What Is Sudo Baron Samedit?

Baron Samedit is the name Qualys gave to CVE-2021-3156, a heap buffer overflow in sudo that they disclosed on 26 January 2021. Any unprivileged local user could exploit it to obtain full root privileges, with no password and no entry in the sudoers file required. The bug had been introduced in July 2011 and shipped in every release for nearly a decade.

Because sudo is installed almost everywhere a Unix-like system runs, the advisory turned into one of the larger emergency patching exercises of that year, touching Linux distributions, macOS, and a long list of appliances with sudo embedded in their firmware.

A Parsing Bug in Shell Mode

When sudo is invoked with -s or -i, it runs the requested command through a shell. To make that work safely, sudo escapes shell metacharacters in the arguments with backslashes before building the command line, and the function that later consumes that string, set_cmnd(), removes the escaping again.

The two halves disagreed about one case. A command line ending in a single unescaped backslash made the unescaping loop read past the end of the buffer, because it consumed the backslash and then the terminating null byte as the character being escaped, and kept going. The result was a heap overflow with attacker-controlled contents and attacker-controlled length.

Crucially, the escaping step was skipped in sudoedit mode while the unescaping step still ran, which is how an attacker could place that trailing backslash in the first place. Three separate heap-based exploitation strategies were published, targeting the service user struct, the def_timestampdir structure, and the sudoers nss entry, giving reliable root on mainstream distributions.

Affected Versions and the One-Line Test

The flaw affected all legacy versions from 1.8.2 to 1.8.31p2 and all stable versions from 1.9.0 to 1.9.5p1. The fix shipped in sudo 1.9.5p1, and distributions backported it to their own packages within days.

Qualys published a safe check that does not attempt exploitation. As any user, run:

sudoedit -s /

A patched system answers with usage: or sudoedit: /: not a regular file. A vulnerable system answers with a segmentation fault. The same bug was later confirmed on macOS Big Sur, where sudo -s rather than sudoedit was the trigger, and Apple patched it in the 11.2.1 security update.

Why Local Privilege Escalation Matters

It is tempting to rank a local flaw below a remote one. In practice, attacks arrive in stages. An attacker who lands a low-privileged shell through a vulnerable web application, a leaked SSH key, or a compromised CI runner needs exactly this kind of bug to turn that foothold into control of the host.

Baron Samedit was particularly convenient for that because it needed no sudo rights at all. A service account such as www-data, deliberately excluded from sudoers, could still use it. That also made it attractive for container escape attempts where sudo was present in the image, and for attacks on shared build servers.

Sudo has produced other serious flaws in the same family, including CVE-2019-14287, where a user permitted to run a command as any user except root could pass the user ID -1 and get root anyway, and CVE-2023-22809, which allowed editing arbitrary files through the EDITOR variable in sudoedit. The pattern is consistent: a small parsing or validation gap in a tool that grants root by design.

Reducing Exposure

The NCSC’s guidance on patch management treats a known-exploited local escalation as urgent precisely because it shortens every intrusion that follows. Our Infrastructure Security Testing Services check for this class of issue across your Linux estate, including the hosts that configuration management has quietly stopped reaching.

FAQ – Frequently Asked Questions

Why Is It Called Baron Samedit?

Qualys named it after Baron Samedi, a figure from Haitian Vodou associated with the dead, with the spelling adjusted to include the sudoedit command that triggers the bug. Vulnerability nicknames exist mainly to make coordination easier during disclosure; the authoritative identifier is CVE-2021-3156, which you should use when searching vendor advisories and patch notes.

Did the Attacker Need to Be in the Sudoers File?

No, and that is what made the flaw unusually dangerous. Exploitation happens during argument parsing, before sudo checks whether the user is authorised to run anything. Any local account, including service accounts such as www-data or a user created by a compromised application, could obtain root on an unpatched system without a password or a sudoers entry.

How Do I Check Whether a System Is Still Vulnerable?

Run sudoedit -s / as any user. A patched system prints a usage message or reports that the path is not a regular file. A vulnerable system produces a segmentation fault. Checking sudo –version alone can mislead because distributions backport fixes without changing the upstream version number, so the behavioural test is more reliable.

Does macOS Have the Same Problem?

Yes. Researchers confirmed exploitation on macOS Big Sur using sudo -s rather than sudoedit, because macOS ships its own build of the same vulnerable code. Apple addressed it in the macOS 11.2.1, Catalina, and Mojave security updates released in February 2021. Any Mac that has not received security updates since then should be considered exposed.

Related Terms

You May Be Interested In These

What Is OpenVAS?

Cybersecurity Terms

17 November 2026

What Is OpenVAS?

Read More
What Is a Secure Element?

Cybersecurity Terms

17 November 2026

What Is a Secure Element?

Read More
What Is the Threat Intelligence Lifecycle?

Cybersecurity Terms

17 November 2026

What Is the Threat Intelligence Lifecycle?

Read More