Apple macOS SMB server directory query request integer overflow vulnerability
An integer overflow in the macOS SMB server's handling of directory query requests can cause an out-of-bounds write, corrupting a stack pointer. An attacker could potentially achieve remote code execution or cause a denial of service by sending a crafted SMB packet.
Originally disclosed on Cisco Talos
A memory corruption vulnerability exists in the SMB Server on Apple macOS 11.2. A specially crafted SMB packet can trigger an integer overflow when handling directory query requests which can result in memory corruption, potentially leading to remote code execution and denial of service.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the code negates an error return value from a UTF-16 to UTF-8 conversion function and uses it as an index without proper bounds checking, leading to an integer wraparound and out-of-bounds write.
Impact
This could lead to remote code execution if the attacker can control the memory layout, or at least a denial of service via crash.
What the attacker needed
Network access to SMB service; authentication (PR:L)
The fix
The vulnerability was fixed by Apple in macOS 11.2 (vendor patched on 2021-05-25).
How it was found
- Send an SMB2 QUERY_DIRECTORY request with a search pattern containing an illegal Unicode sequence.
- The server's ConvertUTF16toUTF8 function returns an error code (e.g., 3).
- The error code is negated and sign-extended, producing a large negative value used as an index.
- A null byte is written out of bounds, corrupting a pointer on the stack.
- When the corrupted pointer is later dereferenced, a crash or potential code execution occurs.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The SMB server on macOS has a bug when it processes a request to list a folder's contents. If the folder name contains invalid characters, the server miscalculates where to write a zero byte, writing it far outside the intended buffer and corrupting memory. This could let an attacker run their own code on the machine or crash the server.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.