DEV Community

kozhevniko
kozhevniko

Posted on

IPsec traffic selectors define negotiated policy, not reachable trust

IPsec traffic selectors define negotiated policy, not reachable trust

An IPsec tunnel is often drawn as a line between two gateways, with subnet labels on each side. The labels in configuration are traffic selectors. They tell the peers which source and destination addresses and protocols are allowed inside a security association. They do not create a general routing relationship, and they do not prove that every address behind a gateway is safe to reach.

StrongSwan expresses these selectors through local_ts and remote_ts, with older configuration names such as leftsubnet and rightsubnet. The peers propose selectors during IKE negotiation. A gateway can narrow a broad remote proposal to the subnets it actually authorizes. Narrowing is a security feature when it reflects policy, but it can also produce confusing operational behavior: a client may have a route for a large network while the selected security association covers only a smaller prefix.

A selector is a packet-matching rule for IPsec. It is not a replacement for firewall rules, application authentication, or route hygiene. A /16 selector that permits all protocols to a server subnet is a broad policy even if the tunnel is encrypted. If the application is an administrative API on one host and one port, the selector should reflect that intended scope where the peer and kernel support narrowing. The firewall should still reject unexpected ports and sources.

Design reviews should compare four representations of the same connection: the IKE proposal, the configured selectors, the installed kernel policy, and the routes that carry traffic into the tunnel. A mismatch between them is common after a migration. One side may propose 0.0.0.0/0 while the other narrows to a specific subnet. The tunnel may come up, yet only some applications work. More importantly, an unintended selector can expose a network segment that the team believed was outside the tunnel.

Wildcard selectors deserve special attention. When a remote peer proposes all addresses, the local gateway should narrow that request to authorized local subnets and protocols. It should not accept the broad first proposal merely because the peer is a known business partner. The trust relationship is with the partner gateway, not every host that gateway can route. Logging the negotiated selectors helps teams detect when a proposal changes after a firmware update or a configuration rollback.

NAT, iptables, and forwarding rules add another layer. The kernel may apply policy-based routing for traffic that matches an IPsec policy. A change to the rule order, the routing table, or the source address can move traffic outside the expected association. Both peers should verify the installed policy, not only the IKE status. Test with exact source and destination pairs, include the protocol and port, and check that an unselected destination fails rather than falling back to cleartext routing.

Access control also depends on who can change selectors. A delegated network administrator who can add a broad subnet to a partner connection can enlarge the tunnel's effective reach. Treat selector changes like firewall changes: require a ticket, an owner, a security review for broad prefixes, and a post-change test. Keep a machine-readable inventory that maps connection names to expected selectors and owners. Alert when the installed policy differs from the approved baseline.

IPsec is valuable because it gives a defined, negotiated security boundary. Traffic selectors are where that boundary becomes concrete for packets. They are not a statement that everything behind a gateway is trusted. A reliable deployment keeps selectors narrow, verifies what the kernel installed, and pairs the tunnel with routing and firewall rules that enforce the same intent.

References

Top comments (0)