Skip to contentSkip to conversation

ipv4: restrict IPOPT_SSRR and IPOPT_LSRR options

PATCH Applied Eric Dumazet 4 participants 4 messages Jun 2 – Jun 4

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ipv4: restrict IPOPT_SSRR and IPOPT_LSRR options

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")

---
v2: use Ido's suggestion.
v1: https://lore.kernel.org/netdev/[email protected]/

 net/ipv4/ip_options.c | 4 ++++
 1 file changed, 4 insertions(+)
net/ipv4/ip_options.c +4 -0
index be8815ce3ac242372eeae4a97091cda26d40ceb0..09d745112c1526a1f151cd917f97dc1e236d6d22 100644
@@ -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;
Signature · 1 line
2.54.0.929.g9b7fa37559-goog
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 18 lines · Eric Dumazet

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")
Quoted 7 lines

---
v2: use Ido's suggestion.
v1: https://lore.kernel.org/netdev/[email protected]/

 net/ipv4/ip_options.c | 4 ++++
 1 file changed, 4 insertions(+)
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Eric Dumazet
Quoted 11 lines · Eric Dumazet

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.

Quoted 7 lines

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")
#3 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Tue, 2 Jun 2026 16:15:47 +0000 you wrote:

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.

[...]

Here is the summary with links:
- [v2,net] ipv4: restrict IPOPT_SSRR and IPOPT_LSRR options

    https://git.kernel.org/netdev/net/c/d3915a1f5a4b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html