Apple macOS SMB server TREE_CONNECT stack buffer overflow vulnerability
A stack buffer overflow in the macOS SMB server's handling of TREE_CONNECT requests allows a remote attacker to overwrite stack memory with a long share path, potentially leading to arbitrary code execution or denial of service.
Originally disclosed on Cisco Talos
A remote code execution vulnerability exists in the SMB Server Apple macOS 10.15.7. A specially crafted SMB packet can trigger a stack-based buffer overflow, which can lead to arbitrary 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
The TREE_CONNECT handler copies a user-supplied path into a fixed-size stack buffer without checking its length.
Impact
A remote attacker could cause a denial of service or potentially execute arbitrary code on the affected system.
What the attacker needed
Network access to SMB service; valid SMB session (authenticated)
The fix
The vulnerability was fixed by the vendor in a patch released on 2021-05-25.
How it was found
- Set a breakpoint at smb2_dispatch_tree_connect to observe the TREE_CONNECT buffer.
- Send a crafted TREE_CONNECT request with an overly long share path.
- Continue execution to the memcpy call and observe the parameters.
- Step over the memcpy and observe a crash due to overwritten stack memory.
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 fixed-size memory area on the stack for storing the share path from a network request. If an attacker sends a path longer than that area, it spills over and corrupts other memory, which can crash the server or let the attacker run their own code.
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.