Re: SETUID perl script leaves backdoor open after dropping privileges

2012-04-25 Thread Ted Unangst
On Wed, Apr 25, 2012 at 07:15, Christopher Zimmermann wrote: > As requested, here's the same test case a little more readable: > > This leaves a backdoor open (possibly in the saved UID): Yes, if you don't clear the saved uid, you can still switch back to it. You should use setresuid if it's ava

Re: SETUID perl script leaves backdoor open

2012-04-25 Thread Christopher Zimmermann
After short testing I found a bug or at least a dangerous pitfall. This leaves a backdoor open (probably in the saved UID): #!/usr/bin/perl -wT use strict; require POSIX; sub ids () { print "RUID=$< EUID=$> RGID=$( EGID=$)\n" } print "Running $^X $0\n"; ids; $> = $< = $<; ids; $> = $< = 0; id

Re: SETUID perl script leaves backdoor open after dropping privileges

2012-04-24 Thread Christopher Zimmermann
As requested, here's the same test case a little more readable: This leaves a backdoor open (possibly in the saved UID): == #!/usr/bin/perl -wT use strict; use English qw(-no_match_vars); sub ids { print "RUID=$REAL_USER_ID EUID=$EFFECTIVE_USER_ID\n" } ids;

Re: SETUID perl script leaves backdoor open

2012-04-24 Thread Christopher Zimmermann
After short testing I found a bug or at least a dangerous pitfall. This leaves a backdoor open (probably in the saved UID): #!/usr/bin/perl -wT use strict; require POSIX; sub ids () { print "RUID=$< EUID=$> RGID=$( EGID=$)\n" } print "Running $^X $0\n"; ids; $> = $< = $<; ids; $> = $< = 0; i

Re: SETUID perl script

2012-04-24 Thread Christopher Zimmermann
On Tue, 24 Apr 2012 14:48:18 -0500 Matthew Weigel wrote: > On 24.04.2012 14:22, Christopher Zimmermann wrote: > > Hi, > > > > I'm trying to chroot and drop privileges in a perl script. But > > somehow > > I'm not even able to run it setuid root. The setuid bit gets ignored > > completely. But as

Re: SETUID perl script

2012-04-24 Thread Matthew Weigel
On 24.04.2012 14:22, Christopher Zimmermann wrote: Hi, I'm trying to chroot and drop privileges in a perl script. But somehow I'm not even able to run it setuid root. The setuid bit gets ignored completely. But as I understand sys/sys/exec_script.h. The SETUIDSCRIPTS feature is enabled by defa

SETUID perl script

2012-04-24 Thread Christopher Zimmermann
Hi, I'm trying to chroot and drop privileges in a perl script. But somehow I'm not even able to run it setuid root. The setuid bit gets ignored completely. But as I understand sys/sys/exec_script.h. The SETUIDSCRIPTS feature is enabled by default. What am I missing? /tmp% ls -l test.pl -rwsrwx-