555 points · by todsacerdoti · 6y ago · 178 comments
That is a kernel nearly 10 years old. Of course, the router itself was released 7 years ago... and of course vendor stopped updating fimware as soon as they could... and of course it's still in production and for sale... and of course it costs $150+.
It's a good thing dd-wrt and similar exist.
(Anecdotally I've had three Netgear devices in my life and all of them caused severe problems. Enough for me to have them on my personal blacklist for life.)
There's code in there besides the kernel that could have (security) bugs and backdoors.
The hardware design and manufacture is outsourced to different vendors, in this case to Foxconn. See here: http://en.techinfodepot.shoutwiki.com/wiki/Netgear_R7000
The software engineering is probably also outsourced mostly.
The board manufactures normally do not want to upgrade. I very rarely see that device manufactures are doing a major kernel upgrade when a new SDK with support for a new major kernel is available from the SoC vendor. This only happens when they need new features from the new major kernel which can not easily be backported and a very big customer is requesting this and normally they also need a good internal software engineering department.
That just means the device vendor isn't exerting the necessary pressure/valuation on the SoC manufacturer.
Of course the SoC manufacturer is gonna try and get away with bare minimum of work for absolute maximum of profit, just like the device vendor. The pressure needs to start at the end of the chain (which is end users) :/
We had some of their switches at a previous job; resetting the admin password required placing a phone call to Romania.
Normally there are 4 years between the start of a new SoC project and the first device with this SoC hitting the consumer market. Then this SoC is used for new projects the next 4 years and shipped in new products an additional 4 years. Now the kernel is 12 years old. ;-)
Even when an SoC vendor provides a new SDK with a more recent kernel, most of the device manufacturers like Netgear would not upgrade existing products to this new SDK with the new kernel. They also have extensions to the kernel and would have to adapt them and then do an extensive validation again. Normally even security updates are only taken if someone proves that this specific devices is affected.
Often board manufacturers do not even want to use the new SDK with the new kernel and security updates for new products when they already have devices with the old SDK, because this would reduce their possibility for reuse.
The SoC vendor wants to reduce effort and will avoid to supporting many different kernel versions. If the major customers do not want to upgrade to a more recent kernel version they will stay at something old because the board manufacturers want to.
The problem is that the customer does not care for security. The customer cares for security features you can print on a box, but not for something like fixing publicly known bugs in the kernel in 6 months.
The home router industry is a hardware business, it is run by hardware experts and they run software like hardware. You start a project, build the system (hardware + software)), you validate the features and then ship it. Now you can start the next project.
If you want to change this you have to request this directly, for small customers this is no really useful, but if you are an ISP and buy 500k units a year, then you can put some peruse on the supply chain. Please communicate your requirements often and to many people in your supply chain and not as one of the 5000 requirements in the excel sheet. If you decide against a vendor because of their software, communicate this to them directly and to many people in his organization, to increase the likelihood that it reaches someone who understand this and fixes it in the future. If they improve you can choose between more vendors next time.
What factor of man years do you imagine OS vendors put into release engineering ? Some open source vendors support multiple streams of the same kernel across multiple architectures all at the same time for over 10 years. The problem is not impossible, not even hard, just work.
> Probably 500k to 2M lines of kernel code for such a router.
What functionality do they include that is not included in standard Linux ? I have setup a router that does the same as these systems with little work. No fancy GUI though.
I _guess_ they could not upstream their kernels ./arch. However the arch specific code doesn't churn hard between major releases.
Do you think you're overselling the complexity they have to manage ?
> The home router industry is a hardware business, it is run by hardware experts and they run software like hardware.
I think this is the crux of the discussion, they simply do not consider software updates as part of the life cycle, until they get customer demand they will not.
It depends on the hardware, for example, mine D-Link DIR-320 (A) has 32MB of RAM and 4MB of ROM (3801599 bytes, to be precise). It's not enough to fit last kernel (IIRC 4.8 for OpenWRT) even without GUI, I had compile it with some hacks.
Edit. It has 256MB of RAM, 128MB of ROM. There is no excuse for this.
Does having a modern kernel solve this issue? As I understand even on a modern linux-based router one should disable those ALGs as it's their [lack of] interface with connection state which is broken.
Is the story here that ALG is a crude hack, which works by naively looking at each packet, without trying to parse the whole stream, and so is vulnerable to this kind of confusion? If so, there are presumably endless varieties of ways to fool it.
But specifically regarding your question, sip looks like http. Same structure / similar response codes. They probably didn't want to write a very strict sip-detector and ended up checking "looks like a verb+destination+ headers? Good enough". Or maybe it's to support http proxies where a http CONNECT session can turn into sip-tcp? (Never seen that in practice, but I guess it's possible)
Or maybe it's just that the alg processing is per-packet, not per-session? Who knows. Just login to your router and turn off ALG. Your SIP phone most likely already knows how to deal with NAT using stun/turn.
Yes, ALGs basically try to understand the protocol while implementing as little of it as possible. They are likely always broken in some way, and there is almost always a better way to solve the problem they attempt to solve.
the core of the hack is the realisation that one can generate arbitrary tcp or udp packets from a browser by exploiting ip packet fragmentation (embed the evil packet in a large http post request that gets fragmented at just the right place).
and worst of all: i don't see a quick way to mitigate this. afaict, router firmware will need to be updated to check the fragment offset, right?
... except these arbitrary tcp/udp packets will be in IP fragments and therefore invalid.
The whole thing hinges on the NAT code NOT reassembling IP packets before passing them to ALG and the ALG also not observing IP fragmentation. These are bugs, and pretty severe at that, so the mitigation is just to patch the code.
But, as gnfargbl points out, the TCP case can be caught by looking at the sequence number, or perhaps some conntrack state.
Go to your router's panel and disable sip support / alg. Even if you use sip, it's still going to work. (Apart from some really weird edge case network setups)
On OpenBSD, PF will reassemble fragmented packets by default.
Your question still stands, is this sufficient to prevent this attack? Perhaps someone who has a greater understanding of PF and of this exploit can respond.
So this effectively means that you can't bind anything any more on a machine that maybe runs a web browser.
I didn't even know you could draw isometric diagrams with draw.io - any more info on this?
They have a isometric edge/cube/square available there.
Also, when you are creating a new diagram, they have a couple of examples in the cloud section.
The exploit depends on the user’s router having enabled a broken ALG implementation that ignores the fragment offset. I’m sure there are routers in the wild with this bug, but so far I haven’t been able to find any reports of the POC exploit working for anyone who tried it (before it was disabled).
The POC shows a message about ALG not being enabled when it fails.
Samy says he used a Netgear R7000. Would be interesting to get some POC test results from other routers.
To detect the attack in the TCP case, the ALG would have to keep a stateful record of the initial sequence number on the outgoing SYN, and to accept the SIP REGISTER packet iff seq# == ISN+1.
Because home router firmware is invariably written by the lowest bidder, I would be surprised if very many firmwares actually do that.
ALG was always a horrible hack, and has been pretty much obsolete for the past 10 years. Just turn it off.
It has always been a big mistake for browsers to allow internet pages to make requests to LAN IPs. This has been exploited before: https://www.forcepoint.com/sites/default/files/resources/fil...
A browser has no way to know that a particular IP address is supposed to be sacred and unreachable by other websites. I’ve seen several dashboards hosted externally that load things from internal IP addresses and that design is MEH but it works.
If a page loads a resource from a private address, it can easily be a local cache on the network. It can also be a dashboard like the example I gave you.
Example:
local.dashboard.example.org resolves to 192.168.255.244
dashboard.example.org resolves to some public address and web server that hosts a page that loads resources from local.dashboard.example.org
The suggestion is that an http://web.url.com page should be blocked from making requests to LAN addresses, at least by default.
I'm fine with a browser setting for corporate/enterprise users, but most home internet users have no need or desire for web pages that load resources from the LAN.
Two reasons: 1) This attack is mostly built off the complexity that NAT requires. STUN, TURN, ICE, ALG all exist because of NAT. More complexity == harder to secure. 2) The actual goal of the attack is to allow sending packets to hosts on your network. The only reason this is even considered an attack is because treating NAT as a security layer leads to the neglect of other security aspects. It shouldn't be a problem for your smart doormat to get random packets, but we've been allowing vendors to get away with shipping devices/software that's only safe on a 'local' network for decades.
Maybe I'm wildly optimistic but if ipv6 had been the default for years and every random IoT device was expected to be exposed to the public internet by default, maybe we'd actually have something approaching decent host-level firewalling/etc by default too?
And that makes sense. The security scope of "my home" makes a lot of sense. I want every computer in my house to print on the printer without extra authentication. And the tiny CPU in smart doormat can probably be overwhelmed even by a tiny DOS attack.
As I read it, it’s a little narrower than that. This attack allows someone to open up an unexpected port on your NAT gateway back to one specific host - the machine that ran the attack code in its browser. It, on its own, doesn’t get you to all the other hosts like the Smart Doormat or the IoT oven. (Though there’s a reasonable chance this gives the attacker, say, a redis port on your box, which gives them root, which then allows them to attack your doormat from there...)
As far as I can see it offers that activities behind the NAT get grouped behind one IP to the outside world, and I guess harder host discovery. Is there more?
Fibre with LTE HA is an extremely common scenario in the physical retail world. And retail is notorious for tight margins. With IPv4 this is dead simple for a router to do using NAT. With IPv6 it’s a nightmare because everyone is against NAT in IPv6. It took ages to get some form of NAT, and it’s poorly supported.
> multiple internet feeds .. assigned IPv6 block ... paying through the teeth to the ISPs for the privilege.
People like having their own network blocks, but typical route-my-subnet-here arrangement require all core routers to store the path to it. IMO assignments of globally re-routable addresses should be actively discouraged and you shouldn't get one unless you're an ISP. Not defending current payment arrangements.
Roaming should be done at or close to the endpoints - imagine if all internet routers had to keep and synchronize ~12G entries, usually in special CAM memory (currently at ~800K) - that does not scale, at all.
Gosh I wish IPv4 -> IPv6 was just 10.x.x.x -> 10.x.x.x.x.x
Instead we went to some hex-colon-double-colon BS. Like instead of "ssh 10.0.0.1" I have to now do "ssh -6 :://::2001:db8:ffff:abcd::34ff:2e6f::49af:fdef::"? Fuck that.
The simple fact that I can't memorize IPv6 addresses makes me lazy to use it. Whenever I want to SSH into a machine in 5 seconds flat I just rattle off its IPv4 address and I'm in.
It's called "The Domain Name System". I know it sounds alien and weird, but I assure you that you'll find that it greatly eases the burden of having to memorise network addresses!
Maybe your distribution has it included, just download it and give it a go.
>10.x.x.x.x.x
Looks a little short. It's more like... 10.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x
For IoT manufacturer a device which fails to work due to blocking is far worse than a security flaw. The first directly leads to chargebacks and bad reputation. The second leads to.. nothing.
So long as IPv4 exists, they have to at least use NAT, and their tracking is limited by IP pooling. But when we switch to IPv6 only, there's no good financial reason for devices to even have a 'deny all' stateful firewall.
It's more profitable to not bother with a firewall (just blame the client if he doesn't install a firewall to shield the device), than to deal with creating the right exceptions for firewall policy - even a single policy error would have a much stronger financial effect than opening up the device for the entire world.
I've tested it -- NATing the outbound connections from your router has no impact whatsoever on inbound connections (which makes sense, but people have a really hard time wrapping their heads around the idea).
hidden img tags to all common gateways (eg 192.168.0.1) are loaded in background
And why would browsers allow this? If I connect to external IP address, why would the browser happly parse such html tags that allows introspection of my local network? Unless of same origin, browsers should not allow this, seems like a bug.This is one of the reasons network level controls are problematic and the solution is being reinvented as "zero trust networking".
There's an argument against it, but it has always been allowed for things like images so far.
If you know for example the path of the netgear logo on a router, you can try loading it and determine success/failure. Existing CORS isn't strict enough to prevent this, and it's debatable whether it should be
Most people building their own iptables firewall would not enable any ALGs, since they're almost always the worst way to solve NAT problems. OTOH, vendors want everything to work out of the box as much as possible, even in weird edge cases with broken servers/clients, so they enable all available ALGs and sometimes don't even provide a way to turn them off.
However, don't miss that it all works because Netfilter passes IP fragments to the ALG instead of either reassembling packets first or making the ALG fragment-aware. Either way it's a software bug, rather than an inherent flaw of the protocol stack.
The author here presents two variants of the attack. The UDP variant does indeed rely on IP fragmentation, but the TCP version does not. To mitigate the TCP version, the ALG needs to be aware of the state of the TCP connection. Simple IP fragment reassembly won't be enough.
There's this and a hundred other ways to get past a firewall, and NAT is an ugly hack to extend the life of IPv4 not a security feature.
Firewalls are a false god. If something can't be connected to the open network and remain reasonably secure, it is not secure.
Firewalls are a necessary evil because there's a lot of insecure junk, sure, but relying on them encourages more insecure junk to be made and encourages lazy security practices in general.
See e.g. https://bugs.chromium.org/p/project-zero/issues/detail?id=14...
I could not find any definite information, but Firefox has a bug [0] which starts from:
> Browsers implement their own dns cache to prevent an attack known as dns rebinding.
You can still fix it at your own router/DNS server, though.
In GNU coreutils, you can do:
dd if=/dev/zero of=/tmp/z bs=8M conv=skip_bytes skip=2221098
https://www.man7.org/linux/man-pages/man1/dd.1.html
Same with count_bytes. Very useful at times.
Also, DNS Rebinding exposes services which are only listening on local interfaces (127.0.0.1) and I suppose this wouldn't.
Could someone help me understand some common circumstances in which using NAT Slipstreaming would be a better choice?
(*) I'm simplifying, what I mean is that DNS rebinding still limits you to only what you can do in the browser, which is effectively HTTP. Most non-HTTP services will generally just close your socket once they see you send an HTTP request.
e.g. firefox > about:config:
* media.peerconnection.enabled false
* webgl.disabled true
If browser games were a usecase of mine, then I'd keep my safe "daily driver" Firefox for surfing the WWW with the mentioned restrictions in place. I'd use a separate Chrome browser as a "game client".
They are generally somewhat neglected, and fairly complex, and they try to understand the flow of a protocol without really implementing the protocol, making them ripe for confusion-type attacks.
Unpatched Windows 10 (17134 1098) running an ancient Chrome 67.
Edit: I think I was thinking of http request smuggling, although I seem to recall something slightly different.