Linux: wireguard: noise: reject response consumption after intermediate initiation
What fixes it
- 4d64a3d6e96aa78619c9c29ffde309794974588aLinuxCVE List
- 3bec3d32c2a3afd164fc87f95457df2cf9049c20LinuxCVE List
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
In the Linux kernel, the following vulnerability has been resolved:
wireguard: noise: reject response consumption after intermediate initiation
Two threads begin processing the identical response message, received twice. The first thread, A, runs. While it's running, the second one, B, gets partway through, and during that slow calculation, or even while blocking on down_write(), A completes and then also a handshake initiation that's already been queued up runs in thread C, which itself takes that same down_write(). The handshake initiation creation succeeds, and sets the state back to waiting-for-response, and calls up_write(), at which point thread B resumes, because either its finished its calculations or was finally allowed to acquire down_write(). Thread B then copies the state back to the peer, and begins a new session, using that state, which is the same session as the one made in thread A.
Thread A Thread B Thread C
down_read() sA = handshake->state memcpy(cA, handshake->crypto) up_read() if (sA != 1) goto fail slow_crypto(cA) down_read() sB = handshake->state memcpy(cB, handshake->crypto) up_read() if (sB != 1) goto fail slow_crypto(cB) down_write() if (sA != handshake->state) goto fail memcpy(handshake->crypto, cA) handshake->state = 2 up_write() down_write() if (handshake->state != 2) goto fail derive_session(handshake->crypto) up_write() down_write() slow_crypto(handshake->crypto) handshake->state = 1 up_write() down_write() if (sB != handshake->state) goto fail memcpy(handshake->crypto, cB) handshake->state = 2 up_write() down_write() if (handshake->state != 2) goto fail derive_session(handshake->crypto) up_write()
This seems basically impossible to hit in a meaningful way in practice, but ensure that it absolutely cannot happen by comparing the ephemeral private key that's on the stack with the latest one that the peer's handshake state has.
Text from CVE List
Affected versions 12
- Linuxaffected: e7096c131e5161fa3b8e52a650d7719d2857adfd before fb5ce4c7790c3eeec820302d08d70ecf46af4295CVE List
- Linuxaffected: e7096c131e5161fa3b8e52a650d7719d2857adfd before c76a80db593096edf2b3b3972f58b6342a8c6c04CVE List
- Linuxaffected: e7096c131e5161fa3b8e52a650d7719d2857adfd before 4d64a3d6e96aa78619c9c29ffde309794974588aCVE List
- Linuxaffected: e7096c131e5161fa3b8e52a650d7719d2857adfd before 3bec3d32c2a3afd164fc87f95457df2cf9049c20CVE List
- Linuxaffected: e7096c131e5161fa3b8e52a650d7719d2857adfd before d0305f8d90029556260c6824b61c493c424eba9eCVE List
- Linuxaffected: 5.6CVE List
- Linuxunaffected: all versions before 5.6CVE List
- Linuxunaffected: 6.6.160 through 6.6.*CVE List
- Linuxunaffected: 6.12.113 through 6.12.*CVE List
- Linuxunaffected: 6.18.57 through 6.18.*CVE List
- Linuxunaffected: 7.2.11 through 7.2.*CVE List
- Linuxunaffected: 7.3CVE List
References 5
- git.kernel.org/stable/c/fb5ce4c7790c3eeec820302d08d70ecf46af4295Referencevia CVE List
- git.kernel.org/stable/c/c76a80db593096edf2b3b3972f58b6342a8c6c04Referencevia CVE List
- git.kernel.org/stable/c/4d64a3d6e96aa78619c9c29ffde309794974588aReferencevia CVE List
- git.kernel.org/stable/c/3bec3d32c2a3afd164fc87f95457df2cf9049c20Referencevia CVE List
- git.kernel.org/stable/c/d0305f8d90029556260c6824b61c493c424eba9eReferencevia CVE List