Skip to main content

SwiftNIO CVE-2026-43671

HIGH
Out-of-bounds Write (CWE-787)
2026-06-12 https://github.com/apple/swift-nio GHSA-r3rc-9hpw-54v9
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Identify SwiftNIO service accepting large input
  2. Delivery
    Send payload with length field > UInt32.max
  3. Exploit
    Trigger _toIndex/_toCapacity truncation
  4. Execution
    Bypass ByteBuffer precondition checks
  5. Persist
    Out-of-bounds write via copyBytes or writeWithUnsafeMutableBytes
  6. Impact
    Corrupt adjacent heap memory for RCE or crash

Vulnerability Assessment

Weakness
CWE
ASVS 5.0
V15 - Secure Coding and Architecture Bounds checking, write limits
MITRE ATT&CK

2 techniques across 2 tactics: Execution, Privilege Escalation

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

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). Limiting factors: these write APIs are typically not used on protocol read paths (most attacker-influenced lengths come from parsing inbound data, which the advisory notes is not the vulnerable surface); the application must compute write positions arithmetically from untrusted input or genuinely process payloads >4 GiB; moveReaderIndex/moveWriterIndex and the takingOwnershipOf initialiser exhibit the bug but are explicitly NOT memory-unsafe per the advisory; and on platforms where Int is 32-bit the truncation cannot occur. Authentication requirements not confirmed from available data - the CVSS vector is not provided, and the exploit prerequisite is application-specific rather than tied to a single network-facing endpoint.

Impact

No CVSS, EPSS, or KEV signals are provided, so prioritization must be driven by the description. The vulnerability is memory-safety relevant (CWE-787) but gated by a very specific precondition: the attacker must steer an index, offset, or length above UInt32.max (~4 GiB) into one of two ByteBuffer write APIs (copyBytes(at:to:length:) or writeWithUnsafeMutableBytes(minimumWritableBytes:)). The advisory itself notes this is a high bar - typical NIO read paths do not call these methods, and most protocol parsers derive sizes from on-wire fields constrained well below 4 GiB. Realistic risk concentrates on SwiftNIO-based services that (a) process or accept very large payloads, or (b) compute write offsets arithmetically from untrusted input. Where those conditions hold, impact is severe (heap corruption in release builds, with assertions unreliable in debug builds). Where they do not, the bug manifests at most as logical corruption of outbound packets. No public exploit identified at time of analysis, and exploitation status is not in CISA KEV, so this should be treated as a patch-soon hygiene fix for the broad fleet and a higher priority for services known to handle multi-gigabyte buffers or attacker-influenced write offsets.

Exploit ScenarioDerived

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. No public PoC is identified at time of analysis, but the advisory itself describes the exploit primitive in enough detail that targeted exploit development against a vulnerable service is plausible.

This Week Schedule remediation this week. Why: HIGH severity (CVSS 7.0-8.9).
No patch listed yet 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Jun 12, 2026

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. No public exploit identified at time of analysis, and the high data-size threshold makes practical exploitation narrow but severe where applicable.

RemediationAI

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. Confirm the upgrade reaches the resolved dependency graph because indirect pins via frameworks like gRPC-Swift, AsyncHTTPClient, or Vapor can hold older swift-nio versions. Until the upgrade is rolled out, the vendor-suggested workaround is to validate at the application boundary that any Int passed as index, offset, length, or minimumWritableBytes to ByteBuffer methods is <= UInt32.max (4,294,967,295) and reject or clamp larger values; this is low-risk for typical protocol code but requires auditing call sites that compute offsets arithmetically from network-derived integers. Side effects: the upgrade converts what was silent truncation into a deterministic trap, so any code path that previously relied on (or accidentally produced) >4 GiB Int values will now crash instead of silently misbehaving - surface this in pre-deployment testing. Advisory reference: https://github.com/apple/swift-nio/security/advisories/GHSA-r3rc-9hpw-54v9.

Affects your stack

Find out whether the stacks and servers you run are on an affected version.

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

SwiftNIO is Apple's cross-platform asynchronous event-driven network application framework that underpins many server-side Swift applications and Apple ecosystem services (HTTP/2, TLS, gRPC stacks, etc.). Its ByteBuffer type stores indices and capacities internally as UInt32 and relied on the _toIndex and _toCapacity helpers, which used UInt32(truncatingIfNeeded:) to narrow Int to UInt32. On 64-bit platforms this discards the upper 32 bits instead of trapping, so values like 0x1_0000_0000 collapse to 0 before bounds checks run. This is a classic CWE-787 (Out-of-bounds Write) rooted in an integer-truncation/wraparound issue: the truncated value passes preconditions (and even debug assertions, because the assertion sees the already-narrowed value), after which copyBytes(at:to:length:) or writeWithUnsafeMutableBytes(minimumWritableBytes:) operate on attacker-chosen offsets and can write past the allocated buffer.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

vuln.today AI 7.4 HIGH

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.

3.1 AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:H
4.0 AV:N/AC:H/AT:P/PR:N/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N

Estimated by vuln.today — no official severity rating has been published for this CVE yet.

DescriptionCVE.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 exceeding UInt32.max could copy bytes to an incorrect offset.
  • writeWithUnsafeMutableBytes(minimumWritableBytes:) - a crafted minimumWritableBytes exceeding UInt32.max could 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 exceeding UInt32.max could 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 than UInt32.max bytes could create a ByteBuffer with 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.

Executive ViewAI

Why It Matters

Apple's SwiftNIO ByteBuffer contains an out-of-bounds write vulnerability affecting versions 1.0.0 through 2.99.0; no public exploit identified at time of analysis, but memory corruption capability poses significant risk if exploited. Organizations using affected versions face potential service disruption and data compromise, particularly those handling untrusted data at scale. Immediate inventory of SwiftNIO usage and version identification is required to assess organizational exposure.

Business Impact: High
Compensating Controls

No vendor-released patch identified at time of analysis. Interim mitigations: (1) Implement strict input validation and size limits on untrusted data passed to ByteBuffer operations; (2) Enable memory protection (ASLR, DEP/NX) on all affected systems; (3) Segment network access to services using SwiftNIO; (4) Monitor memory utilization and access patterns for anomalies; (5) Maintain detailed logging of ByteBuffer operations. Monitor Apple advisories for SwiftNIO 2.100.0 release and deploy immediately upon availability.

Threat Intelligence Overview

EPSS Score
0.0%
Top 87% exploitable
Threat Intel
1
1 source
Data Quality
2 sources
Confidence: Low
CVE.org EPSS GHSA GitHub

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity HIGH
CISA KEV No
Public POC No
EPSS 0.0%
Patch available No
Active threat No
Deciding rule
HIGH severity (CVSS 7.0-8.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

Attack Technique

A buffer overflow occurs when a program writes more data to a memory buffer than it was allocated to hold, causing the excess data to spill into adjacent memory regions.

Memory corruption occurs when a program writes data beyond the boundaries of allocated memory regions or accesses memory in unintended ways, violating the integrity of the process's address space.

Affected Products (CPE)CVE.org

pkg:swift/github.com_apple_swift-nio

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy