You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Joe Orton <jo...@redhat.com> on 2009/02/23 12:37:56 UTC

Re: svn commit: r746589 - in /apr/apr/trunk: ./ include/ include/arch/unix/ include/arch/win32/ misc/unix/ misc/win32/ threadproc/beos/ threadproc/netware/ threadproc/os2/ threadproc/unix/ threadproc/win32/

On Sat, Feb 21, 2009 at 08:59:47PM -0000, Mladen Turk wrote:
> Author: mturk
> Date: Sat Feb 21 20:59:46 2009
> New Revision: 746589
> 
> URL: http://svn.apache.org/viewvc?rev=746589&view=rev
> Log:
> Add simple parent/child data exchange for APR processes

1) another addition to the procattr API which is entirely orthogonal to 
the API's purpose.  ick.

2) every apr_initialize() call for every app in the universe now tries 
to open some random file in /tmp regardless of whether they use this API

3) fundamental /tmp race (the temp file name is predictable and hence 
another local user could create the shm file and populate the data 
segment which would be picked up by the child) and hence is huge 
security hole

-1


Re: svn commit: r746589 - in /apr/apr/trunk: ./ include/ include/arch/unix/ include/arch/win32/ misc/unix/ misc/win32/ threadproc/beos/ threadproc/netware/ threadproc/os2/ threadproc/unix/ threadproc/win32/

Posted by Greg Stein <gs...@gmail.com>.
On Mon, Feb 23, 2009 at 13:16, Mladen Turk <mt...@apache.org> wrote:
> Joe Orton wrote:
>...
>> -1
>
> I announced that twice on this list during the last year,
> so you should spoke then thought.

And people miss email. Or they thought it might be implemented
differently. Or WHATEVER.

It doesn't matter. There is no time limit on standing against a
change. It is possible to veto something that was checked in *months*
ago. That change would then have to be backed out before release, or
some solution/compromise reached instead.

I'm also with Joe: stuff like this can be built *on top of* APR,
rather than being part of it. Create a shared memory segment, and pass
a cmdline switch. Or leave a descriptor open with the name of the
segment which the parent/child can write/read. These solutions could
be done as part of apr-util, no?

Cheers,
-g

Re: svn commit: r746589 - in /apr/apr/trunk: ./ include/ include/arch/unix/ include/arch/win32/ misc/unix/ misc/win32/ threadproc/beos/ threadproc/netware/ threadproc/os2/ threadproc/unix/ threadproc/win32/

Posted by Joe Orton <jo...@redhat.com>.
On Mon, Feb 23, 2009 at 04:05:26PM +0100, Mladen Turk wrote:
> Joe Orton wrote:
>>
>>> Also shm name is not predictable because the child pid is not
>>> known in advance (well one can make all 1...PID_MAX shm's, sure),
>>
>> tmp races are a security issue regardless of pid predicatibility (and 
>> in fact, pids are predictable on many platforms).
>>
>
> I made it unique. It can still fail in theory during the
> transition from two consequtive api calls
> (file_close and shm_create)

So the race is still there, and if an attacker wins that race, he can 
substitute a shm segment containing arbitrary data which the child 
process will pick up.  -1 stands on that basis.

Using an env var is also completely bizarre.  I can't imagine why on 
earth an application would want to work like this, rather than e.g. 
creating a shm segment in the parent and passing the name as a 
command-line option to the exec'ed child - or using a common config 
file.  Or using hard-coded paths.  But trying to shove this all into 
apr_proc_create() just seems like a disaster.

Regards, Joe


Re: svn commit: r746589 - in /apr/apr/trunk: ./ include/ include/arch/unix/ include/arch/win32/ misc/unix/ misc/win32/ threadproc/beos/ threadproc/netware/ threadproc/os2/ threadproc/unix/ threadproc/win32/

Posted by Mladen Turk <mt...@apache.org>.
Joe Orton wrote:
> 
>> Also shm name is not predictable because the child pid is not
>> known in advance (well one can make all 1...PID_MAX shm's, sure),
> 
> tmp races are a security issue regardless of pid predicatibility (and in 
> fact, pids are predictable on many platforms).
> 

I made it unique. It can still fail in theory during the
transition from two consequtive api calls
(file_close and shm_create)

If you still insist on -1, I'll have to remove it :(

Regards
-- 
^(TM)

Re: svn commit: r746589 - in /apr/apr/trunk: ./ include/ include/arch/unix/ include/arch/win32/ misc/unix/ misc/win32/ threadproc/beos/ threadproc/netware/ threadproc/os2/ threadproc/unix/ threadproc/win32/

Posted by Mladen Turk <mt...@apache.org>.
Joe Orton wrote:
> On Mon, Feb 23, 2009 at 01:16:22PM +0100, Mladen Turk wrote:
>> Joe Orton wrote:
>>> On Sat, Feb 21, 2009 at 08:59:47PM -0000, Mladen Turk wrote:
>>>> Author: mturk
>>>> Date: Sat Feb 21 20:59:46 2009
>>>> New Revision: 746589
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=746589&view=rev
>>>> Log:
>>>> Add simple parent/child data exchange for APR processes
>>> 1) another addition to the procattr API which is entirely orthogonal to
>>> the API's purpose.  ick.
>>>
>> This can always be made using some different solutions.
>> However this one IMHO is the most portable one.
>> If you think the apr_procattr is the wrong group I can
>> rename it to something else, but it's related to
>> process, process attributes and ipc, so there's not
>> very much space for something meaningful.
> 
> "this HTTP server I just wrote is related to sockets, files, and 
> processes, so I'm going to put it in APR"
> 

:)

