* Re: netfilter: Use netlink_ns_capable to verify the permisions of netlink messages
[not found] <CABv53a97_5iaAdOcoVdQDxNyyTxgXHx=mHm0Sfo4UJVLHoxosg@mail.gmail.com>
@ 2021-07-07 9:18 ` Pablo Neira Ayuso
2021-07-07 13:22 ` iLifetruth
0 siblings, 1 reply; 2+ messages in thread
From: Pablo Neira Ayuso @ 2021-07-07 9:18 UTC (permalink / raw)
To: iLifetruth
Cc: Jozsef Kadlecsik, Florian Westphal, David S. Miller,
Jakub Kicinski, netfilter-devel, coreteam, netdev, linux-kernel,
Qiang Liu, yajin
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: netfilter: Use netlink_ns_capable to verify the permisions of netlink messages
2021-07-07 9:18 ` netfilter: Use netlink_ns_capable to verify the permisions of netlink messages Pablo Neira Ayuso
@ 2021-07-07 13:22 ` iLifetruth
0 siblings, 0 replies; 2+ messages in thread
From: iLifetruth @ 2021-07-07 13:22 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: Jozsef Kadlecsik, Florian Westphal, David S. Miller,
Jakub Kicinski, netfilter-devel, coreteam, netdev, linux-kernel,
Qiang Liu, yajin
I see.
There is no need to check the capability again in the
nfnetlink_cthelper and nfnetlink_osf now.
Regards and thanks for your analyze,
- iLifetruth
On Wed, Jul 7, 2021 at 5:18 PM Pablo Neira Ayuso <pablo@netfilter.org> wrote:
>
> 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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-07 13:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CABv53a97_5iaAdOcoVdQDxNyyTxgXHx=mHm0Sfo4UJVLHoxosg@mail.gmail.com>
2021-07-07 9:18 ` netfilter: Use netlink_ns_capable to verify the permisions of netlink messages Pablo Neira Ayuso
2021-07-07 13:22 ` iLifetruth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).