Heap-Based Buffer Overflow in Sudo Package: CVE-2021-3156

sudo Updated 02 Oct 2025

Summary

26/01/2021
N/A
Yes i
High
7.8

ALPINE-CVE-2021-3156: Sudo before 1.9.5p2 contains an off-by-one error that can result in a heap-based buffer overflow, which allows privilege escalation to root via "sudoedit -s" and a command-line argument that ends with a single backslash... Affects sudo versions < 1.9.5p2-r0. Fixed in 1.9.5p2-r0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Sudo is a widely used program that allows users to run commands with the security privileges of another user, typically the superuser. It is an essential tool in Unix-like operating systems, providing a mechanism for granting limited administrative access to users. The vulnerability in question affects various versions of the Sudo package across multiple Alpine Linux releases, making it critical for system administrators to address.

Vulnerability Detail

The vulnerability, identified as CVE-2021-3156, is an off-by-one error in Sudo versions prior to 1.9.5p2. This flaw can lead to a heap-based buffer overflow, which may allow an attacker to escalate privileges to root. The issue arises when using the 'sudoedit -s' command with a command-line argument that ends with a single backslash character. This can potentially compromise the security of the system, allowing unauthorized access and control.

How To Fix

Minimum fixed version

1.9.5p2-r0

This is the first release that contains the fix.

sudo apk add --upgrade sudo

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, users can avoid using the 'sudoedit -s' command with arguments that end with a backslash until the package is updated. This can help mitigate the risk of exploitation while waiting for a patch.

Conclusion

CVE-2021-3156 is a critical vulnerability in the Sudo package that can lead to serious security risks if not addressed. It is crucial for users to update their Sudo installations to the patched versions to protect their systems from potential exploitation.

See every vulnerability recorded for sudo →

Share this vulnerability

FAQ

CVE-2021-3156 is a vulnerability in the Sudo package that can lead to a heap-based buffer overflow, allowing privilege escalation to root.

Sudo versions prior to 1.9.5p2 and 1.8.31-r1 for Alpine Linux are affected by this vulnerability.

You can use the Vulert platform to monitor and alert for open-source vulnerabilities in your software. Visit Vulert Scanner to check if your application is affected.

The CVSS score for CVE-2021-3156 is 7.8, indicating a high severity level.

If an immediate update is not possible, avoid using the 'sudoedit -s' command with backslash arguments as a temporary workaround.

Related vulnerabilities

Recent vulnerabilities recorded for sudo.

How To Fix

Minimum fixed version

1.9.5p2-r0

This is the first release that contains the fix.

sudo apk add --upgrade sudo

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback