Skip to content

Commit

Permalink
netfilter: xt_osf: Add missing permission checks
Browse files Browse the repository at this point in the history
The capability check in nfnetlink_rcv() verifies that the caller
has CAP_NET_ADMIN in the namespace that "owns" the netlink socket.
However, xt_osf_fingers is shared by all net namespaces on the
system.  An unprivileged user can create user and net namespaces
in which he holds CAP_NET_ADMIN to bypass the netlink_net_capable()
check:

    vpnns -- nfnl_osf -f /tmp/pf.os

    vpnns -- nfnl_osf -f /tmp/pf.os -d

These non-root operations successfully modify the systemwide OS
fingerprint list.  Add new capable() checks so that they can't.

Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Kevin Cernekee authored and Pablo Neira Ayuso committed Dec 6, 2017
1 parent 6ab4051 commit 916a279
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions net/netfilter/xt_osf.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/module.h>
#include <linux/kernel.h>

#include <linux/capability.h>
#include <linux/if.h>
#include <linux/inetdevice.h>
#include <linux/ip.h>
Expand Down Expand Up @@ -70,6 +71,9 @@ static int xt_osf_add_callback(struct net *net, struct sock *ctnl,
struct xt_osf_finger *kf = NULL, *sf;
int err = 0;

if (!capable(CAP_NET_ADMIN))
return -EPERM;

if (!osf_attrs[OSF_ATTR_FINGER])
return -EINVAL;

Expand Down Expand Up @@ -115,6 +119,9 @@ static int xt_osf_remove_callback(struct net *net, struct sock *ctnl,
struct xt_osf_finger *sf;
int err = -ENOENT;

if (!capable(CAP_NET_ADMIN))
return -EPERM;

if (!osf_attrs[OSF_ATTR_FINGER])
return -EINVAL;

Expand Down

0 comments on commit 916a279

Please sign in to comment.