[tz] [PROPOSED] Don’t assume nonempty argv

Guy Harris gharris at sonic.net
Sat Oct 29 20:34:52 UTC 2022


On Oct 29, 2022, at 1:01 PM, Steffen Nurpmeso <steffen at sdaoden.eu> wrote:

> Guy Harris wrote in
> <C690F5F6-E5D4-4EAD-BEFA-3252DF022EE9 at sonic.net>:
> |On Oct 28, 2022, at 11:56 PM, Paul Eggert via tz <tz at iana.org> wrote:
> |> Don’t dump core if argv[0] is NULL, which is allowed on
> |> GNU/Linux if the invoker is sufficiently perverse.
> |
> |Is argc == 0 in that case?
> 
> Just to add this was CVE-2021-4034.

	https://nvd.nist.gov/vuln/detail/cve-2021-4034

"A local privilege escalation vulnerability was found on polkit's pkexec utility. The pkexec application is a setuid tool designed to allow unprivileged users to run commands as privileged users according predefined policies. The current version of pkexec doesn't handle the calling parameters count correctly and ends trying to execute environment variables as commands. An attacker can leverage this by crafting environment variables in such a way it'll induce pkexec to execute arbitrary code. When successfully executed the attack can cause a local privilege escalation given unprivileged users administrative rights on the target machine."

See the Qualys blog entry on this:

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

And a fix for that was committed in...

	https://gitlab.freedesktop.org/polkit/polkit/-/commit/a2bf5c9c83b6ae46cbd5c779d3055bff81ded683

January 2022.

pkexec was parsing the flag arguments with

	for (n = 1; n < argc; n++) {
		if (it's a flag argument)
			process it;
		else
			break;
	}

and assuming, afterwards, that argv[n], if non-null, is the first non-flag argument.

That meant, if *no* arguments were passed to it, it would go past the end of the array, which stands a good chance of fetching the first element of the array of environment variable settings.

The fix was to check, at the beginning of main(), whether argc < 1 and, if so, quitting immediately.


More information about the tz mailing list