CVE-2026-41940 Explained: The cPanel & WHM Authentication Bypass That Hit 1.5M Servers
| May 01, 2026
TL;DR — CVE-2026-41940 is a pre-authentication remote auth bypass in cPanel & WHM (CVSS 9.8). It chains a CRLF injection in the session writer with an encryption-skip triggered by a malformed cookie, then uses a quirk in how cPanel caches sessions to "promote" the injection into a privileged login. CISA added it to the KEV catalog. In-the-wild exploitation predates the patch by roughly two months. Patch now, rotate credentials, and triage your session directory.
Credit where it's due. The original root-cause analysis and proof-of-concept were published by Sina Kheirkhah at watchTowr Labs. This article is an independent explainer. It summarizes the logic of the bug for defenders, walks through why it works, and points readers back to watchTowr's writeup for the full exploit walkthrough. Reproducing their PoC code or verbatim narrative is not the goal here; if you want the original deep-dive, read it directly.
Simulate Emerging Threats with 14-Day Free Trial of Picus Platform
Why this CVE-2026-41940 matters

Figure 1. CVE-2026-41940 cPanel WHM authentication bypass vulnerability CVSS 9.8
A few numbers set the stakes:
- CVSS 9.8 (Critical), pre-auth, network-reachable.
- ~1.5 million internet-exposed cPanel instances per Shodan telemetry referenced by Rapid7.
- All supported versions after 11.40 were vulnerable, plus WP Squared.
- Exploitation observed since ~February 23, 2026, per hosting provider KnownHost, meaning this was a true zero-day for roughly two months before cPanel's emergency patch on April 28.
- CISA KEV entry added shortly after disclosure.
- Hosting providers (Namecheap, KnownHost, HostPapa, InMotion) preemptively blocked TCP/2083 and TCP/2087 to protect customers ahead of patching.
When the management plane of millions of shared-hosting servers can be unauthenticated by an attacker who knows one trick, the operational severity is hard to overstate. Compromise of WHM is effectively a compromise of the host, and on shared hosting, of every site that host serves.
What cPanel & WHM are
cPanel is the per-account user UI; WHM is the root-level admin panel used by the hosting provider. Both are served by a Perl daemon called cpsrvd on ports 2082/2083/2086/2087 (and webmail on 2095/2096). All three pieces — cPanel, WHM, and WP Squared — were impacted by CVE-2026-41940.
Affected versions
If you're below the right column, you're vulnerable.
|
Branch |
Patched in |
|
11.110.0.x |
11.110.0.97 |
|
11.118.0.x |
11.118.0.63 |
|
11.126.0.x |
11.126.0.54 |
|
11.132.0.x |
11.132.0.29 |
|
11.134.0.x |
11.134.0.20 |
|
11.136.0.x |
11.136.0.5 |
|
WP Squared |
11.136.1.7 |
Two reminders from the vendor advisory: servers with auto-update disabled or version pinning will not patch themselves, and you should restart cpsrvd after updating (/scripts/restartsrv_cpsrvd).
The bug, in plain English
The shortest honest description:
|
An attacker can write attacker-chosen lines into a cPanel session file before authentication, then trick the server into reading those lines as if they were legitimate session attributes, including ones that mark the session as root and signal "password already verified." |
The vulnerability isn't a single mistake. It's three weaknesses lined up end-to-end:
A sanitizer that wasn't called on the dangerous code path. cPanel already had a function to strip \r\n=, from session values, but it was the caller's responsibility to invoke it. The Basic-auth handler in cpsrvd didn't.
An encryption step that silently turned itself off. The session writer encrypts the password field using a per-session secret embedded in the session cookie. If that secret is missing, the original code skipped encryption entirely instead of refusing the operation. So an attacker who sends a truncated cookie causes their payload to land on disk in plaintext.
A two-file session model that hides — and then later reveals — the injection. Sessions exist in two places:
- a line-oriented raw file, and
- a JSON cache.
The loader reads the cache first, where injected newlines look like harmless escape sequences inside one big string. A separate code path (the "token denied" handler) re-parses the raw file and rewrites the cache, promoting the injected lines into top-level keys the loader will trust.

