Re: Network isolation with RLIMIT_NETWORK, cont'd.



Eric Biederman wrote:

I have added the container's list to the cc as there is some overlap.

Good idea; thanks.

Overall what you have looks ad-hoc, and very special case which is
likely to impair maintenance in the future.

Unfortunately, these are the semantics which are necessary to make further
progress on sandboxing real Linux apps with the discretionary access control
facilities which are available today.

You can in theory confuse a suid root application and cause it to take action
with it's elevated privileges that violate the security policy.

You're right, in theory. In practice, the setuid-root facility is a rather
special escape hatch which *everyone* in this field knows must be carefully
audited and maintained when building or updating trustworthy systems.

Also, in practice, I'm not expecting perfection today. Nor was I last year, nor
am I next year. What I am expecting is that the kernel will supply me (perhaps
with my assistance along the way) with the access control facilities that I
need to do my job in userland. This is one of them.

The network namespace has more potential to confuse existing applications
than your mechanism, but the problem seems to remain.

I'm glad to hear that you find this mechanism to be comparatively less
confusing.

1. ptrace() It was pointed out by Alan Cox, Andi Kleen, and others that processes
which dropped their RLIMIT_NETWORK rlimit were still able to directly
perform networking through a ptrace()'d victim.

The new patchset adds an access check to __ptrace_may_access() to prevent
this behavior.

Solve that with an unused uid.

I already do, in general. (As do the other people requesting this facility.)

The reason for the __ptrace_may_access() check is that the logical way for
*application authors* whose code is *already* running in a fresh uid to further
improve system security is to separate their network I/O from their parsing
code a process boundary and to drop networking privileges in the parser.

2. unshare(CLONE_NEWNET)

It was pointed out by James Morris that network namespaces could be used
to implement behavior similar to the behavior this patchset is designed to
implement. To address this criticism, I added support for network
namespaces to my sandboxing utility (Rainbow).

Unfortunately, I have discovered that network namespaces in their current
form are not appropriate for my use cases because they prevent the
namespace'd apps from connecting to the X server, even over plain old
AF_UNIX sockets.

We discussed that a while ago, and there is no fundamental reason to
disallow opening unix domain sockets from another network namespace.

I disagree. I like that the network namespaces have (fairly) clear semantics.
They are excellent semantics for some of my other use cases, like testing
networked software [1]. They're probably quite nice for full-blown
containerization. They're just not right for the kind of lightweight sandboxing
of complicated legacy apps that I'm doing.

[1]: http://dev.laptop.org/git/users/mstone/dnshash/tree/docs/unit_testing.txt

The RLIMIT_NETWORK facility I propose contains a specific exception for
AF_UNIX filesystem sockets since those sockets are already bound by
regular Unix discretionary access control.

What is more significant than unix discretionary access control is the
fact that the set of available af_unix sockets you can bind to is filtered
by the mount namespace.

Actually, the Unix DAC is far more important for my purposes. The reason is
that it's unprivileged, already understood by literally *everyone* involved in
Unix security, and it has the best tools support of any access control
mechanism.

For comparison, I do use CLONE_NEWNS mount namespaces and they've been a real
pain because

a) unlike in Plan 9, they're privileged,

b) they greatly complicate debugging the isolated app because you see
different things inside and outside the namespace,

c) there's no good way to manipulate them from userland, and

d) they're poorly documented outside of the mount man page.

Regards,

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



Relevant Pages

  • Re: [patch 2/6] [Network namespace] Network device sharing by view
    ... And the network stack seems to have a perfectly good ... device moving between namespaces, ... A packet appears right inside some namespace, ... Not twice because you don't traverse the entire network stack. ...
    (Linux-Kernel)
  • Re: J2ME or network programming or...what do you recommend?
    ... It was more 'J2EE' I was thinking of in my ... offers network connections to other places, ... OK - J2ME apps. ... thin client GUI - so there is ...
    (comp.lang.java.programmer)
  • Re: sysfs: tagged directories not merged completely yet
    ... namespaces (right now, with a mainline kernel, we have to disable sysfs ... to build network namespaces). ... special-case in VFS every kind of weirdness sysfs happens to do; ... a lot of locking conditional on that. ...
    (Linux-Kernel)
  • Re: [PATCH 1/3] Security: Add prctl(PR_{GET,SET}_NETWORK)
    ... With namespaces it is possible to masquarade as a trusted source, ... of information to a suid program such as /etc/passwd or a NIS server. ... the network namespace if executing suid applications are disabled. ... How do you propose to address the problem with the Unix sockets? ...
    (Linux-Kernel)
  • Re: VFP open table corruption
    ... backup and audit trail, but I'm scared of it happening again. ... Just never seen any corruption that comprehensive before. ... everything went nuts - apps crashing everywhere. ... The network is having a few problems I admit, ...
    (microsoft.public.fox.programmer.exchange)