[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ITP: sid - Run commands in your /sid chroot



[Bill Allombert]
> #include <unistd.h>
> #include <sys/types.h>
> #include <stdio.h>
> #include <errno.h>
> #include <stdlib.h>
> #include <string.h>
> #define CHROOT_PATH "/sid/"

I'd encase this in #ifndef CHROOT_PATH, so you can change it on the
compile line and thus quickly build multiple binaries.

> #define LEN_CHROOT_PATH strlen(CHROOT_PATH)

Not used.

>   char *shell;
>   if (chroot(CHROOT_PATH)) die("chroot");
>   if (seteuid(getuid())) die("seteuid");
>   /*Now most security problem are ended.*/

FYI, chroot() does not imply chdir().  so your current directory isn't
inside the chroot yet, and so long as this is true, a user can use
relative paths (including ../../../../) to navigate arbitrarily.

This isn't a security problem in *your* application, but it probably
*is* unexpected behavior.  I suggest saving the cwd in a char[] before
the chroot, then doing chdir("/") followed by chdir(old_cwd).

Attachment: signature.asc
Description: Digital signature


Reply to: