Skip to contentSkip to conversation

how does this port binding happen?

DISCUSSION Russell Coker 4 participants 7 messages Aug 17, 2004 SELinux security module

lore
Share & tools
lore
#0 lore raw

avc: denied { name_bind } for pid=14909 exe=/usr/bin/kview src=669 scontext=rjc:staff_r:staff_t tcontext=system_u:object_r:port_t tclass=tcp_socket

kview is a viewer for JPEG etc images. It is never run as root. How does it get to the stage of an SE Linux access check?

Signature · 9 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#1 lore raw
Quoted 6 lines · Russell Coker

avc: denied { name_bind } for pid=14909 exe=/usr/bin/kview src=669 scontext=rjc:staff_r:staff_t tcontext=system_u:object_r:port_t tclass=tcp_socket

kview is a viewer for JPEG etc images. It is never run as root. How does it get to the stage of an SE Linux access check?

This check is done before the kernel DAC check.

- James

Signature · 9 lines
James Morris
<[email protected]>



--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 9 lines · James Morris
Quoted 6 lines · Russell Coker

avc: denied { name_bind } for pid=14909 exe=/usr/bin/kview src=669 scontext=rjc:staff_r:staff_t tcontext=system_u:object_r:port_t tclass=tcp_socket

kview is a viewer for JPEG etc images. It is never run as root. How does it get to the stage of an SE Linux access check?

This check is done before the kernel DAC check.

Is it practical to get that changed?

There are quite a number of programs that make bogus attempts to bind to low ports. There is no excuse for a print client binding to port 631 or a POP client binding to port 110. If such a bind attempt did happen to succeed somehow then it would be a very bad thing as it could prevent the daemon from correctly starting up (think of the case where a daemon crashes and the sys-admin tries to restart it just after a user has run a buggy KDE program that binds to the port).

Signature · 9 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw
Quoted 9 lines · Russell Coker
Quoted 8 lines · James Morris
Quoted 6 lines · Russell Coker

avc: denied { name_bind } for pid=14909 exe=/usr/bin/kview src=669 scontext=rjc:staff_r:staff_t tcontext=system_u:object_r:port_t tclass=tcp_socket

kview is a viewer for JPEG etc images. It is never run as root. How does it get to the stage of an SE Linux access check?

Quoted 7 lines
Quoted 1 line

This check is done before the kernel DAC check.

Is it practical to get that changed?

There are quite a number of programs that make bogus attempts to bind to low ports. There is no excuse for a print client binding to port 631 or a POP client binding to port 110.

there is _one_ necessary exception: due to a bug in network neighbourhood code in windows systems.

this bug was corrected and proper UDP behaviour observed in ONE version of windows nt - 3.51 - whereup on the bug was reintroduced thereafter.

all other windows systems respond _from_ port 137 _to_ port 137 for the-equivalent-of-dynamic-dns (known as NetBIOS over TCP/UDP name
resolution: see rfcs 1001 and 1002).

consequently, any system wishing to query a dynamically registered NetBIOS name on the TCP/UDP-emulated NetBIOS stack NEEDS to bind to port 137.

or, needs the intervention and assistance of a proxy daemon to perform the query and receive the response, because the client's UDP "from" port is totally ignored by all windows client.

