What’s Vulnerable › Vulnerabilities

CVE-2026-40194: phpseclib has a variable-time HMAC comparison in SSH2::get_binary_packet() using != instead of hash_equals()

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.

Affected products

How to fix

Upgrade to a fixed version: phpseclib 2.0.53, 3.0.51; Packagist Phpseclib/Phpseclib 1.0.28, 2.0.53, 3.0.51. Check the vendor advisory for mitigations.

References

Get alerted when CVE-2026-40194 or the next vulnerability affects your stack