Skip to content
Commit 878aed8d authored by Florian Westphal's avatar Florian Westphal Committed by Pablo Neira Ayuso
Browse files

netfilter: nat: force port remap to prevent shadowing well-known ports



If destination port is above 32k and source port below 16k
assume this might cause 'port shadowing' where a 'new' inbound
connection matches an existing one, e.g.

inbound X:41234 -> Y:53 matches existing conntrack entry
        Z:53 -> X:4123, where Z got natted to X.

In this case, new packet is natted to Z:53 which is likely
unwanted.

We avoid the rewrite for connections that originate from local host:
port-shadowing is only possible with forwarded connections.

Also adjust test case.

v3: no need to call tuple_force_port_remap if already in random mode (Phil)

Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Acked-by: default avatarPhil Sutter <phil@nwl.cc>
Acked-by: default avatarEric Garver <eric@garver.life>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 4a6fbdd8
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment