Use-After-Free In IPV6_2292PKTOPTIONS leading To Arbitrary Kernel R/W Primitives
A missing lock in the handling of the IPV6_2292PKTOPTIONS socket option allows a race condition that frees a kernel buffer while it is still in use. An attacker can hijack pointers in the freed structure to gain arbitrary kernel read/write and achieve code execution.
Originally disclosed on HackerOne
- Triaged in 4 days
- Fixed in 35 days
- Paid in 5 days
- Disclosed after 4 months
Summary
Due to missing locks in option IPV6_2292PKTOPTIONS of setsockopt , it is possible to race and free the struct ip6_pktopts buffer, while it is being handled by ip6_setpktopt. This structure contains pointers (ip6po_pktinfo) that can be hijacked to obtain arbitrary kernel R/W primitives. As a consequence, it is easy to have kernel code execution. This vulnerability is reachable from WebKit sandbox and is available in the latest FW, that is 7.02.
Attachment
Attached is a Proof-Of-Concept that achieves a Local Privilege Escalation on FreeBSD 9 and FreeBSD 12.
Impact
- In conjunction with a WebKit exploit, a fully chained remote attack can be achieved.
- It is possible to steal/manipulate user data.
- Dump and run pirated games.
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 path for IPV6_2292PKTOPTIONS in setsockopt lacks proper locking, allowing a race between freeing and using the ip6_pktopts structure.
Impact
An attacker could escalate privileges locally and, combined with a WebKit exploit, achieve a fully chained remote attack; the vulnerability is reachable from the WebKit sandbox and present in the latest firmware.
What the attacker needed
Local access to the device; ability to trigger setsockopt; WebKit sandbox escape for remote chain
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.
When a program sets a network option, the operating system kernel stores some data in memory. Here, two actions can happen at the same time: one frees that memory while another still uses it, which is called a use-after-free. Because the freed memory still contains pointers the kernel trusts, an attacker can take control of the kernel.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.