ipv4: restrict IPOPT_SSRR and IPOPT_LSRR options
authorEric Dumazet <edumazet@google.com>
Tue, 2 Jun 2026 16:15:47 +0000 (16:15 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 4 Jun 2026 01:53:14 +0000 (18:53 -0700)
This patch restricts setting Loose Source and Record Route (LSRR)
and Strict Source and Record Route (SSRR) IP options to users
with CAP_NET_RAW capability.

This prevents unprivileged applications from forcing packets to route
through attacker-controlled nodes to leak TCP ISN and possibly other
protocol information.

While LSRR and SSRR are commonly filtered in many network environments,
they may still be supported and forwarded along some network paths.

RFC 7126 (Recommendations on Filtering of IPv4 Packets Containing
IPv4 Options) recommend to drop these options in 4.3 and 4.4.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Tamir Shahar <tamirthesis@gmail.com>
Reported-by: Amit Klein <aksecurity@gmail.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260602161547.2642155-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/ip_options.c

index be8815c..09d7451 100644 (file)
@@ -530,6 +530,10 @@ int ip_options_get(struct net *net, struct ip_options_rcu **optp,
                kfree(opt);
                return -EINVAL;
        }
+       if (opt->opt.srr && !ns_capable(net->user_ns, CAP_NET_RAW)) {
+               kfree(opt);
+               return -EPERM;
+       }
        kfree(*optp);
        *optp = opt;
        return 0;