PuTTY 漏洞 vuln-p521-bias
PuTTY vulnerability vuln-p521-bias

原始链接: https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/vuln-p521-bias.html

名为“vuln-p521-bias”的严重漏洞影响 PuTTY 版本 0.68 至 0.80。 这些版本在负责使用 NIST P521 曲线生成 ECDSA 签名的代码中包含一个缺陷,从而暴露了用户的私钥。 通过分析几十条这样的签名消息并了解相关的公钥,攻击者可以恢复私钥并伪造新的签名。 攻击需要短暂访问易受攻击的服务器或存储密钥的 Pageant 副本。 此问题标记为 CVE-2024-31497,允许对受受影响私钥保护的帐户进行未经授权的访问。 用户应紧急撤销其 NIST p521 密钥,并用新密钥替换。 其他密钥类型或大小(包括 512 位 ECDSA 和 Ed25519 等其他算法)不会受到影响。 PuTTY 开发人员通过实施广泛采用的 RFC 6979 技术来解决该问题,以消除使密钥恢复成为可能的偏差。 不幸的是,由于此漏洞,一些 P521 私钥的先验知识已经存在。

本文讨论密码学中的一个众所周知的问题,称为独特签名攻击 (DSA) 或椭圆曲线数字签名算法 (ECDSA) 隐藏数字问题。 该问题源于密码系统中随机选择的数字和模数之间的混淆。 虽然直观上,较长的模数可能看起来更安全,但如果只有一部分包含随机值,则其附加位实际上可能会带来弱点。 在这种情况下,在使用 DSA 或 ECDSA 生成数字签名期间,必须为每个签名选择一个随机数“k”。 然而,由于随机数生成过程中的独特模式,模数中的某些高阶位始终为零,使得签名容易受到攻击。 这些攻击可能导致私钥恢复,从而可能导致对受保护数据的未经授权的访问。 该文本引用了在 PuTTY 中发现的此缺陷的具体实例,PuTTY 是一种流行的 SSH 客户端,由于其广泛使用而产生了广泛的影响。 该问题源于应用程序尝试从 Microsoft Windows 平台上可用的有限来源生成足够的熵,最终导致生成的数字出现可预测的模式。 通过分析从同一私钥获得的多个签名,攻击者能够识别这些偏差,揭示潜在的漏洞。 必须认识到在密码学应用中采用稳健且可靠的方法来生成真正随机数的重要性,确保使用这些技术传输或处理的敏感信息的安全性。 此外,持续的警惕和测试对于维护这些关键系统的完整性和安全性是必要的。
相关文章

原文
PuTTY vulnerability vuln-p521-bias

Home | FAQ | Feedback | Licence | Updates | Mirrors | Keys | Links | Team
Download: Stable · Snapshot | Docs | Changes | Wishlist

summary: NIST P521 private keys are exposed by biased signature generation
class: vulnerability: This is a security vulnerability.
priority: high: This should be fixed in the next release.
absent-in: 0.67
present-in: 0.68 0.69 0.70 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.80
fixed-in: c193fe9848f50a88a4089aac647fecc31ae96d27 (0.81)

Every version of the PuTTY tools from 0.68 to 0.80 inclusive has a critical vulnerability in the code that generates signatures from ECDSA private keys which use the NIST P521 curve. (PuTTY, or Pageant, generates a signature from a key when using it to authenticate you to an SSH server.)

This vulnerability has been assigned CVE-2024-31497. It was discovered by Fabian Bäumer and Marcus Brinkmann of the Ruhr University Bochum; see their write-up on the oss-security mailing list.

The bad news: the effect of the vulnerability is to compromise the private key. An attacker in possession of a few dozen signed messages and the public key has enough information to recover the private key, and then forge signatures as if they were from you, allowing them to (for instance) log in to any servers you use that key for. To obtain these signatures, an attacker need only briefly compromise any server you use the key to authenticate to, or momentarily gain access to a copy of Pageant holding the key. (However, these signatures are not exposed to passive eavesdroppers of SSH connections.)

Therefore, if you have a key of this type, we recommend you revoke it immediately: remove the old public key from all OpenSSH authorized_keys files, and the equivalent in other SSH servers, so that a signature from the compromised key has no value any more. Then generate a new key pair to replace it.

(The problem is not with how the key was originally generated; it doesn't matter whether it came from PuTTYgen or somewhere else. What matters is whether it was ever used with PuTTY or Pageant.)

The good news: the only affected key type is 521-bit ECDSA. That is, a key that appears in Windows PuTTYgen with ecdsa-sha2-nistp521 at the start of the 'Key fingerprint' box, or is described as 'NIST p521' when loaded into Windows Pageant, or has an id starting ecdsa-sha2-nistp521 in the SSH protocol or the key file. Other sizes of ECDSA, and other key algorithms, are unaffected. In particular, Ed25519 is not affected.


Details of the error:

All DSA signature schemes require a random value to be invented during signing, known as the 'nonce' (cryptography jargon for a value used only once), or sometimes by the letter k. It's well known that if an attacker can guess the value of k you used, or find any two signatures you generated with the same k, then they can immediately recover your private key.

This means that it's dangerous to generate DSA signatures on systems with no high-quality source of randomness. Significantly more dangerous than generating the encryption keys for a single session: a leak of the private key compromises far more than one SSH session.

For this reason, since PuTTY was developed on Windows before it had any cryptographic random number generator at all, PuTTY has always generated its k using a deterministic method, avoiding the need for random numbers at all. The clever trick is to compute a secure hash whose input includes the message to be signed and also the private key. Secure hash output is indistinguishable from random data (or else the hash function isn't doing its job), and this generation method can't be repeated by an attacker who's trying to find out the private key – if they could generate the same hash input as you, they'd already have the private key.

This technique is now mainstream, and RFC 6979 documents a specific well-known way of doing it. But PuTTY didn't follow that specification, because we started doing the same thing in 2001, and the RFC wasn't published until 2013.

PuTTY's technique worked by making a SHA-512 hash, and then reducing it mod q, where q is the order of the group used in the DSA system. For integer DSA (for which PuTTY's technique was originally developed), q is about 160 bits; for elliptic-curve DSA (which came later) it has about the same number of bits as the curve modulus, so 256 or 384 or 521 bits for the NIST curves.

In all of those cases except P521, the bias introduced by reducing a 512-bit number mod q is negligible. But in the case of P521, where q has 521 bits (i.e. more than 512), reducing a 512-bit number mod q has no effect at all – you get a value of k whose top 9 bits are always zero.

This bias is sufficient to allow a key recovery attack. It's less immediate than if an attacker knows all of k, but it turns out that if k has a biased distribution in this way, it's possible to aggregate information from multiple signatures and recover the private key eventually. Apparently the number of signatures required is around 60.


To fix this vulnerability, we've completely abandoned PuTTY's old system for generating k, and switched to the RFC 6979 technique, for all DSA and ECDSA key types. (EdDSA keys such as Ed25519 already used a different system, which has not changed.) However, this doesn't affect the fact that information about existing P521 private keys has already been leaked whenever a signature was generated using the old k generator.


If you want to comment on this web site, see the Feedback page.

(last revision of this bug record was at 2024-04-15 20:49:32 +0100)

联系我们 contact @ memedata.com