KernelScan.io

CRITICAL Introduced in 3.8

net/ipv4 TCP ACK Bypass

CVE-2023-52881

CVSS 9.8 / 10.0 NVD

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

KernelScan AI9.8CRITICAL

01

In the Linux kernel, the following vulnerability has been resolved: tcp: do not accept ACK of bytes we never sent This patch is based on a detailed report and ideas from Yepeng Pan and Christian Rossow. ACK seq validation is currently following RFC 5961 5.2 guidelines: The ACK value is considered acceptable only if it is in the range of ((SND.UNA - MAX.SND.WND) <= SEG.ACK <= SND.NXT). All incoming segments whose ACK value doesn't satisfy the above condition MUST be discarded and an ACK sent back. It needs to be noted that RFC 793 on page 72 (fifth check) says: "If the ACK is a duplicate (SEG.ACK < SND.UNA), it can be ignored. If the ACK acknowledges something not yet sent (SEG.ACK > SND.NXT) then send an ACK, drop the segment, and return". The "ignored" above implies that the processing of the incoming data segment continues, which means the ACK value is treated as acceptable. This mitigation makes the ACK check more stringent since any ACK < SND.UNA wouldn't be accepted, instead only ACKs that are in the range ((SND.UNA - MAX.SND.WND) <= SEG.ACK <= SND.NXT) get through. This can be refined for new (and possibly spoofed) flows, by not accepting ACK for bytes that were never sent. This greatly improves TCP security at a little cost. I added a Fixes: tag to make sure this patch will reach stable trees, even if the 'blamed' patch was adhering to the RFC. tp->bytes_acked was added in linux-4.2 Following packetdrill test (courtesy of Yepeng Pan) shows the issue at hand: 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 +0 bind(3, ..., ...) = 0 +0 listen(3, 1024) = 0 // ---------------- Handshake ------------------- // // when window scale is set to 14 the window size can be extended to // 65535 * (2^14) = 1073725440. Linux would accept an ACK packet // with ack number in (Server_ISN+1-1073725440. Server_ISN+1) // ,though this ack number acknowledges some data never // sent by the server. +0 < S 0:0(0) win 65535 <mss 1400,nop,wscale 14> +0 > S. 0:0(0) ack 1 <...> +0 < . 1:1(0) ack 1 win 65535 +0 accept(3, ..., ...) = 4 // For the established connection, we send an ACK packet, // the ack packet uses ack number 1 - 1073725300 + 2^32, // where 2^32 is used to wrap around. // Note: we used 1073725300 instead of 1073725440 to avoid possible // edge cases. // 1 - 1073725300 + 2^32 = 3221241997 // Oops, old kernels happily accept this packet. +0 < . 1:1001(1000) ack 3221241997 win 65535 // After the kernel fix the following will be replaced by a challenge ACK, // and prior malicious frame would be dropped. +0 > . 1:1(0) ack 1001

02

Engine v0.6.0

Risk summary

An unauthenticated on-path attacker or accurate remote spoofer can target a reachable TCP flow, bypass its challenge-ACK defense, and insert chosen bytes into the application's received stream. The integrity compromise can lead to disclosure or service failure when the peer acts on or parses the forged data, and no credentials, special hardware, or elevated namespace capability is required.

Affectednet/ipv4/tcp_input.c (net/ipv4 TCP input)

Vulnerability analysis

The receiver treated an old-looking acknowledgment as acceptable whenever it fell within the connection's full advertised window, even on a new or spoofed connection where the peer had not acknowledged enough data to justify that range. An attacker able to inject a correctly timed TCP segment could therefore bypass the challenge-acknowledgment defense and have attacker-chosen payload accepted into the receiving application's data stream. The fix limits how far an old acknowledgment may trail the current acknowledgment to the amount actually acknowledged during the connection, causing impossible acknowledgments to be challenged and their segments dropped. The path is reachable over the network without credentials, although practical injection generally requires an on-path attacker or accurate knowledge of the connection's sequence state.

03

BranchIntroducedFixed inPatch commit
3.03.0.583.169eae75ca525
3.23.2.373.3458f07ffeccd
3.43.4.253.57ffff0cc929f
4.143.84.14.333b17a886ed29f
4.193.84.19.3020d4e0afdd665
5.103.85.10.2042087d53a66e9
5.153.85.15.1433d501dd326fb
5.43.85.4.264008b807fe487
6.13.86.1.68—
6.63.86.6.7—
mainline3.86.7—
cip/4.193.84.19.304-cip106458f07ffeccd
cip/4.19-rt3.84.19.306-cip107-rt35458f07ffeccd
cip/4.43.84.4.302-cip83ac30c08ffa7b
cip/4.4-rt3.84.4.302-cip83-rt47ac30c08ffa7b
cip/5.103.85.10.205-cip42b17a886ed29f
cip/5.10-rt3.85.10.209-cip44-rt18b17a886ed29f
cip/6.13.86.1.72-cip13008b807fe487
cip/6.1-rt3.86.1.75-cip14-rt8008b807fe487

04

State of the newest release of each Civil Infrastructure Platform SLTS tree, from CIP's own fix records.

CIP treeState
cip/6.1Fixed in 6.1.72-cip13
cip/6.1-rtFixed in 6.1.75-cip14-rt8
cip/5.10Fixed in 5.10.205-cip42
cip/5.10-rtFixed in 5.10.209-cip44-rt18
cip/4.19Fixed in 4.19.304-cip106
cip/4.19-rtFixed in 4.19.306-cip107-rt35
cip/4.4Fixed in 4.4.302-cip83
cip/4.4-rtFixed in 4.4.302-cip83-rt47