From: Pablo Neira Ayuso <pablo@netfilter.org>
To: iLifetruth <yixiaonn@gmail.com>
Cc: Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Qiang Liu <cyruscyliu@gmail.com>,
yajin@vm-kernel.org
Subject: Re: netfilter: Use netlink_ns_capable to verify the permisions of netlink messages
Date: Wed, 7 Jul 2021 11:18:07 +0200 [thread overview]
Message-ID: <20210707091807.GA16039@salvia> (raw)
In-Reply-To: <CABv53a97_5iaAdOcoVdQDxNyyTxgXHx=mHm0Sfo4UJVLHoxosg@mail.gmail.com>
On Wed, Jul 07, 2021 at 04:05:33PM +0800, iLifetruth wrote:
> Hi, we have found that the same fix pattern of CVE-2014-0181 may not
> forward ported to some netlink-related places in the latest linux
> kernel(v5.13)
>
> =============
> Here is the description of CVE-2014-0181:
>
> The Netlink implementation in the Linux kernel through 3.14.1 does not
> provide a mechanism for authorizing socket operations based on the opener
> of a socket, which allows local users to bypass intended access
> restrictions and modify network configurations by using a Netlink socket
> for the (1) stdout or (2) stderr of a setuid program.
>
> ==========
> And here is the solution to CVE-2014-0181:
>
> To keep this from happening, replace bare capable and ns_capable calls with
> netlink_capable, netlink_net_calls and netlink_ns_capable calls. Which act
> the same as the previous calls *except they verify that the opener of the
> socket had the desired permissions as well.*
>
> ==========
> The upstream patch commit of this vulnerability described in CVE-2014-0181
> is:
> 90f62cf30a78721641e08737bda787552428061e (committed about 7 years ago)
>
> =========
> Capable() checks were added to these netlink-related places listed below
> in netfilter by another upstream commit:
> 4b380c42f7d00a395feede754f0bc2292eebe6e5(committed about 4 years ago)
>
> In kernel v5.13:
> File_1: linux/net/netfilter/nfnetlink_cthelper.c
> in line 424, line 623 and line 691
> File_2: linux/net/netfilter/nfnetlink_osf.c
> in line 305 and line 351
These subsystems depend on nfnetlink.
nfnetlink_rcv() is called before passing the message to the
corresponding backend, e.g. nfnetlink_osf.
static void nfnetlink_rcv(struct sk_buff *skb)
{
struct nlmsghdr *nlh = nlmsg_hdr(skb);
if (skb->len < NLMSG_HDRLEN ||
nlh->nlmsg_len < NLMSG_HDRLEN ||
skb->len < nlh->nlmsg_len)
return;
if (!netlink_net_capable(skb, CAP_NET_ADMIN)) {
netlink_ack(skb, nlh, -EPERM, NULL);
return;
}
[...]
which is calling netlink_net_capable().
> But these checkers are still using bare capable instead of netlink_capable
> calls. So this is likely to trigger the vulnerability described in the
> CVE-2014-0181 without checking the desired permissions of the socket
> opener. Now, shall we forward port the fix pattern from the patch of
> CVE-2014-0181?
>
> We would like to contact you to confirm this problem.
I think these capable() calls in nfnetlink_cthelper and nfnetlink_osf
are dead code that can be removed. As I explained these subsystems
stay behind nfnetlink.
next parent reply other threads:[~2021-07-07 9:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CABv53a97_5iaAdOcoVdQDxNyyTxgXHx=mHm0Sfo4UJVLHoxosg@mail.gmail.com>
2021-07-07 9:18 ` Pablo Neira Ayuso [this message]
2021-07-07 13:22 ` netfilter: Use netlink_ns_capable to verify the permisions of netlink messages iLifetruth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210707091807.GA16039@salvia \
--to=pablo@netfilter.org \
--cc=coreteam@netfilter.org \
--cc=cyruscyliu@gmail.com \
--cc=davem@davemloft.net \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=yajin@vm-kernel.org \
--cc=yixiaonn@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.