* seccomp vs ptrace
@ 2015-03-18 21:30 Serge E. Hallyn
2015-03-18 21:38 ` Kees Cook
2015-03-18 21:39 ` Andy Lutomirski
0 siblings, 2 replies; 6+ messages in thread
From: Serge E. Hallyn @ 2015-03-18 21:30 UTC (permalink / raw)
To: lkml, Kees Cook, Andy Lutomirski, stgraber
Hi,
I'm writing to ask about
The seccomp check will not be run again after the tracer is
notified. (This means that seccomp-based sandboxes MUST NOT
allow use of ptrace, even of other sandboxed processes, without
extreme care; ptracers can use this mechanism to escape.)
This basically means that seccomp cannot be safely used with for instance
an upstart based container. I've been told that Andy was working on
changing the order so that ptrace checks would be done before seccomp.
Is there any update on that? Is it likely to happen? Scrapped?
thanks,
-serge
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: seccomp vs ptrace 2015-03-18 21:30 seccomp vs ptrace Serge E. Hallyn @ 2015-03-18 21:38 ` Kees Cook 2015-03-18 21:42 ` Andy Lutomirski 2015-03-18 21:39 ` Andy Lutomirski 1 sibling, 1 reply; 6+ messages in thread From: Kees Cook @ 2015-03-18 21:38 UTC (permalink / raw) To: Serge E. Hallyn; +Cc: lkml, Andy Lutomirski, stgraber On Wed, Mar 18, 2015 at 2:30 PM, Serge E. Hallyn <serge@hallyn.com> wrote: > Hi, > > I'm writing to ask about > > The seccomp check will not be run again after the tracer is > notified. (This means that seccomp-based sandboxes MUST NOT > allow use of ptrace, even of other sandboxed processes, without > extreme care; ptracers can use this mechanism to escape.) > > This basically means that seccomp cannot be safely used with for instance > an upstart based container. I've been told that Andy was working on > changing the order so that ptrace checks would be done before seccomp. > Is there any update on that? Is it likely to happen? Scrapped? There are two problems, as I see it: 1) seccomp filtering happens first, so any following ptrace actions could change the syscall that actually happens (e.g. a filter allows clone and ptrace, meaning it could start a child, ptrace it, issue an allowed syscall, catch it, and change it to a disallowed syscall: escape from sandbox). 2) even if ptrace was moved ahead of seccomp, a sandboxed process as above and also access to add more filters (via seccomp or prctl syscalls) could use SECCOMP_RET_TRACE, to catch the syscall at the end of the seccomp checks, which would allow the same as above. Basically, the note is correct: ptrace really cannot be allowed in a filter or it could be used to bypass the filter. I am, of course, open to ideas on fixing this without introducing loops. The use-case of having a ptrace monitor of a sandboxed process intentionally changing syscalls isn't a use-case I think we need to support. Monitors like that should just perform such calls themselves from the unsandboxed half. -Kees -- Kees Cook Chrome OS Security ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: seccomp vs ptrace 2015-03-18 21:38 ` Kees Cook @ 2015-03-18 21:42 ` Andy Lutomirski 2015-03-18 21:44 ` Kees Cook 0 siblings, 1 reply; 6+ messages in thread From: Andy Lutomirski @ 2015-03-18 21:42 UTC (permalink / raw) To: Kees Cook; +Cc: Serge E. Hallyn, lkml, Stephane Graber On Wed, Mar 18, 2015 at 2:38 PM, Kees Cook <keescook@chromium.org> wrote: > On Wed, Mar 18, 2015 at 2:30 PM, Serge E. Hallyn <serge@hallyn.com> wrote: >> Hi, >> >> I'm writing to ask about >> >> The seccomp check will not be run again after the tracer is >> notified. (This means that seccomp-based sandboxes MUST NOT >> allow use of ptrace, even of other sandboxed processes, without >> extreme care; ptracers can use this mechanism to escape.) >> >> This basically means that seccomp cannot be safely used with for instance >> an upstart based container. I've been told that Andy was working on >> changing the order so that ptrace checks would be done before seccomp. >> Is there any update on that? Is it likely to happen? Scrapped? > > There are two problems, as I see it: > > 1) seccomp filtering happens first, so any following ptrace actions > could change the syscall that actually happens (e.g. a filter allows > clone and ptrace, meaning it could start a child, ptrace it, issue an > allowed syscall, catch it, and change it to a disallowed syscall: > escape from sandbox). > > 2) even if ptrace was moved ahead of seccomp, a sandboxed process as > above and also access to add more filters (via seccomp or prctl > syscalls) could use SECCOMP_RET_TRACE, to catch the syscall at the end > of the seccomp checks, which would allow the same as above. Ouch! Arguably we messed up by making SECCOMP_RET_TRACE have higher precedence than ERRNO and TRAP. We could add new ERRNO and TRAP actions that have high precedence or a new flag that promotes them in the filter being applied. --Andy ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: seccomp vs ptrace 2015-03-18 21:42 ` Andy Lutomirski @ 2015-03-18 21:44 ` Kees Cook 2015-03-18 22:06 ` Andy Lutomirski 0 siblings, 1 reply; 6+ messages in thread From: Kees Cook @ 2015-03-18 21:44 UTC (permalink / raw) To: Andy Lutomirski; +Cc: Serge E. Hallyn, lkml, Stephane Graber On Wed, Mar 18, 2015 at 2:42 PM, Andy Lutomirski <luto@amacapital.net> wrote: > On Wed, Mar 18, 2015 at 2:38 PM, Kees Cook <keescook@chromium.org> wrote: >> On Wed, Mar 18, 2015 at 2:30 PM, Serge E. Hallyn <serge@hallyn.com> wrote: >>> Hi, >>> >>> I'm writing to ask about >>> >>> The seccomp check will not be run again after the tracer is >>> notified. (This means that seccomp-based sandboxes MUST NOT >>> allow use of ptrace, even of other sandboxed processes, without >>> extreme care; ptracers can use this mechanism to escape.) >>> >>> This basically means that seccomp cannot be safely used with for instance >>> an upstart based container. I've been told that Andy was working on >>> changing the order so that ptrace checks would be done before seccomp. >>> Is there any update on that? Is it likely to happen? Scrapped? >> >> There are two problems, as I see it: >> >> 1) seccomp filtering happens first, so any following ptrace actions >> could change the syscall that actually happens (e.g. a filter allows >> clone and ptrace, meaning it could start a child, ptrace it, issue an >> allowed syscall, catch it, and change it to a disallowed syscall: >> escape from sandbox). >> >> 2) even if ptrace was moved ahead of seccomp, a sandboxed process as >> above and also access to add more filters (via seccomp or prctl >> syscalls) could use SECCOMP_RET_TRACE, to catch the syscall at the end >> of the seccomp checks, which would allow the same as above. > > Ouch! > > Arguably we messed up by making SECCOMP_RET_TRACE have higher > precedence than ERRNO and TRAP. We could add new ERRNO and TRAP > actions that have high precedence or a new flag that promotes them in > the filter being applied. Nope, RET_TRACE is lower. KILL, TRAP, ERRNO, TRACE, ALLOW. Still doesn't help the above cases, but we can't override a blocked syscall just with a new filter. You'd still have to do the ptrace dance with an allowed syscall. -Kees -- Kees Cook Chrome OS Security ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: seccomp vs ptrace 2015-03-18 21:44 ` Kees Cook @ 2015-03-18 22:06 ` Andy Lutomirski 0 siblings, 0 replies; 6+ messages in thread From: Andy Lutomirski @ 2015-03-18 22:06 UTC (permalink / raw) To: Kees Cook; +Cc: Serge E. Hallyn, lkml, Stephane Graber On Wed, Mar 18, 2015 at 2:44 PM, Kees Cook <keescook@chromium.org> wrote: > On Wed, Mar 18, 2015 at 2:42 PM, Andy Lutomirski <luto@amacapital.net> wrote: >> On Wed, Mar 18, 2015 at 2:38 PM, Kees Cook <keescook@chromium.org> wrote: >>> On Wed, Mar 18, 2015 at 2:30 PM, Serge E. Hallyn <serge@hallyn.com> wrote: >>>> Hi, >>>> >>>> I'm writing to ask about >>>> >>>> The seccomp check will not be run again after the tracer is >>>> notified. (This means that seccomp-based sandboxes MUST NOT >>>> allow use of ptrace, even of other sandboxed processes, without >>>> extreme care; ptracers can use this mechanism to escape.) >>>> >>>> This basically means that seccomp cannot be safely used with for instance >>>> an upstart based container. I've been told that Andy was working on >>>> changing the order so that ptrace checks would be done before seccomp. >>>> Is there any update on that? Is it likely to happen? Scrapped? >>> >>> There are two problems, as I see it: >>> >>> 1) seccomp filtering happens first, so any following ptrace actions >>> could change the syscall that actually happens (e.g. a filter allows >>> clone and ptrace, meaning it could start a child, ptrace it, issue an >>> allowed syscall, catch it, and change it to a disallowed syscall: >>> escape from sandbox). >>> >>> 2) even if ptrace was moved ahead of seccomp, a sandboxed process as >>> above and also access to add more filters (via seccomp or prctl >>> syscalls) could use SECCOMP_RET_TRACE, to catch the syscall at the end >>> of the seccomp checks, which would allow the same as above. >> >> Ouch! >> >> Arguably we messed up by making SECCOMP_RET_TRACE have higher >> precedence than ERRNO and TRAP. We could add new ERRNO and TRAP >> actions that have high precedence or a new flag that promotes them in >> the filter being applied. > > Nope, RET_TRACE is lower. KILL, TRAP, ERRNO, TRACE, ALLOW. Still > doesn't help the above cases, but we can't override a blocked syscall > just with a new filter. You'd still have to do the ptrace dance with > an allowed syscall. Oh, right, I read it backwards. We could try to handle TRACE immediately instead of after running all filters. This could be rather tricky given the way the x86 code works, though. Maybe at some point we'll be able to change that without killing performance. We could add an ugly flag that says that subsequent filters can use TRACE, I suppose. Yuck. --Andy ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: seccomp vs ptrace 2015-03-18 21:30 seccomp vs ptrace Serge E. Hallyn 2015-03-18 21:38 ` Kees Cook @ 2015-03-18 21:39 ` Andy Lutomirski 1 sibling, 0 replies; 6+ messages in thread From: Andy Lutomirski @ 2015-03-18 21:39 UTC (permalink / raw) To: Serge E. Hallyn; +Cc: lkml, Kees Cook, Stephane Graber On Wed, Mar 18, 2015 at 2:30 PM, Serge E. Hallyn <serge@hallyn.com> wrote: > Hi, > > I'm writing to ask about > > The seccomp check will not be run again after the tracer is > notified. (This means that seccomp-based sandboxes MUST NOT > allow use of ptrace, even of other sandboxed processes, without > extreme care; ptracers can use this mechanism to escape.) > > This basically means that seccomp cannot be safely used with for instance > an upstart based container. I've been told that Andy was working on > changing the order so that ptrace checks would be done before seccomp. > Is there any update on that? Is it likely to happen? Scrapped? No, just got stalled because I'm too busy. The code is here: https://git.kernel.org/cgit/linux/kernel/git/luto/linux.git/log/?h=x86/seccomp but it's not really adequately tested. > > thanks, > -serge -- Andy Lutomirski AMA Capital Management, LLC ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-03-18 22:06 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-03-18 21:30 seccomp vs ptrace Serge E. Hallyn 2015-03-18 21:38 ` Kees Cook 2015-03-18 21:42 ` Andy Lutomirski 2015-03-18 21:44 ` Kees Cook 2015-03-18 22:06 ` Andy Lutomirski 2015-03-18 21:39 ` Andy Lutomirski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®