# Use-After-Free In IPV6_2292PKTOPTIONS leading To Arbitrary Kernel R/W Primitives

Missing locks in IPV6_2292PKTOPTIONS setsockopt let an attacker race-free struct ip6_pktopts and hijack ip6po_pktinfo pointers for arbitrary kernel R/W and LPE.

- Payout: $10,000
- Severity: high
- Program: PlayStation
- Found by: theflow0
- Disclosed: 2020-07-06
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/826026
- Library page: https://bugbountylibrary.com/r/h1%3A826026
- Tags: area:cloud domain:infra impact:privesc impact:rce kind:bounty platform:hackerone sev:high technique:chained technique:race-window technique:source-review vuln:memory-corruption vuln:privilege-escalation vuln:race-condition

**Target:** FreeBSD kernel IPv6 setsockopt (IPV6_2292PKTOPTIONS) on PlayStation 4
**Root cause:** ip6_setpktopt handles the struct ip6_pktopts buffer without proper locking, so a concurrent setsockopt can free it while still in use (UAF). The freed struct contains ip6po_pktinfo pointers that can be reclaimed and hijacked.
**Steps:**
1. Open an IPv6 socket.
2. Thread A: call `setsockopt(fd, IPPROTO_IPV6, IPV6_2292PKTOPTIONS, ...)` to allocate/handle struct ip6_pktopts in ip6_setpktopt.
3. Thread B: concurrently call setsockopt on the same option to free the buffer while Thread A still references it.
4. Reclaim the freed struct ip6_pktopts with attacker-controlled data, overwriting ip6po_pktinfo pointers.
5. Trigger use of the hijacked pointer to obtain arbitrary kernel read/write, then escalate to kernel code execution.
**How found:** Code review of ip6_setpktopt revealed missing locks around the IPV6_2292PKTOPTIONS buffer, suggesting a race window where the struct could be freed while in use.
**Exploitation:** Race two setsockopt calls on IPV6_2292PKTOPTIONS to free struct ip6_pktopts mid-handling, reclaim it with controlled contents to hijack ip6po_pktinfo pointers, yielding arbitrary kernel R/W and then kernel code execution; reachable from the WebKit sandbox for a full remote chain.
**Escalation:** Chained with a WebKit exploit to convert sandbox-reachable UAF into full remote kernel compromise on PS4 firmware 7.02.
**Insight:** setsockopt option handlers that allocate/copy per-option structs (like ip6_pktopts) are prime UAF targets when locking is asymmetric; audit each option path for free-vs-use races and check whether the struct holds kernel pointers usable for R/W.

