]> git.decadent.org.uk Git - nfs-utils.git/commit - support/export/hostname.c
nfs: fix host_reliable_addrinfo
authorJeff Layton <jlayton@redhat.com>
Wed, 22 Jun 2011 18:51:38 +0000 (14:51 -0400)
committerSteve Dickson <steved@redhat.com>
Wed, 22 Jun 2011 18:51:38 +0000 (14:51 -0400)
commitb50ad13298b3e9519a9bdecb8c146c9ecf39cef8
tree59c37962c1170b46de72d0b6bb5e80d9d2d3119b
parent7235a2164aabfd8dba1f7e1577047bda45053db0
nfs: fix host_reliable_addrinfo

According to Neil Brown:

    The point of the word 'reliable' is to check that the name we get
    really does belong to the host in question - ie that both the
    forward and reverse maps agree.

    But the new code doesn't do that check at all.  Rather it simply
    maps the address to a name, then discards the address and maps the
    name back to a list of addresses and uses that list of addresses as
    "where the request came from" for permission checking.

This bug is exploitable via the following scenario and could allow an
attacker access to data that they shouldn't be able to access.

    Suppose you export a filesystem to some subnet or FQDN and also to a
    wildcard or netgroup, and I know the details of this (maybe
    showmount -e tells me) Suppose further that I can get IP packets to
    your server..

    Then I create a reverse mapping for my ipaddress to a domain that I
    own, say "black.hat.org", and a forward mapping from that domain to
    my IP address, and one of your IP addresses.

    Then I try to mount your filesystem.  The IP address gets correctly
    mapped to "black.hat.org" and then mapped to both my IP address and
    your IP address.

    Then you search through all of your exports and find that one of the
    addresses: yours - is allowed to access the filesystem.

    So you create an export based on the addrinfo you have which allows
    my IP address the same access as your IP address.

Fix this by instead using the forward lookup of the hostname just to
verify that the original address is in the list. Then do a numeric
lookup using the address and stick the hostname in the ai_canonname.

Reviewed-by: NeilBrown <neilb@suse.de>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
support/export/hostname.c