Figure 2. cPanel session file vs JSON cache CRLF injection diagram CVE-2026-41940
When you put those three together, an unauthenticated HTTP request can install an admin session for root.
Why each safeguard failed
It's worth dwelling on why a hardened, decade-old codebase shipped this. Each layer failed for a recognizable reason.

Figure 3. CVE-2026-41940 four security layer failures Swiss cheese model
Layer 1 — Input sanitation: "every caller must remember"
Sanitation lived in a helper that callers were expected to invoke before saving a session. Most callers did. One — the Basic-auth path that takes credentials directly off an HTTP header — did not. This is a textbook "defense at the source instead of the sink" failure. As long as sanitation is opt-in, it will eventually be opted out of. The patch fixes this by moving the sanitizer inside the save function.
Layer 2 — Encryption keyed on attacker-controllable data
The per-session encryption key is read from the session cookie. The original code essentially said "if we have a key, encrypt; otherwise, just save." The otherwise branch was reachable by the attacker, because the attacker controls the cookie. Encryption that the input can disable is not encryption. The patched code distinguishes the two cases and never writes a raw password to disk.
Layer 3 — Cache and source-of-truth divergence
Two on-disk representations of the same session existed for performance reasons: a raw text file and a JSON cache. JSON encodes embedded newlines as escape sequences inside a string, while the raw text format treats them as record separators. The same bytes therefore mean two different things depending on which file you parse. An attacker who can write to the raw file and find a code path that re-parses raw → JSON wins, because they can shift their payload from "looks like one big string" to "looks like multiple top-level fields."
Layer 4 — Authentication that can be skipped by setting a flag
The final indignity: the password check in docheckpass_whostmgrd short-circuits to "AUTH OK" if the session contains a successful_internal_auth_with_timestamp value. That field exists for legitimate reasons (single-sign-on flows, internal tooling), but its mere presence — with no cryptographic binding — is treated as proof of prior authentication. Because the attacker can now plant arbitrary fields, they can plant that field. A flag that means "trust me, I already checked" must be cryptographically bound to the thing that actually checked.
Exploit chain at a glance
Without reproducing the full walkthrough or any working PoC payload, the chain has four conceptual steps. Each one is interesting only because the previous one exists.

Figure 4. CVE-2026-41940 cPanel exploit chain four steps to root access
|
Step |
What the attacker does |
What the server does wrong |
|
1 |
Submits a deliberately failed login |
Creates a preauth session file on disk anyway |
|
2 |
Sends a Basic-auth request with newline-laced credentials, using a cookie that omits the encryption-key segment |
Writes the credentials to disk unencrypted and unsanitized |
|
3 |
Sends a request that triggers the "token denied" handler |
Re-parses the poisoned raw file and overwrites the JSON cache, promoting injected lines to top-level fields |
|
4 |
Makes any normal authenticated request |
Treats the session as root and skips the password check because of the planted "already authenticated" flag |
The whole chain is a handful of HTTP requests and zero credentials. From step 4 onward, full WHM API access trivially yields root RCE through any of the legitimate features WHM exposes (custom hooks, package management, PHP-FPM configuration, etc.).
Detection and IOCs

