`UnixType.init(path:)` uses a macOS length limit longer than the `sockaddr_un.sun_path` buffer it copies into
MediumPublished Sep 9, 2026
## Impact An attacker who can influence the Unix-domain socket pathname that a macOS host application passes into `UnixType.init(path:)` can supply a pathname of 105–252 UTF-8 bytes to overflow the stack-allocated `sockaddr_un` before any socket syscall runs, corrupting the host process's stack. This requires a host application to accept an attacker-influenced pathname and forward it to this initializer — for example, through `Containerization`'s Unix-socket relay configuration — rather than being reachable directly from a container guest or a registry. The confirmed effect is stack corruption and process abort under memory-safety instrumentation. ## Details `UnixType.init(path:)` checks a candidate path's UTF-8 byte length against `lengthLimit` before copying it into the native `sockaddr_un.sun_path` field. On macOS that limit was hardcoded to 253 bytes, unrelated to `sun_path`'s actual 104-byte capacity. In Swift, `sockaddr_un` has a fixed Swift-visible size, and `UnixType.init(path:)` stack-allocates exactly that fixed-size value. The initializer then copies `nameLength` bytes into `sun_path` via `strncpy`, so any path accepted by the 253-byte check but longer than 104 byte...
Affected versions
| Package | Affected | Fixed in |
|---|---|---|
| apple/containerization Product | < 0.45.0 | 0.45.0 |
Details and references
## Impact An attacker who can influence the Unix-domain socket pathname that a macOS host application passes into `UnixType.init(path:)` can supply a pathname of 105–252 UTF-8 bytes to overflow the stack-allocated `sockaddr_un` before any socket syscall runs, corrupting the host process's stack. This requires a host application to accept an attacker-influenced pathname and forward it to this initializer — for example, through `Containerization`'s Unix-socket relay configuration — rather than being reachable directly from a container guest or a registry. The confirmed effect is stack corruption and process abort under memory-safety instrumentation. ## Details `UnixType.init(path:)` checks a candidate path's UTF-8 byte length against `lengthLimit` before copying it into the native `sockaddr_un.sun_path` field. On macOS that limit was hardcoded to 253 bytes, unrelated to `sun_path`'s actual 104-byte capacity. In Swift, `sockaddr_un` has a fixed Swift-visible size, and `UnixType.init(path:)` stack-allocates exactly that fixed-size value. The initializer then copies `nameLength` bytes into `sun_path` via `strncpy`, so any path accepted by the 253-byte check but longer than 104 bytes overflows past the entire stack-allocated struct, not just past the `sun_path` field, writing 1–148 attacker-controlled bytes into adjacent stack memory. ## Affected code - `UnixType.init(path:)` in `Sources/ContainerizationOS/Socket/UnixType.swift` — used a macOS-specific `lengthLimit` of 253 bytes to gate a copy into the 104-byte `sun_path` field. Not affected: the Linux branch of the same initializer, which already derived `lengthLimit` from `sun_path`'s actual size. Triggering this also requires an application-level path: the in-repository relay call sites (`Sources/Containerization/UnixSocketRelay.swift`) use host-controlled filesystem paths, so a concrete exploit needs a host application that forwards an attacker-influenced pathname into `UnixType.init(path:)`. ## Mitigations 1. Upgrade to the version of `apple/containerization` containing the fix. 2. If you can't upgrade immediately, validate that any Unix-domain socket pathname reaching `UnixType.init(path:)` is well under 104 bytes before calling it. 3. Don't let externally-influenced values (registry-supplied image metadata, network input, etc.) reach a Unix-socket relay path or any other caller of `UnixType.init(path:)` without going through your own length check first. ## References https://github.com/apple/containerization/pull/917
- Severity from
- GitHub (reviewed advisory)
More Apple advisories
All Apple| Date | Advisory | Severity | Fixed in |
|---|---|---|---|
| Sep 14 | Apple iOS and iPadOS: out-of-bounds write | Medium4.3 | 26.7+2 more |
| Sep 14 | Apple iOS and iPadOS: denial of service | High7.5 | 18.7.10 |
| Sep 14 | A privacy issue was addressed by moving sensitive data | High7.5 | 26.6 |
| Sep 14 | Apple macOS: improper access control | Medium5.5 | 27 |
| Sep 14 | Apple iOS and iPadOS: improper authentication | High7.1 | 27+2 more |
| Sep 9 | OCI image load follows symlinks for `oci-layout` and `index.json` outside the extraction directory | Medium | 0.45.0+1 more |