Security Vulnerability Report
中文
CVE-2026-40194 CVSS 3.7 LOW

CVE-2026-40194

Published: 2026-04-10 21:16:28
Last Modified: 2026-05-08 16:16:11

Description

phpseclib is a PHP secure communications library. Starting in 0.1.1 and prior to 3.0.51, 2.0.53, and 1.0.28, phpseclib\Net\SSH2::get_binary_packet() uses PHP's != operator to compare a received SSH packet HMAC against the locally computed HMAC. != on equal-length binary strings in PHP uses memcmp(), which short-circuits on the first differing byte. This is a real variable-time comparison (CWE-208), proven by scaling benchmarks. This vulnerability is fixed in 3.0.51, 2.0.53, and 1.0.28.

CVSS Details

CVSS Score
3.7
Severity
LOW
CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N

Configurations (Affected Products)

cpe:2.3:a:phpseclib:phpseclib:*:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:a:phpseclib:phpseclib:*:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:a:phpseclib:phpseclib:*:*:*:*:*:*:*:* - VULNERABLE
phpseclib < 3.0.51
phpseclib < 2.0.53
phpseclib < 1.0.28

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
<?php // PoC Code to demonstrate timing difference between != and hash_equals // This simulates the vulnerability in CVE-2026-40194 $correct_hmac = str_repeat('A', 32); // Simulated correct HMAC $guess = str_repeat('A', 31) . 'B'; // Simulated guess (last char wrong) $iterations = 10000; // 1. Test insecure comparison (!=) $start = microtime(true); for ($i = 0; $i < $iterations; $i++) { $result = ($correct_hmac != $guess); } $insecure_time = microtime(true) - $start; // 2. Test secure comparison (hash_equals) $start = microtime(true); for ($i = 0; $i < $iterations; $i++) { $result = hash_equals($correct_hmac, $guess); } $secure_time = microtime(true) - $start; echo "Insecure Comparison Time: " . number_format($insecure_time * 1000, 4) . " ms\n"; echo "Secure Comparison Time: " . number_format($secure_time * 1000, 4) . " ms\n"; ?>

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-40194", "sourceIdentifier": "[email protected]", "published": "2026-04-10T21:16:27.583", "lastModified": "2026-05-08T16:16:10.647", "vulnStatus": "Modified", "cveTags": [], "descriptions": [{"lang": "en", "value": "phpseclib is a PHP secure communications library. Starting in 0.1.1 and prior to 3.0.51, 2.0.53, and 1.0.28, phpseclib\\Net\\SSH2::get_binary_packet() uses PHP's != operator to compare a received SSH packet HMAC against the locally computed HMAC. != on equal-length binary strings in PHP uses memcmp(), which short-circuits on the first differing byte. This is a real variable-time comparison (CWE-208), proven by scaling benchmarks. This vulnerability is fixed in 3.0.51, 2.0.53, and 1.0.28."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N", "baseScore": 3.7, "baseSeverity": "LOW", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "LOW", "integrityImpact": "NONE", "availabilityImpact": "NONE"}, "exploitabilityScore": 2.2, "impactScore": 1.4}]}, "weaknesses": [{"source": "[email protected]", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-208"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:phpseclib:phpseclib:*:*:*:*:*:*:*:*", "versionEndIncluding": "1.0.27", "matchCriteriaId": "8315BEB0-7CC2-4BF7-8951-086898B9D909"}, {"vulnerable": true, "criteria": "cpe:2.3:a:phpseclib:phpseclib:*:*:*:*:*:*:*:*", "versionStartIncluding": "2.0.0", "versionEndExcluding": "2.0.53", "matchCriteriaId": "88F1EA13-1048-43B5-8AE5-52D81EE17470"}, {"vulnerable": true, "criteria": "cpe:2.3:a:phpseclib:phpseclib:*:*:*:*:*:*:*:*", "versionStartIncluding": "3.0.0", "versionEndExcluding": "3.0.51", "matchCriteriaId": "595DB51F-4A57-4D49-A951-E45590487A83"}]}]}], "references": [{"url": "https://github.com/phpseclib/phpseclib/commit/ffe48b6b1b1af6963327f0a5330e3aa004a194ac", "source": "[email protected]", "tags": ["Patch"]}, {"url": "https://github.com/phpseclib/phpseclib/releases/tag/1.0.28", "source": "[email protected]", "tags": ["Release Notes"]}, {"url": "https://github.com/phpseclib/phpseclib/releases/tag/2.0.53", "source": "[email protected]", "tags": ["Release Notes"]}, {"url": "https://github.com/phpseclib/phpseclib/releases/tag/3.0.51", "source": "[email protected]", "tags": ["Release Notes"]}, {"url": "https://github.com/phpseclib/phpseclib/security/advisories/GHSA-r854-jrxh-36qx", "source": "[email protected]", "tags": ["Vendor Advisory"]}, {"url": "https://github.com/phpseclib/phpseclib/security/advisories/GHSA-r854-jrxh-36qx", "source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "tags": ["Vendor Advisory"]}]}}