[unfortunately, the samba team refuse to cooperate in properly
writing such a proxy daemon service, but that's another story.]

l.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw
Quoted 18 lines · Luke Kenneth Casson Leighton
Quoted 9 lines · Russell Coker
Quoted 8 lines · James Morris
Quoted 6 lines · Russell Coker

avc: denied { name_bind } for pid=14909 exe=/usr/bin/kview src=669 scontext=rjc:staff_r:staff_t tcontext=system_u:object_r:port_t tclass=tcp_socket

kview is a viewer for JPEG etc images. It is never run as root. How does it get to the stage of an SE Linux access check?

Quoted 7 lines
Quoted 1 line

This check is done before the kernel DAC check.

Is it practical to get that changed?

There are quite a number of programs that make bogus attempts to bind to low ports. There is no excuse for a print client binding to port 631 or a POP client binding to port 110.

Quoted 6 lines

there is _one_ necessary exception: due to a bug in network neighbourhood code in windows systems.

this bug was corrected and proper UDP behaviour observed in ONE version of windows nt - 3.51 - whereup on the bug was reintroduced thereafter.

It's for this sort of thing that we need to get the kernel code changed. We don't want to audit huge numbers of regular stupid operations from KDE programs, but we also don't want a dontaudit rule to catch the few cases where such access may be really needed (such as the example you gave).

Signature · 9 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#5 lore raw
Quoted 22 lines · Russell Coker
Quoted 21 lines · Luke Kenneth Casson Leighton
Quoted 9 lines · Russell Coker
Quoted 8 lines · James Morris
Quoted 6 lines · Russell Coker

avc: denied { name_bind } for pid=14909 exe=/usr/bin/kview src=669 scontext=rjc:staff_r:staff_t tcontext=system_u:object_r:port_t tclass=tcp_socket

kview is a viewer for JPEG etc images. It is never run as root. How does it get to the stage of an SE Linux access check?

Quoted 7 lines
Quoted 1 line

This check is done before the kernel DAC check.

Is it practical to get that changed?

There are quite a number of programs that make bogus attempts to bind to low ports. There is no excuse for a print client binding to port 631 or a POP client binding to port 110.

there is _one_ necessary exception: due to a bug in network neighbourhood code in windows systems.

Quoted 8 lines
Quoted 3 lines

this bug was corrected and proper UDP behaviour observed in ONE version of windows nt - 3.51 - whereup on the bug was reintroduced thereafter.

It's for this sort of thing that we need to get the kernel code changed. We don't want to audit huge numbers of regular stupid operations from KDE programs, but we also don't want a dontaudit rule to catch the few cases where such access may be really needed (such as the example you gave).

well... in this instance [137], the present scenario is:

- nmbd binds to UDP port 137 and therefore no other program can

- nmblookup binds to a high UDP port number and sends to port 137, expecting a response on the high UDP port.

- nmbd receives the response that SHOULD have gone to the high UDP port, looks it up in its state tables, and goes "eek, i shouldn't have received that, _let's_ stick it in a file unexpected.tdb".

- nmblookup, which is still waiting for data on the high UDP port, _also_ polls the same unexpected.tdb database file.

therefore it receives its response.

until recently, where the tdb program was GPL'd, it was impossible for any other open source project to do the same method.

so the other scenario is:

- The Wine team wrote their own (experimental) code which REPLACES all the GPL'd work done by the samba team with LGPL'd code.

THEIR code binds to port 137.

.... etc.

i've been endeavouring to persuade people to do this properly (the unexpected.tdb database method has problems with the "state"
records, namely that the lookup table has only 64k possible entries).

anyway.

one for the future, because the Wine team's code is experimental.

l.

Quoted 5 lines
Signature · 4 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page
Signature · 13 lines
--
Truth, honesty and respect are rare commodities that all spring from
the same well: Love.  If you love yourself and everyone and everything
around you, funnily and coincidentally enough, life gets a lot better.
--
<a href="http://lkcl.net">      lkcl.net      </a> <br />
<a href="mailto:[email protected]"> [email protected] </a> <br />


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#6 lore raw
In reply to Russell Coker
Quoted 6 lines · Russell Coker
Quoted 5 lines · James Morris
Quoted 4 lines · Russell Coker

avc: denied { name_bind } for pid=14909 exe=/usr/bin/kview src=669 scontext=rjc:staff_r:staff_t tcontext=system_u:object_r:port_t tclass=tcp_socket

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

kview is a viewer for JPEG etc images. It is never run as root. How does it get to the stage of an SE Linux access check?

This check is done before the kernel DAC check.

Is it practical to get that changed?

I doubt it. SELinux is using one of the general socket layer hooks to implement the name_bind check; the kernel performs its check in the ipv4/af_inet.c code. Getting a hook accepted in the ipv4 code is unlikely, and moving the kernel check to the general socket layer is likewise unlikely. Simplest solution for us would be to reproduce the kernel check in the SELinux hook prior to performing the SELinux check. That wouldn't be difficult, just duplicative.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.