Rapid7 Vulnerability & Exploit Database

Linux Polkit pkexec helper PTRACE_TRACEME local root exploit

Back to Search

Linux Polkit pkexec helper PTRACE_TRACEME local root exploit



This module exploits an issue in ptrace_link in kernel/ptrace.c before Linux kernel 5.1.17. This issue can be exploited from a Linux desktop terminal, but not over an SSH session, as it requires execution from within the context of a user with an active Polkit agent. In the Linux kernel before 5.1.17, ptrace_link in kernel/ptrace.c mishandles the recording of the credentials of a process that wants to create a ptrace relationship, which allows local users to obtain root access by leveraging certain scenarios with a parent-child process relationship, where a parent drops privileges and calls execve (potentially allowing control by an attacker). One contributing factor is an object lifetime issue (which can also cause a panic). Another contributing factor is incorrect marking of a ptrace relationship as privileged, which is exploitable through (for example) Polkit's pkexec helper with PTRACE_TRACEME.


  • Jann Horn
  • bcoles <bcoles@gmail.com>
  • timwr






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/linux/local/ptrace_traceme_pkexec_helper
msf exploit(ptrace_traceme_pkexec_helper) > show targets
msf exploit(ptrace_traceme_pkexec_helper) > set TARGET < target-id >
msf exploit(ptrace_traceme_pkexec_helper) > show options
    ...show and set options...
msf exploit(ptrace_traceme_pkexec_helper) > 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