Executive Summary
CVE-2026-41940 is a pre-authentication remote authentication bypass in cPanel & WHM (CVSS 9.8 / Critical) caused by a CRLF injection flaw in the platform's session-handling subsystem. Attackers exploited it as a zero-day for roughly two months before cPanel issued an emergency patch on April 28, 2026 — and it has since been added to CISA's Known Exploited Vulnerabilities (KEV) catalog with a federal remediation deadline that has already passed. Any unpatched cPanel server is at immediate, critical risk of full root compromise.
1. What Is This Vulnerability?
CVE-2026-41940 chains three separate weaknesses in cPanel & WHM's authentication and session-management code to allow a completely unauthenticated attacker to promote themselves to a fully authenticated root session.
The Three-Link Chain
Link 1 — CRLF Injection in Basic Auth password handling:
cPanel's HTTP Basic Auth handler fails to sanitize Carriage Return (\r) and Line Feed (\n) characters in the password field before writing session data to a server-side flat-file session store. An attacker can embed arbitrary key=value pairs — separated by CRLF characters — inside the password string, and those pairs are written verbatim into the session file.
Link 2 — Truncated cookie disables session encryption:
A second flaw allows an attacker to supply a truncated session cookie, which causes cPanel's session layer to skip the encryption/integrity checks it would normally apply to session-file contents. This means the injected key-value pairs are trusted as-is on the next read.
Link 3 — Session cache re-parses injected values as top-level session entries:
cPanel maintains both a raw text file and a JSON cache for each session. When cpsrvd (the cPanel main service daemon) re-reads the session, the injected key-value pairs are promoted to first-class session attributes. By injecting the right set of keys — user=root, hasroot=1, tfa_verified=1, and a controlled cp_security_token — the attacker's unauthenticated session is silently re-classified as a fully authenticated root session, bypassing both password checks and two-factor authentication.
Attack Vector
The attack is entirely remote and requires no prior authentication:
- Attacker sends a specially crafted HTTP request to cPanel's login endpoint (port 2083 or 2087).
- The password field contains CRLF-injected session keys ending with
user=root\r\nhasroot=1\r\ntfa_verified=1\r\n.... - A second request with a truncated session cookie is sent to trigger the re-parse without integrity checking.
- cPanel's session layer promotes the session to root — the attacker is now fully logged in as the server's root user via the web interface.
No credentials, no tokens, no social engineering required.
Real-World Impact
- Exploitation began on or around February 23, 2026 — approximately two months before cPanel's patch was released on April 28, 2026, making this a prolonged zero-day.
- Threat actors exploited CVE-2026-41940 to deploy web shells, exfiltrate customer data, pivot to hosted databases, and install persistent backdoors across shared-hosting environments.
- Roughly 1.5 million servers run cPanel & WHM globally, making the attack surface enormous.
- CISA added the CVE to its KEV catalog on April 30, 2026, with a federal FCEB remediation deadline of May 3, 2026.
2. Who Is Affected?
| Component | Affected Versions |
|---|---|
| cPanel & WHM | All versions > 11.40 (prior to patched builds listed below) |
| WP Squared | All versions based on affected cPanel core |
Patched versions:
| Branch | First Safe Build |
|---|---|
| 11.86.x | 11.86.0.41 |
| 11.110.x | 11.110.0.97 |
| 11.118.x | 11.118.0.63 |
| 11.126.x | 11.126.0.54 |
| 11.130.x | 11.130.0.19 |
| 11.132.x | 11.132.0.29 |
| 11.134.x | 11.134.0.20 |
| 11.136.x | 11.136.0.5 |
You are vulnerable if:
- Your cPanel build is older than the first safe build listed for your branch.
- Your cPanel management ports (2083, 2087, 2095, 2096) are reachable from untrusted networks.
- You have not applied the April 28, 2026 emergency patch.
3. How to Detect It (Testing)
Check Your cPanel Version
# SSH into the cPanel server as root
/usr/local/cpanel/cpanel -V
# Or check via WHM:
cat /usr/local/cpanel/version
Compare the output against the patched version table above. If your build number is lower, you are vulnerable.
Manual Testing Steps
⚠️ Perform only on systems you own or have written authorization to test.
- Step 1: Identify the cPanel login URL — typically
https://<host>:2083(cPanel) orhttps://<host>:2087(WHM). - Step 2: Attempt a Basic Auth request with a CRLF payload in the password field to a non-existent user. A vulnerable server will accept the injected session and issue a valid session cookie rather than returning HTTP 401.
- Step 3: If the server returns a redirect to the cPanel home dashboard (HTTP 302 to
/cpsess.../frontend/...) rather than an authentication error, the server is vulnerable. - Step 4: Inspect the Set-Cookie header — a successful injection produces a
cpsessioncookie with an unexpired, valid session ID tied to the injected user.
Automated Scanning
Nuclei template (Recommended):
# Install / update Nuclei
nuclei -update-templates
# Run the cve-2026-41940 template against target
nuclei -t cves/2026/CVE-2026-41940.yaml -u https://<target>:2087
Shodan / Censys reconnaissance (before scanning your own assets):
# Shodan query to identify exposed WHM instances in your IP range
port:2087 product:"cPanel"
Expected vulnerable output: HTTP 302 redirect with a valid cpsession cookie in response to unauthenticated CRLF-injected request.
Expected patched output: HTTP 401 Unauthorized with no session cookie issued.
Code Review Checklist (for cPanel plugin/theme developers)
- Confirm all user-supplied input (especially password fields) is stripped of
\rand\nbefore any write to session files. - Verify session files are written with strict integrity signatures that fail on re-parse if content has been altered.
- Ensure session cookie truncation is treated as an invalid session, not a downgrade signal.
- Check that
cpsrvdre-parse logic validates the full session object rather than merging raw key-value pairs.
4. How to Fix It (Mitigation)
Step-by-Step Remediation
Priority 1 (Do immediately): Block management ports at the firewall
If you cannot patch right now, this is the most critical interim step:
# Using iptables — block external access to cPanel management ports
iptables -I INPUT -p tcp --dport 2083 -j DROP
iptables -I INPUT -p tcp --dport 2087 -j DROP
iptables -I INPUT -p tcp --dport 2095 -j DROP
iptables -I INPUT -p tcp --dport 2096 -j DROP
# Or with firewalld
firewall-cmd --permanent --remove-port=2083/tcp
firewall-cmd --permanent --remove-port=2087/tcp
firewall-cmd --permanent --remove-port=2095/tcp
firewall-cmd --permanent --remove-port=2096/tcp
firewall-cmd --reload
Allow only trusted IPs (admin/management networks) to reach these ports.
Priority 2 (Do immediately): Stop vulnerable services if patching is delayed
# Stop cPanel core daemon and WebDAV daemon
/etc/init.d/cpanel stop
# Or via systemctl on supported builds
systemctl stop cpanel
⚠️ This takes cPanel management offline. Use only as a last resort when external exposure cannot be immediately blocked.
Priority 3 (Primary fix): Patch cPanel & WHM
# Update cPanel to the latest patched build
/scripts/upcp --force
# Verify the new version
/usr/local/cpanel/cpanel -V
Confirm the resulting version is ≥ the first safe build for your branch in the table above.
Priority 4: Restart services post-patch
/etc/init.d/cpanel restart
Priority 5: Rotate credentials and review session logs
# Review authentication logs for suspicious sessions before the patch date
grep -i "cpanel" /var/log/secure | grep "Feb\|Mar\|Apr" | grep -v "Failed password"
# Review cPanel access logs for unusual root sessions
cat /usr/local/cpanel/logs/access_log | grep "root" | grep -v "127.0.0.1"
Code Fix Example (for affected session-handling logic)
The core fix is sanitizing CRLF characters before writing to the session store:
# BEFORE (vulnerable)
sub write_session_data {
my ($session_id, $key, $value) = @_;
open(my $fh, '>>', "/var/cpanel/sessions/$session_id") or die;
print $fh "$key=$value\n"; # $value may contain \r\n
close($fh);
}
# AFTER (patched)
sub write_session_data {
my ($session_id, $key, $value) = @_;
# Strip all CRLF characters from both key and value
$key =~ s/[\r\n]//g;
$value =~ s/[\r\n]//g;
open(my $fh, '>>', "/var/cpanel/sessions/$session_id") or die;
print $fh "$key=$value\n";
close($fh);
}
Additionally, the patched version enforces HMAC-based integrity on session files so that any out-of-band modification causes immediate session invalidation.
Configuration Hardening
# 1. Restrict cPanel port access to known management IPs only (CSF example)
# Edit /etc/csf/csf.allow and add trusted IP
echo "tcp|in|d=2083|s=YOUR_MGMT_IP" >> /etc/csf/csf.allow
csf -r
# 2. Enable cPanel's built-in IP-based access restriction (WHM > Security Center > Host Access Control)
# Add the following to /etc/hosts.allow:
echo "cpanel : YOUR_MGMT_IP_RANGE" >> /etc/hosts.allow
echo "whostmgrd : YOUR_MGMT_IP_RANGE" >> /etc/hosts.allow
echo "cpanel : ALL : DENY" >> /etc/hosts.deny
# 3. Enable two-factor authentication (note: TFA was bypassed by this CVE on unpatched systems)
# After patching, enforce 2FA in WHM > Security Center > Two-Factor Authentication
# 4. Enable ModSecurity with a CRLF injection ruleset
# In WHM > ModSecurity > enable and apply a ruleset that blocks CRLF injection patterns
5. How to Test the Fix (Validation)
Regression Test Scenarios
- Scenario A — Patch verification: After upgrading, verify
cpanel -Vreturns a build ≥ the patched version for your branch. - Scenario B — Authentication bypass no longer works: Re-run the detection steps from Section 3. The server must now return HTTP 401 for any CRLF-injected Basic Auth request.
- Scenario C — Legitimate login still works: Confirm that valid cPanel credentials still successfully authenticate via the web interface and API — no regression in normal auth flows.
- Scenario D — 2FA enforcement: If 2FA is enabled, confirm it is still required post-patch (the injected
tfa_verified=1key should no longer be trusted).
Security Test Cases
Test Case 1: Verify authentication bypass is closed
- Precondition: cPanel patched to safe build; management ports accessible from test host.
- Steps: Send a crafted Basic Auth request with CRLF-injected
user=root\r\nhasroot=1in the password field tohttps://<host>:2087. - Expected Result: Server returns HTTP 401; no
cpsessioncookie issued; no session file created with injected keys.
Test Case 2: Verify session file integrity is enforced
- Precondition: Patched system with an active session.
- Steps: Manually append
user=root\r\nhasroot=1to the session file on disk, then re-send the session cookie. - Expected Result: Server detects HMAC mismatch, invalidates the session, and forces re-authentication.
Test Case 3: Verify normal user authentication is unaffected
- Precondition: Valid cPanel user credentials.
- Steps: Log in with correct username and password.
- Expected Result: Successful authentication and dashboard load; no regressions.
Automated Validation Test (Nuclei + shell)
# Post-patch nuclei scan — should return no findings
nuclei -t cves/2026/CVE-2026-41940.yaml -u https://<target>:2087
echo "Exit code $? — 0 means no finding (patched)"
# curl-based quick check (replace TARGET with your server)
TARGET="https://your-cpanel-server:2087"
PAYLOAD=$'baduser\r\nuser=root\r\nhasroot=1'
RESPONSE=$(curl -sk -o /dev/null -w "%{http_code}" -u "testuser:${PAYLOAD}" "$TARGET/login")
if [ "$RESPONSE" = "401" ]; then
echo "PASS: Server correctly rejected CRLF-injected request (status 401)"
else
echo "FAIL: Server returned $RESPONSE — may still be vulnerable"
fi
6. Prevention & Hardening
Best Practices
- Keep cPanel on auto-update: Enable automatic updates in WHM > Update Preferences > set "Automatic Updates" to Daily. cPanel's update system handles security patches; staying current is the single most effective long-term control.
- Restrict management port access by default: Management ports (2083, 2087, 2095, 2096) should never be exposed to the public internet. Place them behind a VPN, firewall allowlist, or SSH tunnel as a baseline architectural requirement — not an afterthought.
- Apply CRLF injection filtering at the WAF/proxy layer: Deploy a Web Application Firewall (ModSecurity with OWASP CRS, Cloudflare WAF, etc.) in front of cPanel interfaces. CRLF injection is a well-understood attack class with established WAF signatures.
- Implement privileged-access workstations (PAW): Access to WHM root should only be possible from hardened, dedicated management machines — not general-purpose workstations.
- Conduct regular external attack-surface assessments: Periodically run authenticated and unauthenticated scans against your cPanel infrastructure to catch open management ports and outdated builds before attackers do.
Monitoring & Detection
Even on patched systems, deploy monitoring to catch any exploitation attempts or signs of compromise from the pre-patch window:
# 1. Monitor for suspicious root sessions in cPanel access logs
tail -f /usr/local/cpanel/logs/access_log | grep -E "root|hasroot"
# 2. Check for recently created web shells in document roots
find /home/*/public_html -name "*.php" -newer /etc/passwd -ls 2>/dev/null
find /var/www -name "*.php" -newer /etc/passwd -ls 2>/dev/null
# 3. Monitor cPanel service logs for auth anomalies
journalctl -u cpanel -f | grep -iE "auth|session|bypass|inject"
# 4. Alert on new SSH authorized_keys entries (post-compromise persistence indicator)
find /root/.ssh /home/*/.ssh -name "authorized_keys" -newer /etc/passwd
# 5. Check for unexpected cron jobs added during the exploitation window
for user in $(cut -f1 -d: /etc/passwd); do crontab -l -u $user 2>/dev/null | grep -v "^#"; done
If you suspect compromise from the pre-patch exploitation window (Feb–Apr 2026):
- Capture a forensic image of the server before remediation.
- Review
/var/log/secure,/usr/local/cpanel/logs/, and web server access logs for the Feb 23 – April 28 window. - Search for web shells, unfamiliar PHP files, and newly added SSH keys.
- Consider a full server rebuild if root-level compromise is confirmed — restoring from backup is insufficient if the backup was made post-compromise.
References
- CVE Record: CVE-2026-41940 — NVD Detail
- CISA KEV Entry: CISA Known Exploited Vulnerabilities Catalog
- Rapid7 ETR: CVE-2026-41940: cPanel & WHM Authentication Bypass
- watchTowr Labs Analysis: The Internet Is Falling Down — cPanel & WHM Authentication Bypass
- Picus Security Explained: CVE-2026-41940 Explained: 1.5M Servers Hit
- BleepingComputer Coverage: Critical cPanel and WHM bug exploited as zero-day, PoC now available
- Help Net Security: cPanel zero-day exploited for months before patch release
- Patch Info: Update via
/scripts/upcp --forceor download from cPanel & WHM Changelog - Halosecurity Blog: CVE-2026-41940: Critical cPanel & WHM Auth Bypass Under Active Exploitation