ipv4: add option to drop unicast encapsulated in L2 multicast
Subsystems (4)
PATCH v3 1/4 ipv4: add option to drop unicast encapsulated in L2 multicast
From: Johannes Berg <[email protected]>
In order to solve a problem with 802.11, the so-called hole-196 attack, add an option (sysctl) called "drop_unicast_in_l2_multicast" which, if enabled, causes the stack to drop IPv4 unicast packets encapsulated in link-layer multi- or broadcast frames. Such frames can (as an attack) be created by any member of the same wireless network and transmitted as valid encrypted frames since the symmetric key for broadcast frames is shared between all stations.
Additionally, enabling this option provides compliance with a SHOULD clause of RFC 1122.
--- Documentation/networking/ip-sysctl.txt | 7 +++++++ include/uapi/linux/ip.h | 1 + net/ipv4/devinet.c | 2 ++ net/ipv4/ip_input.c | 25 ++++++++++++++++++++++++- 4 files changed, 34 insertions(+), 1 deletion(-)
Documentation/networking/ip-sysctl.txt +7 -0
@@ -1208,6 +1208,13 @@ promote_secondaries - BOOLEAN promote a corresponding secondary IP address instead of removing all the corresponding secondary IP addresses. +drop_unicast_in_l2_multicast - BOOLEAN + Drop any unicast IP packets that are received in link-layer + multicast (or broadcast) frames. + This behavior (for multicast) is actually a SHOULD in RFC + 1122, but is disabled by default for compatibility reasons. + Default: off (0) + tag - INTEGER Allows you to write a number, which can be used as required.
include/uapi/linux/ip.h +1 -0
@@ -165,6 +165,7 @@ enumIPV4_DEVCONF_IGMPV2_UNSOLICITED_REPORT_INTERVAL ,IPV4_DEVCONF_IGMPV3_UNSOLICITED_REPORT_INTERVAL ,IPV4_DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN , +IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST , __IPV4_DEVCONF_MAX };
net/ipv4/devinet.c +2 -0
@@ -2192,6 +2192,8 @@ static struct devinet_sysctl_table { "promote_secondaries"), DEVINET_SYSCTL_FLUSHING_ENTRY(ROUTE_LOCALNET, "route_localnet"), +DEVINET_SYSCTL_FLUSHING_ENTRY (DROP_UNICAST_IN_L2_MULTICAST , + "drop_unicast_in_l2_multicast"), }, };
net/ipv4/ip_input.c +24 -1
@@ -359,8 +359,31 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb) rt =skb_rtable (skb);if (rt->rt_type ==RTN_MULTICAST ) {IP_UPD_PO_STATS_BH (net,IPSTATS_MIB_INMCAST , skb->len); - }else if (rt->rt_type ==RTN_BROADCAST ) + }else if (rt->rt_type ==RTN_BROADCAST ) {IP_UPD_PO_STATS_BH (net,IPSTATS_MIB_INBCAST , skb->len); + }else if (skb->pkt_type ==PACKET_BROADCAST || + skb->pkt_type ==PACKET_MULTICAST ) { +struct in_device *in_dev =__in_dev_get_rcu (skb->dev); + +/* RFC 1122 3.3.6: +* +* When a host sends a datagram to a link-layer broadcast +* address, the IP destination address MUST be a legal IP +* broadcast or IP multicast address. +* +* A host SHOULD silently discard a datagram that is received +* via a link-layer broadcast (see Section 2.4) but does not +* specify an IP multicast or broadcast destination address. +* +* This doesn't explicitly say L2 *broadcast*, but broadcast is +* in a way a form of multicast and the most common use case for +* this is 802.11 protecting against cross-station spoofing (the +* so-called "hole-196" attack) so do it for both. +*/ +if (in_dev && +IN_DEV_ORCONF (in_dev,DROP_UNICAST_IN_L2_MULTICAST )) + goto drop; + }return dst_input (skb);
Signature · 1 line
2.7.0
A message that is not in the archive (sent off-list or not yet received): 1454589080-21354-1-git-send-email-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org
PATCH v3 3/4 ipv6: add option to drop unicast encapsulated in L2 multicast
From: Johannes Berg <[email protected]>
In order to solve a problem with 802.11, the so-called hole-196 attack, add an option (sysctl) called "drop_unicast_in_l2_multicast" which, if enabled, causes the stack to drop IPv6 unicast packets encapsulated in link-layer multi- or broadcast frames. Such frames can (as an attack) be created by any member of the same wireless network and transmitted as valid encrypted frames since the symmetric key for broadcast frames is shared between all stations.
--- Documentation/networking/ip-sysctl.txt | 6 ++++++ include/linux/ipv6.h | 1 + include/uapi/linux/ipv6.h | 1 + net/ipv6/addrconf.c | 8 ++++++++ net/ipv6/ip6_input.c | 10 ++++++++++ 5 files changed, 26 insertions(+)
Documentation/networking/ip-sysctl.txt +6 -0
@@ -1666,6 +1666,12 @@ stable_secret - IPv6 address By default the stable secret is unset. +drop_unicast_in_l2_multicast - BOOLEAN + Drop any unicast IPv6 packets that are received in link-layer + multicast (or broadcast) frames. + + By default this is turned off. + icmp/*: ratelimit - INTEGER Limit the maximal rates for sending ICMPv6 packets.
include/linux/ipv6.h +1 -0
@@ -50,6 +50,7 @@ struct ipv6_devconf {__s32 mc_forwarding;#endif __s32 disable_ipv6; +__s32 drop_unicast_in_l2_multicast;__s32 accept_dad;__s32 force_tllao;__s32 ndisc_notify;
include/uapi/linux/ipv6.h +1 -0
@@ -174,6 +174,7 @@ enum {DEVCONF_USE_OIF_ADDRS_ONLY ,DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT ,DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN , +DEVCONF_DROP_UNICAST_IN_L2_MULTICAST , DEVCONF_MAX };
net/ipv6/addrconf.c +8 -0
@@ -4672,6 +4672,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, array[DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN ] = cnf->ignore_routes_with_linkdown;/* we omit DEVCONF_STABLE_SECRET for now */ array[DEVCONF_USE_OIF_ADDRS_ONLY ] = cnf->use_oif_addrs_only; + array[DEVCONF_DROP_UNICAST_IN_L2_MULTICAST ] = cnf->drop_unicast_in_l2_multicast; }static inline size_t inet6_ifla6_size (void )
@@ -5734,6 +5735,13 @@ static struct addrconf_sysctl_table .proc_handler = addrconf_sysctl_ignore_routes_with_linkdown, }, { + .procname = "drop_unicast_in_l2_multicast", + .data = &ipv6_devconf.drop_unicast_in_l2_multicast, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, + {/* sentinel */ } },
net/ipv6/ip6_input.c +10 -0
@@ -134,6 +134,16 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt IPV6_ADDR_MC_SCOPE(&hdr->daddr) == 1) goto err; +/* If enabled, drop unicast packets that were encapsulated in link-layer +* multicast or broadcast to protected against the so-called "hole-196" +* attack in 802.11 wireless. +*/ +if (!ipv6_addr_is_multicast (&hdr->daddr) && + (skb->pkt_type ==PACKET_BROADCAST || + skb->pkt_type ==PACKET_MULTICAST ) && + idev->cnf.drop_unicast_in_l2_multicast) + goto err; +/* RFC4291 2.7 * Nodes must not originate a packet to a multicast address whose scope * field contains the reserved value 0; if such a packet is received, it
Signature · 6 lines
2.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 3/4] ipv6: add option to drop unicast encapsulated in L2 multicast
From: Johannes Berg <[email protected]>
Date: Thu, 4 Feb 2016 13:31:19 +0100
Quoted 10 lines
From: Johannes Berg <[email protected]>
In order to solve a problem with 802.11, the so-called hole-196 attack, add an option (sysctl) called "
drop_unicast_in_l2_multicast" which, if enabled, causes the stack to drop IPv6 unicast packets encapsulated in link-layer multi- or broadcast frames. Such frames can (as an attack) be created by any member of the same wireless network and transmitted as valid encrypted frames since the symmetric key for broadcast frames is shared between all stations.
Quoted 2 lines
Reviewed-by Julian Anastasov <[email protected]>Signed-off-by Johannes Berg <[email protected]>
Applied.
PATCH v3 4/4 ipv6: add option to drop unsolicited neighbor advertisements
In reply to a message not in the archiveFrom: Johannes Berg <[email protected]>
In certain 802.11 wireless deployments, there will be NA proxies that use knowledge of the network to correctly answer requests. To prevent unsolicitd advertisements on the shared medium from being a problem, on such deployments wireless needs to drop them.
Enable this by providing an option called "drop_unsolicited_na".
--- Documentation/networking/ip-sysctl.txt | 7 +++++++ include/linux/ipv6.h | 1 + include/uapi/linux/ipv6.h | 1 + net/ipv6/addrconf.c | 8 ++++++++ net/ipv6/ndisc.c | 9 +++++++++ 5 files changed, 26 insertions(+)
Documentation/networking/ip-sysctl.txt +7 -0
@@ -1672,6 +1672,13 @@ drop_unicast_in_l2_multicast - BOOLEAN By default this is turned off. +drop_unsolicited_na - BOOLEAN + Drop all unsolicited neighbor advertisements, for example if there's + a known good NA proxy on the network and such frames need not be used + (or in the case of 802.11, must not be used to prevent attacks.) + + By default this is turned off. + icmp/*: ratelimit - INTEGER Limit the maximal rates for sending ICMPv6 packets.
include/linux/ipv6.h +1 -0
@@ -56,6 +56,7 @@ struct ipv6_devconf {__s32 ndisc_notify;__s32 suppress_frag_ndisc;__s32 accept_ra_mtu; +__s32 drop_unsolicited_na;struct ipv6_stable_secret {bool initialized;struct in6_addr secret;
include/uapi/linux/ipv6.h +1 -0
@@ -175,6 +175,7 @@ enum {DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT ,DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN ,DEVCONF_DROP_UNICAST_IN_L2_MULTICAST , +DEVCONF_DROP_UNSOLICITED_NA , DEVCONF_MAX };
net/ipv6/addrconf.c +8 -0
@@ -4673,6 +4673,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,/* we omit DEVCONF_STABLE_SECRET for now */ array[DEVCONF_USE_OIF_ADDRS_ONLY ] = cnf->use_oif_addrs_only; array[DEVCONF_DROP_UNICAST_IN_L2_MULTICAST ] = cnf->drop_unicast_in_l2_multicast; + array[DEVCONF_DROP_UNSOLICITED_NA ] = cnf->drop_unsolicited_na; }static inline size_t inet6_ifla6_size (void )
@@ -5742,6 +5743,13 @@ static struct addrconf_sysctl_table .proc_handler = proc_dointvec, }, { + .procname = "drop_unsolicited_na", + .data = &ipv6_devconf.drop_unsolicited_na, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, + {/* sentinel */ } },
net/ipv6/ndisc.c +9 -0
@@ -887,6 +887,7 @@ static void ndisc_recv_na(struct sk_buff *skb) offsetof(struct nd_msg, opt));struct ndisc_options ndopts;struct net_device *dev = skb->dev; +struct inet6_dev *idev =__in6_dev_get (dev);struct inet6_ifaddr *ifp;struct neighbour *neigh;
@@ -906,6 +907,14 @@ static void ndisc_recv_na(struct sk_buff *skb)return ; } +/* For some 802.11 wireless deployments (and possibly other networks), +* there will be a NA proxy and unsolicitd packets are attacks +* and thus should not be accepted. +*/ +if (!msg->icmph.icmp6_solicited && idev && + idev->cnf.drop_unsolicited_na) +return ; +if (!ndisc_parse_options (msg->opt, ndoptlen, &ndopts)) {ND_PRINTK (2 , warn,"NS: invalid ND option\n" );return ;
Signature · 6 lines
2.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 4/4] ipv6: add option to drop unsolicited neighbor advertisements
From: Johannes Berg <[email protected]>
Date: Thu, 4 Feb 2016 13:31:20 +0100
Quoted 10 lines
From: Johannes Berg <[email protected]>
In certain 802.11 wireless deployments, there will be NA proxies that use knowledge of the network to correctly answer requests. To prevent unsolicitd advertisements on the shared medium from being a problem, on such deployments wireless needs to drop them.
Enable this by providing an option called "
drop_unsolicited_na".Signed-off-by Johannes Berg <[email protected]>
Applied.
PATCH v3 2/4 ipv4: add option to drop gratuitous ARP packets
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
In certain 802.11 wireless deployments, there will be ARP proxies that use knowledge of the network to correctly answer requests. To prevent gratuitous ARP frames on the shared medium from being a problem, on such deployments wireless needs to drop them.
Enable this by providing an option called "drop_gratuitous_arp".
--- Documentation/networking/ip-sysctl.txt | 6 ++++++ include/uapi/linux/ip.h | 1 + net/ipv4/arp.c | 8 ++++++++ net/ipv4/devinet.c | 2 ++ 4 files changed, 17 insertions(+)
Documentation/networking/ip-sysctl.txt +6 -0
@@ -1215,6 +1215,12 @@ drop_unicast_in_l2_multicast - BOOLEAN 1122, but is disabled by default for compatibility reasons. Default: off (0) +drop_gratuitous_arp - BOOLEAN + Drop all gratuitous ARP frames, for example if there's a known + good ARP proxy on the network and such frames need not be used + (or in the case of 802.11, must not be used to prevent attacks.) + Default: off (0) + tag - INTEGER Allows you to write a number, which can be used as required.
include/uapi/linux/ip.h +1 -0
@@ -166,6 +166,7 @@ enumIPV4_DEVCONF_IGMPV3_UNSOLICITED_REPORT_INTERVAL ,IPV4_DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN ,IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST , +IPV4_DEVCONF_DROP_GRATUITOUS_ARP , __IPV4_DEVCONF_MAX };
net/ipv4/arp.c +8 -0
@@ -735,6 +735,14 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb) (!IN_DEV_ROUTE_LOCALNET(in_dev) && ipv4_is_loopback(tip))) goto out; +/* +* For some 802.11 wireless deployments (and possibly other networks), +* there will be an ARP proxy and gratuitous ARP frames are attacks +* and thus should not be accepted. +*/ +if (sip == tip &&IN_DEV_ORCONF (in_dev,DROP_GRATUITOUS_ARP )) + goto out; +/* * Special case: We must set Frame Relay source Q.922 address */
net/ipv4/devinet.c +2 -0
@@ -2185,6 +2185,8 @@ static struct devinet_sysctl_table { "igmpv3_unsolicited_report_interval"),DEVINET_SYSCTL_RW_ENTRY (IGNORE_ROUTES_WITH_LINKDOWN ,"ignore_routes_with_linkdown" ), +DEVINET_SYSCTL_RW_ENTRY (DROP_GRATUITOUS_ARP , +"drop_gratuitous_arp" ),DEVINET_SYSCTL_FLUSHING_ENTRY (NOXFRM ,"disable_xfrm" ), DEVINET_SYSCTL_FLUSHING_ENTRY(NOPOLICY, "disable_policy"),
Signature · 1 line
2.7.0
Re: [PATCH v3 2/4] ipv4: add option to drop gratuitous ARP packets
From: Johannes Berg <[email protected]>
Date: Thu, 4 Feb 2016 13:31:18 +0100
Quoted 10 lines
From: Johannes Berg <[email protected]>
In certain 802.11 wireless deployments, there will be ARP proxies that use knowledge of the network to correctly answer requests. To prevent gratuitous ARP frames on the shared medium from being a problem, on such deployments wireless needs to drop them.
Enable this by providing an option called "
drop_gratuitous_arp".Signed-off-by Johannes Berg <[email protected]>
Applied.
From: Johannes Berg <[email protected]>
Date: Thu, 4 Feb 2016 13:31:17 +0100
Quoted 10 lines
From: Johannes Berg <[email protected]>
In order to solve a problem with 802.11, the so-called hole-196 attack, add an option (sysctl) called "
drop_unicast_in_l2_multicast" which, if enabled, causes the stack to drop IPv4 unicast packets encapsulated in link-layer multi- or broadcast frames. Such frames can (as an attack) be created by any member of the same wireless network and transmitted as valid encrypted frames since the symmetric key for broadcast frames is shared between all stations.
Quoted 5 lines
Additionally, enabling this option provides compliance with a SHOULD clause of RFC 1122.
Reviewed-by Julian Anastasov <[email protected]>Signed-off-by Johannes Berg <[email protected]>
Applied.