Skip to main content
Mallory
CriticalExploited in the wildCISA KEVPublic exploitVulnerability

CVE-2021-20038: Unauthenticated RCE in SonicWall SMA 100 mod_cgi

Published Dec 8, 2021 · Updated 1 month ago
Trending this weekNot trendingOutside this week’s top 100
Mention activity · 30 daysNo mention activity in the last 30 days.
CVSS9.8Critical · v3.1
EPSS99.9%100th percentile
CISA KEVYesAdded Jan 28, 2022
In the wildActivePer CISA KEV
Vendor
Sonicwall
IdentifiersCVE-2021-20038CWE-121 · Stack-based Buffer Overflow

CVE-2021-20038 is a stack-based buffer overflow in the Apache httpd mod_cgi environment-variable handling of SonicWall SMA 100 series appliances. During HTTP GET processing, the vulnerable code uses strcat to concatenate environment-variable data into a single stack buffer. A remote unauthenticated attacker can potentially exploit the overflow to execute code as the low-privilege nobody user. Affected models are SMA 200, 210, 400, 410, and 500v, running firmware 10.2.0.8-37sv, 10.2.1.1-19sv, 10.2.1.2-24sv, and earlier versions.

Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Analyst brief

Impact, mitigation & remediation

What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.

Impact

What an attacker gets, and what they’ve been doing with it.

Successful exploitation can provide remote code execution under the appliance's nobody account, potentially enabling malware installation and control of the affected appliance within that account's permissions. Exploitation has been observed in the wild, including use by DPRK actors for initial access. This vulnerability alone does not establish root-level execution.

Mitigation

If you can’t patch tonight, do this now.

The appliance's web application firewall does not prevent exposure to this vulnerability and is not a substitute for patching. Least-privilege access and multilayer network segmentation can reduce post-compromise impact, but no vulnerability-specific non-patching workaround is established.

Remediation

Patch, then assume compromise.

Upgrade affected appliances to firmware 10.2.0.9-41sv or 10.2.1.3-27sv, or a later applicable vendor release. Review installed firmware and apply the latest supported SonicWall update immediately.

Public exploits

Exploits

2 exploits validated by Mallory's analysis.

View more in app →
sonicwall-audit-toolkitRepository purpose: a Python-based SonicWall “Security Audit Toolkit” plus a Docker CTF-style lab that simulates and (in solutions) exploits two critical SonicWall CVEs. Top-level structure: - sonicwall_audit.py: main orchestrator CLI that runs modules (ssl, cve, auth, web) against a target https://<host>:<port>, writes JSON/text reports to reports/. - validate_cves.py: standalone deep validators for CVE-2021-20038 and CVE-2024-53704 using non-destructive behavioral checks. - modules/: implementation of auditors/validators and report generation. - lab/: docker-compose lab with two containers: - cve-2021-20038: Apache + deliberately vulnerable 32-bit CGI binary /usr/lib/cgi-bin/sslvpnclient (and symlinks portal/welcome/etc). Protections disabled (no canary, execstack, no PIE, ASLR disabled in entrypoint) to make stack overflow exploitation feasible. - cve-2024-53704: Flask/Gunicorn SSLVPN simulator on 4433 with vulnerable swap cookie deserialization (conditional HMAC verification). - lab/exploits/: skeleton exploit templates (incomplete). - lab/solutions/: working exploits. Exploit capabilities present: 1) CVE-2024-53704 (auth bypass via cookie forgery): Working exploit forges a base64-encoded JSON session cookie named swap with {username, authenticated:true} and omits sig_version so the server skips HMAC verification. It then accesses /virtual-office/ and /dashboard to retrieve the flag. 2) CVE-2021-20038 (stack buffer overflow -> RCE): Working exploit crafts a URL-encoded query string payload to overflow a 4096-byte stack buffer in the CGI handler (strcpy of QUERY_STRING). Payload includes a NOP sled, null-free 32-bit x86 Linux shellcode that runs /bin//sh -c "cat /root/flag.txt", padding to offset 4100, and an attacker-chosen return address into the sled. Output is returned in the HTTP response body. Important distinction: the main toolkit modules and CVE validators are primarily scanners/validators and explicitly avoid destructive exploitation; the actual exploitation code is confined to the lab solution scripts intended for the local practice environment.anir0y · Disclosed Feb 23, 2026 · python · c · network · local (docker lab)WeaponizedbadbloodThis repository contains an exploit for CVE-2021-20038, a stack-based buffer overflow in the httpd binary of SonicWall SMA-100 series devices running firmware 10.2.1.x. The main exploit script, 'badblood.py', is a Python program that automates the exploitation process. It attempts to trigger the vulnerability by sending crafted HTTP requests to the target device, guessing stack addresses to achieve code execution. Upon successful exploitation, the target device makes an HTTP callback to the attacker's server, which responds with a shell script payload. This payload downloads a busybox binary to the target, makes it executable, and starts a telnet daemon on port 1270, providing the attacker with shell access as the 'nobody' user. The exploit requires the attacker to know the target's IP address and firmware version, which can be fingerprinted via the device's web interface. The repository includes a detailed README with usage instructions, supported versions, and technical background. The only code file is 'badblood.py', which contains all exploit logic and the embedded payload server.jbaines-r7 · Disclosed Jan 11, 2022 · python · networkOperational
Exposure surface

Affected products & vendors

Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.

VendorProductType
SonicwallSma 200 Firmwareoperating_system
SonicwallSma 210 Firmwareoperating_system
SonicwallSma 400 Firmwareoperating_system
SonicwallSma 410 Firmwareoperating_system
SonicwallSma 500v Firmwareoperating_system
FAQ

Frequently asked questions

Is CVE-2021-20038 exploited in the wild?
Yes. As of Oct 16, 2026, Mallory has reports of exploitation in the wild, and CISA added it to KEV on Jan 28, 2022.
Is there a public exploit for CVE-2021-20038?
Yes. Mallory tracks 2 public exploits or proofs of concept for CVE-2021-20038, the earliest disclosed Jan 11, 2022.
Is there a patch for CVE-2021-20038?
Upgrade affected appliances to firmware 10.2.0.9-41sv or 10.2.1.3-27sv, or a later applicable vendor release. Review installed firmware and apply the latest supported SonicWall update immediately.
What products are affected by CVE-2021-20038?
Sonicwall Sma 200 Firmware, Sonicwall Sma 210 Firmware, Sonicwall Sma 400 Firmware, Sonicwall Sma 410 Firmware, and Sonicwall Sma 500v Firmware.
How severe is CVE-2021-20038?
CVE-2021-20038 has a CVSS v3.1 score of 9.8 (Critical) and an EPSS score of 99.9% (100th percentile) as of Oct 16, 2026.
Mallory platform

The version that knows your environment.

This page is what’s public. Mallory adds the parts that aren’t: which of your assets are affected, which adversaries are exploiting it right now, and which detections to deploy tonight.
Exposure mappingQuery your assets running an affected version, and investigate the blast radius.
Threat actor evidenceEvery report linking this CVE to a named adversary.
Associated malware3Malware families linked to this CVE, with evidence and IOCs.
Detection signatures4YARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.
Vendor-by-vendor mappingCross-references every affected SKU, including bundled OEM variants.
Social activity1Community discussion across Reddit, Mastodon, and other social sources.