Rapid7 Vulnerability & Exploit Database

FreeBSD ip6_setpktopt Use-After-Free Privilege Escalation

Back to Search

FreeBSD ip6_setpktopt Use-After-Free Privilege Escalation

Disclosed
07/07/2020
Created
07/30/2020

Description

This module exploits a race and use-after-free vulnerability in the FreeBSD kernel IPv6 socket handling. A missing synchronization lock in the `IPV6_2292PKTOPTIONS` option handling in `setsockopt` permits racing `ip6_setpktopt` access to a freed `ip6_pktopts` struct. This exploit overwrites the `ip6po_pktinfo` pointer of a `ip6_pktopts` struct in freed memory to achieve arbitrary kernel read/write. This module has been tested successfully on: FreeBSD 9.0-RELEASE #0 (amd64); FreeBSD 9.1-RELEASE #0 r243825 (amd64); FreeBSD 9.2-RELEASE #0 r255898 (amd64); FreeBSD 9.3-RELEASE #0 r268512 (amd64); FreeBSD 12.0-RELEASE r341666 (amd64); and FreeBSD 12.1-RELEASE r354233 (amd64).

Author(s)

  • Andy Nguyen
  • bcoles <bcoles@gmail.com>

Platform

BSD

Architectures

x64

Development

Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use exploit/freebsd/local/ip6_setpktopt_uaf_priv_esc
msf exploit(ip6_setpktopt_uaf_priv_esc) > show targets
    ...targets...
msf exploit(ip6_setpktopt_uaf_priv_esc) > set TARGET < target-id >
msf exploit(ip6_setpktopt_uaf_priv_esc) > show options
    ...show and set options...
msf exploit(ip6_setpktopt_uaf_priv_esc) > exploit

Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.

– Jim O’Gorman | President, Offensive Security

;