Figure 5. Detection Cheat Sheet for CVE-2026-41940
cPanel published a vendor detection script that performs filesystem-based triage. Defensive teams should also look for:
- Session files under /var/cpanel/sessions/raw/ whose pass= value contains embedded \r or \n bytes, or where pass= is followed on the next line by something that looks like another key=value pair.
- Sessions in which privileged-looking keys (hasroot=1, tfa_verified=1, successful_internal_auth_with_timestamp=*) coexist with origin_as_string=...method=badpass — that combination means the session was minted from a failed login and then "elevated."
- Access-log sequences where a 307 redirect to /cpsessXXXXXXXXXX/ appears without a preceding successful POST /login/.
- Cookies of the form whostmgrsession=:<name> (no ,<32-hex> tail) on requests that carry an Authorization: Basic header — this is the signature of the no-encryption code path being intentionally tickled.
A couple of triage one-liners:
|
# Sessions containing privileged-looking top-level keys grep -lE '^(hasroot|tfa_verified|successful_internal_auth_with_timestamp)=1' \ /var/cpanel/sessions/raw/* 2>/dev/null # pass= values with embedded carriage returns grep -lP 'pass=.*\r' /var/cpanel/sessions/raw/* 2>/dev/null |
Given confirmed in-the-wild exploitation since late February 2026, any cPanel host that was internet-exposed and unpatched during that window should be treated as suspect, not hypothetical.
Mitigation checklist for CVE-2026-41940 exploitation attacks
- Patch. Update via /scripts/upcp --force. Confirm with /usr/local/cpanel/cpanel -V. Restart cpsrvd.
- Manually patch pinned or auto-update-disabled servers. They will not heal themselves.
- Rotate credentials. Force-reset root and every WHM reseller password. Rotate API tokens. Re-issue SSH keys stored in WHM-managed accounts.
- Purge sessions in /var/cpanel/sessions/raw/ and /var/cpanel/sessions/cache/.
- Hunt for persistence. Audit cron entries (system and per-user), ~/.ssh/authorized_keys, custom WHM hooks, and packages installed during the exposure window.
- If you cannot patch immediately, block inbound TCP/2083, TCP/2087, TCP/2095, TCP/2096 at the perimeter, or stop cpsrvd and cpdavd. This is the same containment several major hosting providers used.
Lessons that generalize
A few takeaways worth carrying into other codebases:
- Sanitize at the sink. "Remember to call X before Y" rules will be forgotten. Put the check inside Y.
- Don't let untrusted input disable security checks. A falsy value should not silently turn off encryption — it should fail closed.
- Two representations of the same data is a vulnerability shape. Raw vs. cache, JSON vs. flat, normalized vs. raw — wherever a parser disagrees with another parser about what a byte sequence means, that disagreement is exploitable.
- "Already authenticated" flags need cryptographic binding. A boolean in a session that says "skip the password check" must be unforgeable, not just present.
- Pre-auth state is attack surface. Anything written to disk on the strength of an unauthenticated request must be assumed attacker-controlled.
How Picus Helps Simulate CVE-2026-41940 Attacks?
We strongly recommend simulating the CVE-2026-41940 cPanel & WHM authentication bypass to validate the effectiveness of your security controls against pre-authentication exploitation attempts. With the Picus Security Validation Platform, you can safely emulate the full CRLF injection and session-promotion attack chain in your environment — and measure exactly how your WAF, EDR, and SIEM rules respond.
You can also test your defenses against other high-impact vulnerability exploitation attacks — including regreSSHion (CVE-2024-6387), Citrix Bleed (CVE-2023-4966), and Follina (CVE-2022-30190) — within minutes using a 14-day free trial of the Picus Platform.
The Picus Threat Library includes the following threats for CVE-2026-41940 exploitation attacks:
|
Threat ID |
Threat Name |
Attack Module |
|
41178 |
cPanel WHM Auth Bypass via Basic Auth CRLF Injection Variant 1 |
Web Application |
Start simulating emerging threats today and get actionable mitigation insights with a 14-day free trial of the Picus Security Validation Platform.
References
- cPanel Security Advisory: Critical Vulnerability with cPanel & WHM Login Authentication (April 28, 2026).
- watchTowr Labs — original technical analysis and PoC by Sina Kheirkhah (April 29, 2026): labs.watchtowr.com.
- Rapid7 Emerging Threat Report on CVE-2026-41940.
- CISA Known Exploited Vulnerabilities catalog entry.
- BleepingComputer, SecurityWeek, CyberScoop, The Register — coverage of in-the-wild exploitation since Feb 23, 2026.
- KnownHost community advisory confirming pre-disclosure exploitation.
Frequently Asked Questions
- Is it wormable?
-
The chain is fully unauthenticated and small. Mass scripted exploitation against the ~1.5M exposed instances is feasible, which is exactly why CISA escalated it.
- Does 2FA protect me?
-
No. The injection sets tfa_verified=1 directly in the session.
- Does my WAF block this?
-
Only if it both normalizes Authorization: Basic payloads against CRLF and inspects cookies for the missing encryption-key segment. Generic rule sets generally did not catch this pre-disclosure. Patch regardless.
- Does this affect cPanel DNSOnly?
-
Yes, per the vendor advisory.
- Are unsupported (pre-11.40) versions affected?
-
No.