> I don't see why it needs to be in APR at all.  APR should not become a 
> random dumping ground for utility functions that someone once found 
> useful; APR-util has to-date served that function quite well.
> 

It cannot be part of apr-util cause it's platform specific.
It is created when we know the child pid but before the child starts.

> 
> The parent doesn't fail on the apr_shm_create() error path, it carries 
> on regardless.  Changing it to fail would downgrade the tmp race from a 
> potential escalation of privileges to a DoS; still a security issue.
> 

Right it should fail if it cannot create the shm.

>> Also shm name is not predictable because the child pid is not
>> known in advance (well one can make all 1...PID_MAX shm's, sure),
> 
> tmp races are a security issue regardless of pid predicatibility (and in 
> fact, pids are predictable on many platforms).
> 

Well, this can be easily fixed by making unique tmpfile
and adding apripc.<PID>=tempfile to the env.

Regards
-- 
^(TM)

Re: svn commit: r746589 - in /apr/apr/trunk: ./ include/ include/arch/unix/ include/arch/win32/ misc/unix/ misc/win32/ threadproc/beos/ threadproc/netware/ threadproc/os2/ threadproc/unix/ threadproc/win32/

Posted by Joe Orton <jo...@redhat.com>.
On Mon, Feb 23, 2009 at 01:16:22PM +0100, Mladen Turk wrote:
> Joe Orton wrote:
> > On Sat, Feb 21, 2009 at 08:59:47PM -0000, Mladen Turk wrote:
> >> Author: mturk
> >> Date: Sat Feb 21 20:59:46 2009
> >> New Revision: 746589
> >>
> >> URL: http://svn.apache.org/viewvc?rev=746589&view=rev
> >> Log:
> >> Add simple parent/child data exchange for APR processes
> >
> > 1) another addition to the procattr API which is entirely orthogonal to
> > the API's purpose.  ick.
> >
>
> This can always be made using some different solutions.
> However this one IMHO is the most portable one.
> If you think the apr_procattr is the wrong group I can
> rename it to something else, but it's related to
> process, process attributes and ipc, so there's not
> very much space for something meaningful.

"this HTTP server I just wrote is related to sockets, files, and 
processes, so I'm going to put it in APR"

I don't see why it needs to be in APR at all.  APR should not become a 
random dumping ground for utility functions that someone once found 
useful; APR-util has to-date served that function quite well.

> > 3) fundamental /tmp race (the temp file name is predictable and hence
> > another local user could create the shm file and populate the data
> > segment which would be picked up by the child) and hence is huge
> > security hole
>
> Hmm, that's the shared memory, not the actual file.

Not sure what you mean there?  e.g. with APR_USE_SHMEM_MMAP_TMP they are 
one and the same thing

> Nevertheless the parent creates the shm so it will fail
> if it cannot create shm, so the child won't get started.

The parent doesn't fail on the apr_shm_create() error path, it carries 
on regardless.  Changing it to fail would downgrade the tmp race from a 
potential escalation of privileges to a DoS; still a security issue.

> Also shm name is not predictable because the child pid is not
> known in advance (well one can make all 1...PID_MAX shm's, sure),

tmp races are a security issue regardless of pid predicatibility (and in 
fact, pids are predictable on many platforms).

Regards, Joe

Re: svn commit: r746589 - in /apr/apr/trunk: ./ include/ include/arch/unix/ include/arch/win32/ misc/unix/ misc/win32/ threadproc/beos/ threadproc/netware/ threadproc/os2/ threadproc/unix/ threadproc/win32/

Posted by Mladen Turk <mt...@apache.org>.
Joe Orton wrote:
 > On Sat, Feb 21, 2009 at 08:59:47PM -0000, Mladen Turk wrote:
 >> Author: mturk
 >> Date: Sat Feb 21 20:59:46 2009
 >> New Revision: 746589
 >>
 >> URL: http://svn.apache.org/viewvc?rev=746589&view=rev
 >> Log:
 >> Add simple parent/child data exchange for APR processes
 >
 > 1) another addition to the procattr API which is entirely orthogonal to
 > the API's purpose.  ick.
 >

This can always be made using some different solutions.
However this one IMHO is the most portable one.
If you think the apr_procattr is the wrong group I can
rename it to something else, but it's related to
process, process attributes and ipc, so there's not
very much space for something meaningful.

 > 2) every apr_initialize() call for every app in the universe now tries
 > to open some random file in /tmp regardless of whether they use this API
 >

I suppose the late open on explicit
apr_proc_parent_ipc_data_get would be smarter solution
and wouldn't impose any performance degradation.

 > 3) fundamental /tmp race (the temp file name is predictable and hence
 > another local user could create the shm file and populate the data
 > segment which would be picked up by the child) and hence is huge
 > security hole
 >

Hmm, that's the shared memory, not the actual file.
Nevertheless the parent creates the shm so it will fail
if it cannot create shm, so the child won't get started.
Also shm name is not predictable because the child pid is not
known in advance (well one can make all 1...PID_MAX shm's, sure),
but then again the child using the api 'knows' it was called
by the parent and data is always valid.

 > -1
 >

I announced that twice on this list during the last year,
so you should spoke then thought.

Regards
-- 
^(TM)