SwiftNIO CVE-2026-43671
HIGHSeverity by source
Network-reachable services can be targeted (AV:N) without auth or interaction, but the >4 GiB precondition and need for a write-path call site make AC:H; impact is heap corruption (I:H/A:H) with no direct confidentiality vector described.
Estimated by vuln.today — no official severity rating has been published for this CVE yet.
Lifecycle Timeline
2DescriptionCVE.org
Summary
A program using swift-nio is vulnerable to a potential out-of-bounds write when attacker-controlled index or length values exceeding UInt32.max are passed to some ByteBuffer methods. This affects all swift-nio versions from 1.0.0 to 2.99.0. It is fixed in 2.100.0 and later releases.
Details
ByteBuffer internally stores indices and capacities as UInt32 values. The internal helper functions _toIndex and _toCapacity, which convert from Int to UInt32, used UInt32(truncatingIfNeeded:). On 64-bit platforms, this silently discards the upper 32 bits of the value rather than trapping on overflow. For example, a value of UInt32.max + 1 (0x100000000) would be truncated to 0.
This truncation can cause safety preconditions to pass when they should fail. Subsequent operations would then use the incorrect truncated value, potentially leading to out-of-bounds memory writes or reads.
The affected ByteBuffer methods that may lead to out-of-bounds writes are:
copyBytes(at:to:length:)- a crafted destination index exceedingUInt32.maxcould copy bytes to an incorrect offset.writeWithUnsafeMutableBytes(minimumWritableBytes:)- a craftedminimumWritableBytesexceedingUInt32.maxcould provide the caller with a buffer pointer of incorrect length, which can easily be subsequently overflowed.
The affected ByteBuffer methods that have logic errors but do neither expose out-of-bounds reads nor out-of-bounds writes:
moveReaderIndex(forwardBy:)/moveWriterIndex(forwardBy:)- a crafted offset exceedingUInt32.maxcould move indices to incorrect positions, bypassing bounds checks. These indices cannot be out of the bounds of the buffer, so they do not expose access to uninitialized memory or produce wild pointers.- The
ByteBuffer(takingOwnershipOf:allocator:)initialiser - passing a buffer larger thanUInt32.maxbytes could create aByteBufferwith an incorrect capacity.
Outside of these methods, there are still impacts, but they are simply logical bugs. In these cases applications can be forced to read from or write to unexpected parts of the buffer. This does not cause memory-safety issues, but it can cause logical issues or corruption of outbound packets.
Impact
Exploitation requires an attacker to influence the index, offset, or length parameter of the affected ByteBuffer methods with a value exceeding UInt32.max (approximately 4 GiB). This is a high bar for most applications: attacker-controlled length parameters to ByteBuffer are typically used on the read path, and the above methods are typically not used on the read paths. However, applications that calculate buffer positions arithmetically from untrusted input when attempting to do writes, or that process very large payloads, may be at risk of memory safety issues.
Other applications may encounter logical issues due to reading unexpected bytes, or writing to unexpected parts of the buffer.
When the memory-safety issue is exploitable, the consequences are severe. Because truncatingIfNeeded silently produces an incorrect but valid UInt32 value, subsequent operations may write to or read from memory outside the valid buffer region. In optimised (release) builds where preconditions are not checked, this could lead to out-of-bounds memory writes, potentially corrupting adjacent heap memory.
In debug builds, some of these conditions are caught by assertions, but truncatingIfNeeded occurs before the assertion checks the (already-truncated) value, so even assertions may not reliably catch the issue.
Patches
The issue is fixed by replacing UInt32(truncatingIfNeeded:) with UInt32(_:) in the _toIndex and _toCapacity helper functions. The UInt32(_:) initialiser traps on overflow in both debug and release builds, converting a potential silent memory corruption into a deterministic crash.
One call site in getSlice(at:length:) retains truncatingIfNeeded because prior bounds checks against the non-truncated Int values mathematically guarantee the values fit within UInt32.
Workarounds
Applications can mitigate this issue by validating that all index and length values passed to ByteBuffer methods do not exceed UInt32.max (4,294,967,295). In practice, most applications are not affected because buffer indices are derived from protocol parsing rather than raw untrusted input.
AnalysisAI
Out-of-bounds write in Apple's SwiftNIO ByteBuffer affects all releases from 1.0.0 through 2.99.0 and is fixed in 2.100.0. The flaw stems from UInt32 truncation in internal index/capacity converters, so when an attacker can influence an index, offset, or length passed to specific ByteBuffer write methods with a value above UInt32.max (~4 GiB), safety preconditions silently pass and subsequent writes can corrupt heap memory outside the buffer. …
Unlock full vulnerability intelligence
- Risk assessment & exploitation conditions
- Attack chain visualization
- Remediation with exact patch versions
- Threat intelligence from 22 sources
- Personal watchlist & email alerts
Free forever · No credit card required
Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata
Vulnerability AssessmentAI
| Exploitation | Exploitation requires the target application to invoke ByteBuffer.copyBytes(at:to:length:) or ByteBuffer.writeWithUnsafeMutableBytes(minimumWritableBytes:) on swift-nio 1.0.0-2.99.0 running on a 64-bit platform, AND for the attacker to be able to drive the destination index, offset, or minimumWritableBytes parameter to a value greater than UInt32.max (4,294,967,295 / ~4 GiB). … Additional conditions and limiting factors are described in the full assessment. |
| Risk Assessment | No CVSS, EPSS, or KEV signals are provided, so prioritization must be driven by the description. … Full risk analysis with EPSS, KEV, and SSVC signal comparison available after sign-in. |
| Exploit Scenario | A SwiftNIO-based service that accepts large uploads computes a write destination by adding an attacker-supplied 64-bit length field to a base offset and calls ByteBuffer.copyBytes(at:to:length:) or writeWithUnsafeMutableBytes(minimumWritableBytes:) with the result. By choosing a value just above 0x1_0000_0000 the attacker causes the helper to truncate to a small UInt32, the precondition passes, and the subsequent write lands outside the buffer, corrupting adjacent heap memory in a release build. … |
| Remediation | Upgrade swift-nio to 2.100.0 or later (vendor-released patch: 2.100.0), then rebuild and redeploy any application or library that links it; transitive consumers should bump their Package.swift constraints and run swift package update. … Detailed patch versions, workarounds, and compensating controls in full report. |
Recommended ActionAI
Within 24 hours: Conduct comprehensive asset inventory to identify all systems, services, and applications using SwiftNIO and document current versions in use. …
Sign in for detailed remediation steps and compensating controls.
Threat intelligence, references, and detailed analysis are available after sign-in.
Share
External POC / Exploit Code
Leaving vuln.today
GHSA-r3rc-9hpw-54v9