# CVE-2026-40194: phpseclib timing discrepancy in SSH2 HMAC verification

Source: https://junglewise.ai/threats/cve-2026-40194-phpseclib-timing-discrepancy-in-ssh2-hmac-verification  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-04-10. Updated: 2026-05-10  
License: CC BY 4.0 with a link back

CVE-2026-40194 · Severity: low · CVSS 3.7 · Published 2026-04-10

phpseclib is a widely used PHP library for secure communications, such as connecting to servers via SSH. A flaw was found where the library compares security codes (HMACs) in a way that takes slightly different amounts of time depending on how much of the code is correct. While difficult to exploit over a network, a sophisticated attacker could theoretically use these timing differences to eventually guess valid security codes, potentially compromising the integrity of the encrypted connection.

Technologies: [phpseclib/phpseclib (Packagist)](https://junglewise.ai/threats/technologies/phpseclib-phpseclib). Vendors: [Packagist](https://junglewise.ai/threats/vendors/packagist).

## Quick answers

**Is CVE-2026-40194 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-40194 being exploited in the wild.

**How severe is CVE-2026-40194?** Low severity, with a CVSS score of 3.7, published 10 April 2026.

**Which products and versions are affected?** phpseclib/phpseclib (Packagist) ECOSYSTEM:introduced=0.1.1,fixed=1.0.28.

**Is there a fix for CVE-2026-40194?** Yes. phpseclib/phpseclib (Packagist): upgrade to 1.0.28 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-40194 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-40194?** Check whether you run phpseclib/phpseclib (Packagist) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- phpseclib/phpseclib (Packagist): upgrade to 1.0.28 or later

  ```sh
  composer require phpseclib/phpseclib:^1.0.28
  ```


## Technical details

The phpseclib library's SSH2 implementation in `get_binary_packet()` uses PHP's `!=` operator to compare received SSH packet HMACs against locally computed HMACs. Because PHP's `!=` operator on equal-length binary strings utilizes `memcmp()`, it short-circuits upon encountering the first differing byte, creating an observable timing discrepancy (CWE-208). An attacker could potentially exploit this side-channel to conduct a timing attack, although practical exploitation is significantly hindered by SSH's default behavior of disconnecting upon MAC failure and the use of per-session keys. The vulnerability affects all non-AEAD ciphers (e.g., AES-CBC, AES-CTR) and is resolved by replacing the inequality operator with the constant-time `hash_equals()` function.

## Affected products

- phpseclib phpseclib 0.1.1 to 1.0.27, 2.0.0 to 2.0.52, 3.0.0 to 3.0.50

## Identifiers

- CVE-2026-40194
- GHSA-r854-jrxh-36qx

## Timeline

- 2026-04-10: advisory: Vendor advisory and GHSA published
- 2026-04-10: patched: Fixed in versions 3.0.51, 2.0.53, and 1.0.28

## References

- [https://github.com/phpseclib/phpseclib/commit/ffe48b6b1b1af6963327f0a5330e3aa004a194ac](https://github.com/phpseclib/phpseclib/commit/ffe48b6b1b1af6963327f0a5330e3aa004a194ac)
- [https://github.com/phpseclib/phpseclib/releases/tag/1.0.28](https://github.com/phpseclib/phpseclib/releases/tag/1.0.28)
- [https://github.com/phpseclib/phpseclib/releases/tag/2.0.53](https://github.com/phpseclib/phpseclib/releases/tag/2.0.53)
- [https://github.com/phpseclib/phpseclib/releases/tag/3.0.51](https://github.com/phpseclib/phpseclib/releases/tag/3.0.51)
- [https://github.com/phpseclib/phpseclib/security/advisories/GHSA-r854-jrxh-36qx](https://github.com/phpseclib/phpseclib/security/advisories/GHSA-r854-jrxh-36qx)

## Related threats

- [phpseclib X25519 non-constant-time scalar multiplication private key recovery](https://junglewise.ai/threats/cve-2026-84308-phpseclib-x25519-non-constant-time-scalar-multiplication-private)
- [phpseclib SSRF in X.509 certificate validation](https://junglewise.ai/threats/cve-2026-55599-phpseclib-ssrf-in-x-509-certificate-validation)
- [phpseclib denial of service via OID amplification in ASN1 decoding](https://junglewise.ai/threats/cve-2026-44167-phpseclib-oid-amplification-dos-in-asn1-decodeoid)
- [Phpseclib needs guardrails on large binaryfield integers](https://junglewise.ai/threats/cve-2023-49316-phpseclib-needs-guardrails-on-large-binaryfield-integers)
- [phpseclib guardrails needed on OID length](https://junglewise.ai/threats/cve-2024-27355-phpseclib-guardrails-needed-on-oid-length)
