Skip to content
Laskyr

phpseclib/phpseclib security advisory

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

CVE-2026-40194 is a low-severity user enumeration vulnerability in the PHP package phpseclib/phpseclib (CVSS 3.7), published 10 April 2026. It is fixed in 1.0.28, 2.0.53 and 3.0.51, one per release line; earlier versions on each line are affected. It can be exploited without an account.

low 3.7 published 2026-04-10 · updated 2026-06-17

Fixed in phpseclib/phpseclib 1.0.28, 2.0.53 and 3.0.51

This user enumeration issue affects phpseclib/phpseclib in 3 release lines: >= 0.1.1, < 1.0.28; >= 2.0.0, < 2.0.53; >= 3.0.0, < 3.0.51. Upgrade to the fixed version for your release line (1.0.28, 2.0.53 and 3.0.51). The newest release, 4.0.3, is not affected.

Affected versions
>= 0.1.1, < 1.0.28
>= 2.0.0, < 2.0.53
>= 3.0.0, < 3.0.51
Fixed in
1.0.28, 2.0.53, 3.0.51
Newest release
4.0.3
Severity
Low · CVSS 3.7
Type
User enumeration
CWE-208
Exploited in the wild
Not on the CISA KEV list
checked 2026-11-04

Is your phpseclib/phpseclib version affected?

Run composer show phpseclib/phpseclib in your project, then enter the version. We check it against this and every other known phpseclib/phpseclib advisory.

Who can exploit CVE-2026-40194

CVSS vector (scored by GitHub): CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N

Your app is only exposed if it uses the affected part of phpseclib/phpseclib. The advisory below says which part that is. If you are not sure, upgrade anyway: it costs less than finding out.

How to fix CVE-2026-40194 in phpseclib/phpseclib

  1. Find the installed version: composer show phpseclib/phpseclib. If you never required it yourself, composer why phpseclib/phpseclib shows which package pulls it in.
  2. Update it: composer update phpseclib/phpseclib --with-all-dependencies. You need the fixed version for your release line (1.0.28, 2.0.53 and 3.0.51).
  3. If Composer will not go that high, your composer.json constraint is holding it back. Widen it (for example "phpseclib/phpseclib": "^3.0.51" if you can take that version), or upgrade the package that requires it.
  4. Run composer audit. It reads the same advisory data and should no longer list CVE-2026-40194.
  5. Commit composer.lock and deploy it. On the server, run composer install --no-dev from the lock file, not composer update.

If you cannot upgrade yet

General hardening for user enumeration issues while the upgrade waits. None of it replaces the fix.

The CVE-2026-40194 advisory

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.

Description from the CVE record, published by GitHub (the CVE Numbering Authority), via the NVD entry for CVE-2026-40194. Advisory title: “phpseclib has a variable-time HMAC comparison in SSH2::get_binary_packet() using != instead of hash_equals()”.

References

Other phpseclib/phpseclib advisories

Related

Need help patching or upgrading? Laskyr does PHP and Laravel security fixes and upgrades. Tell us what you run and we reply with a plan and a price.

Ask about a fix

Where this data comes from

First hour checklist

If the site was just hacked, read the emergency kit before you delete files. The page is free. Email is optional.

Read the emergency kit