News for hackers. Stuff that matters.
Re:WireGuard: next generation in-kernel modern VPN by hueving on Tuesday June 28, 2016 @12:59PM (#11995389)
Why is this in the kernel? It seems to me like a failed separation of concerns compared to running this in userspace. There shouldnt be anything magical requiring this level of coupling.
Re:WireGuard: next generation in-kernel modern VPN by zx2c4 on Tuesday June 28, 2016 @02:26PM (#11996201)
Because it's necessary for any reasonable performance. If you're concerned about this, you might have several heart attacks when you look at the obscene amount of code that IPsec has in the kernel. IPsec is the only other alternative for high speed VPNs, and it's frighteningly complex, both in deployment and in codebase.

WireGuard, on the contrary, is around 4000 lines of core code. This is super short, and allows for a single individual to audit it. By focusing on simplicity and ease-of-auditability, I hope to achieve something that can be considered secure.

Compare this to the massive codebase of OpenVPN/OpenSSL and the various other userspace (read: slow as mollasses) VPNs. WireGuard is considerably shorter and simpler than those too.

Also, keep in mind that on Linux, jumping from userspace to ring0 execution isn't exactly difficult. So in practice I'm not sure it matters.

I make a living by exploiting kernels. This makes me very aware of the questions associated with running this in the kernel. I've tried to write WireGuard using my experience breaking similar codebases; WireGuard is short enough that it should receive the thorough attention that this sort of software deserves. By focusing on simplicity, I think we can in time achieve something quite trustworthy.

Finally, there will be a (necessarily lower speed) cross platform implementation released that's written in Rust. At the end of the day I suspect that all parties will find themselves pleased.

Re:WireGuard: next generation in-kernel modern VPN by q3k on Tuesday June 28, 2016 @02:46PM (#11996373)
> Because it's necessary for any reasonable performance.

This is simply not true [1] [2].

[1] - http://dpdk.org/

[2] - http://info.iet.unipi.it/~luigi/netmap/

Re:WireGuard: next generation in-kernel modern VPN by zx2c4 on Tuesday June 28, 2016 @02:55PM (#11996455)
I love DPDK. Super fun. I've actually made a few projects with it. But this is for creating closed network systems, not for integrating into Linux's networking infrastructure. If somebody would like to produce a WireGuard implementation (library, I guess) for DPDK, I'd be super happy about this, and I'm sure it'd find some specialized users. But for everything else, there's the ordinary design.
Re:WireGuard: next generation in-kernel modern VPN by q3k on Tuesday June 28, 2016 @03:05PM (#11996555)
It is absolutely possible to create DPDK applications that send/receive data into the Linux network stack using KNI [1]. I'm not sure if I'm qualified to say whether DPDK is “for” something, but the means to achieve this exist.

[1] - http://dpdk.org/doc/guides-16.04/prog_guide/kernel_nic_inter...

Re:WireGuard: next generation in-kernel modern VPN by loeg on Tuesday June 28, 2016 @02:54PM (#11996445)
Both userspace stacks bypass several standard kernel interfaces to achieve good performance. If you want to integrate with normal kernel configuration (interface, routing, etc) and BSD sockets, then maybe you do need to be in the kernel. (Maybe it's possible to improve user<->kernel interfaces to reach good performance in userspace with standard kernel configuration, but we aren't there yet.)
Re:WireGuard: next generation in-kernel modern VPN by jpgvm on Wednesday June 29, 2016 @02:08AM (#11999814)
However it's basically true. You need to be running specific hardware and/or drivers to make use of kernel bypass. You most definitely will never be able to use DPDK on the average laptop.

For a VPN that intends end-user device deployment it's kind of silly to require specific hardware.

Re:WireGuard: next generation in-kernel modern VPN by steveklabnik on Tuesday June 28, 2016 @02:46PM (#11996372)
I am extremely excited to see the Rust version of this; how do I learn about it when it ships?
Re:WireGuard: next generation in-kernel modern VPN by zx2c4 on Tuesday June 28, 2016 @02:56PM (#11996463)
Join the mailing list!

https://lists.zx2c4.com/mailman/listinfo/wireguard

And if you're savvy and want to get involved with development, we need all the help we can find!

Re:WireGuard: next generation in-kernel modern VPN by tinco on Wednesday June 29, 2016 @05:08AM (#12000369)
Why necessarily lower speed? Are you hinting at bounds checking? I would think that a rust implementation might have slightly more pressure on the CPU but would not effectively be slower. Am I wrong?
Re:WireGuard: next generation in-kernel modern VPN by steveklabnik on Wednesday June 29, 2016 @06:21AM (#12000639)
I took it as "the Rust version is in userspace, and therefore will be slower than the in-kernel version."
Re:WireGuard: next generation in-kernel modern VPN by tinco on Wednesday June 29, 2016 @06:57AM (#12000761)
Right, I heard about the Rust kernel module[1], but perhaps its environment isn't friendly enough yet to attempt to port a project like this to?

edit: Just read a little bit of its source, apparently you have to disable std, and he replaces it with his own linux_std that at this point has only printf implemented. So yeah it'd be a pretty intense project if one would attempt it :)

1] https://github.com/tsgates/rust.ko

Re:WireGuard: next generation in-kernel modern VPN by steveklabnik on Wednesday June 29, 2016 @07:01AM (#12000781)
Elsewhere in the thread, they talk about upstreaming some code into the kernel itself; so it has to be in C for that. That's my guess, anyway.

(disabling std is standard in environments like this; and you still get libcore, which is a lot of stuff!)

Re:WireGuard: next generation in-kernel modern VPN by tinco on Wednesday June 29, 2016 @07:17AM (#12000839)
What are the odds of getting Linus to approve of Rust? It would be the greatest thing ever. Imagine the impact on the C++ community.. You might say I'm a dreamer, but I'm not the only one ;)
Re:WireGuard: next generation in-kernel modern VPN by steveklabnik on Wednesday June 29, 2016 @01:25PM (#12003118)
I would imagine very low.
Re:WireGuard: next generation in-kernel modern VPN by hueving on Wednesday June 29, 2016 @01:25AM (#11999670)
>If you're concerned about this, you might have several heart attacks when you look at the obscene amount of code that IPsec has in the kernel.

I know and I don't much care to see this crappy tradition carried on with this new protocol. :(

Re:WireGuard: next generation in-kernel modern VPN by tptacek on Tuesday June 28, 2016 @01:25PM (#11995631)
Severe performance impact.

Since we appear to be bolted to the top of the thread, I'll repeat a point I buried deeper in the thread:

Maybe some readers of this thread are in the habit of casually bringing up random VPN connections between individual Linux machines. But in my experience, people tend to invest in VPN configurations so they can connect developers and ops to deployment environments and company networks. That's like, the big use case for serious VPNs.

In a serious VPN deployment, if you lose code execution on the VPN server, whether the attacker took the kernel or just a userland process is somewhat far down the list of concerns you have to deal with. A better first concern is "how many machines inside the VPN did the attacker just get code execution on because they can now make direct TCP connections to all our internal services".

From that vantage point, I'm a little less concerned about whether my VPN server is at CPL0, and a lot more concerned with things like "how complex is this code and how straightforward is it to audit".

Re:WireGuard: next generation in-kernel modern VPN by derefr on Tuesday June 28, 2016 @02:30PM (#11996239)
I'm guessing the parent wasn't really considering the kernel/userland distinction in terms of security (for, after all, a daemon running as root in userland isn't all that different from running in the kernel in terms of attack surface; the real security boundary lies between privileged/unprivileged in userland, not between kernel and userland.)

Rather, I expect what the parent wanted to assert was that a novel malformed packet to a badly written VPN shouldn't bring down the entire VPN gateway machine, but rather just the VPN daemon itself, which can then be brought back up by init(8).

Or, to put it another way—even though the Linux kernel is monolithic, it can still pay to treat it as a microkernel and isolate fault-prone code outside of it.

This was one of the original big benefits of running e.g. the NTFS-3G in FUSE, when that support was experimental: the NTFS-3G driver did crash—often!—and your OS stayed up. The—usually external—drive would just get unmounted, and have to be fsck(8)ed.

Now, the argument you used also kind of answers this: in full deployments, we've got dedicated VPN gateways on either side of the connection, so if the VPN process crashes, the whole machine may as well have crashed, since it's not doing much of anything else anyway.

That's probably true for most networks, but I could think of one exception: a VPN gateway serving multiple customer sites. You'd really rather that one VPN "receiver" process crash on that host (like one webserver instance serving one request) than that the whole machine crash.

Re:WireGuard: next generation in-kernel modern VPN by tptacek on Tuesday June 28, 2016 @02:31PM (#11996252)
NTFS is way, way, way, way, way more complicated than any VPN, and this particular VPN was designed to avoid complexity.
Re:WireGuard: next generation in-kernel modern VPN by dmix on Tuesday June 28, 2016 @02:30PM (#11996244)
And getting from userspace -> kernel doesn't pose much of a challenge for attackers. Especially on stock Ubuntu machines that are so popular. You could probably even find priv esc exploits on github/blogs for a good chunk of VPS servers. I did that when I forgot a root password on a yr old machine recently.
Re:WireGuard: next generation in-kernel modern VPN by code_research on Tuesday June 28, 2016 @09:05PM (#11998825)
Interesting! Would you please like to post some links to actual privilege escalation code for a stock Ubuntu 16.04 - thank you very much for your attention!
Re:WireGuard: next generation in-kernel modern VPN by comex on Tuesday June 28, 2016 @04:45PM (#11997409)
Who said anything about VPN server? The client is running the same code; what if it's popped?

> But in my experience, people tend to invest in VPN configurations so they can connect developers and ops to deployment environments and company networks. That's like, the big use case for serious VPNs.

You're missing the other big use case: VPNs used to get one's internet access through a different network, in order to evade the Great Firewall, limit NSA surveillance, increase security on public Wi-Fi networks, or just watch Netflix in the 'wrong' country. These are often commercial (not that commercial VPNs are going to use WireGuard as long as it's Linux only, but hopefully it'll be ported to other OSes before long). In this case there are two ways the client could be attacked: the network itself could be modifying packets or doing a MitM attack, or the server could be hostile (either after being hacked itself [maybe with the same exploit] or, mostly applicable to government attacks, because it was set up as a honeypot).

With a network attack, the VPN code is one of the only bits of attack surface available to the attacker, especially if they don't know your IP on the other end. A hostile VPN server you route all internet access through, in comparison, already has quite a lot of power over you (hopefully you access all important services over TLS), and at the very least makes it easy to deliver (easier-to-find) browser exploits - but in theory the VPN implementation provides some additional attack surface which bypasses all sandboxes. Also, paranoid users may have a setup where their browsing is done inside a VM, whose connection is routed through a VPN on the host end. This helps ensure that they're not accidentally passing traffic through the wrong interface or leaking their real IP, and provides some protection against attackers who get code execution with the goal of finding said IP (see FBI Tor malware). In such a setup, any networking code running outside the VM is an interesting target.

Linux isn't all that secure against unsandboxed user processes, but VPN code has a simple enough interface that it could in theory be sandboxed effectively using seccomp-bpf.

The Great Firewall tries to block VPNs anyway, so a Chinese attack isn't all that realistic as things stand, but who knows, it might be nice if WireGuard grew some kind of obfuscation support. And that leaves the NSA and others.

Anyway, I don't actually think there's a problem with WireGuard living in the kernel! - because I don't think it presents much attack surface. It's a very small codebase, and performance is important for these applications. Actually, I wholeheartedly approve of WireGuard: it seems like a really nice design, and I've experienced the pain of just getting other VPN implementations to work, never mind securely. But if there is a vulnerability in WireGuard, then for the reasons I've stated, I think its placement in the kernel matters.

Re:WireGuard: next generation in-kernel modern VPN by viraptor on Tuesday June 28, 2016 @08:19PM (#11998629)
You seem to talk about a completely different use of VPN. The "VPN server you route all internet access through" is a glorified encrypting web proxy. There's no "server" in WireGuard as far as I can tell - it's only peers which expose whole networks behind them. Both use cases call for very different solutions: The corporate-style VPN protects your networks and remote endpoints from someone random connecting to them. The glorified web-proxy style VPN needs to mainly encrypt all the outgoing traffic.

I doubt WG is a real candidate for the case you're talking about.

Re:WireGuard: next generation in-kernel modern VPN by comex on Tuesday June 28, 2016 @09:23PM (#11998885)
It's very common to use existing VPN protocols for proxying - Google "VPN" and you'll find many commercial services. And the WireGuard white paper mentions passing all traffic to a single peer as a possible configuration, so I think it should be usable for it as well, modulo OS compatibility. Which is good, because existing VPN software suffers from the same configuration and security headaches whether it's used for proxying or corporate networks, and non-VPN proxies are an inadequate solution.

Web proxies are suboptimal because they only work with web traffic, or even if you use HTTP CONNECT, only TCP. SOCKS is mildly better at a protocol level, with SOCKS5 supporting both TCP and UDP, but still suboptimal if the server end is able to give each client its own IP address (not so common with IPv4 but easy with IPv6), due to the existence of protocols other than TCP and UDP. More importantly in practice, SOCKS clients are typically implemented in userland rather than the kernel, so each individual application needs to be configured to use the tunnel. There is software that lets you use any program with SOCKS by hooking socket API calls, but that's essentially a hack, and has many practical issues. Much nicer to just have the tunnel as a network interface like any other, and let the kernel's network stack work as it was designed - which is usually done with VPN software. VPN also lets one host transparently handle proxying for another, e.g. a router for a home network, or the host in the VM setup I mentioned in my original post.

Re:WireGuard: next generation in-kernel modern VPN by viraptor on Tuesday June 28, 2016 @09:54PM (#11999014)
I think you missed my point. Sure, every VPN solution can be turned into "proxy all internet traffic through there" with enough configuration. What I meant is that tptacek was talking about commercial/serious VPN as in corporate usage, not commercial as in "it takes money from anyone".

You're talking about two completely different use cases with very different goals and potential issues.

Re:WireGuard: next generation in-kernel modern VPN by comex on Tuesday June 28, 2016 @11:23PM (#11999289)
You said that WireGuard was not "a real candidate for the case you're talking about", and I explained why it being (eventually) widely adopted for that case is both possible and desirable. I don't see much point in arguing over what tptacek meant.
Re:WireGuard: next generation in-kernel modern VPN by tptacek on Wednesday June 29, 2016 @01:45PM (#12003249)
I think your point, about people using VPNs in situations where their personal computer is more valuable than the VPN connection, is well taken.
Re:WireGuard: next generation in-kernel modern VPN by hueving on Wednesday June 29, 2016 @01:21AM (#11999657)
I was not concerned about it from a security perspective at all. What I'm concerned about is poor software engineering. The fact that something like a particular flavor of VPN needs to be integrated directly into the kernel smells to me like a shortcut to skip improving the kernel to enable better userland networking code. Why this VPN proto and not the next hot item of the month? How about we start throwing some load balancing code directly into the kernel? How about some TLS termination?
Re:WireGuard: next generation in-kernel modern VPN by tristor on Wednesday June 29, 2016 @05:03AM (#12000349)
> How about we start throwing some load balancing code directly into the kernel?

You mean like lvs/ipvs? [0]

> How about some TLS termination?

You mean like the KTLS project from Dave Watson/Facebook Engineering? [1][2]

[0] http://www.linuxvirtualserver.org/software/index.html

[1] https://github.com/ktls/af_ktls

[2] https://lwn.net/Articles/666509/

Re:WireGuard: next generation in-kernel modern VPN by lobster_johnson on Tuesday June 28, 2016 @02:51PM (#11996414)
Tinc [1] is a userspace VPN, and a good demonstration of how slow networking gets when done that way, compared to kernel-mode VPN routing such as IPsec and VxLAN.

[1] https://www.tinc-vpn.org

Re:WireGuard: next generation in-kernel modern VPN by cm3 on Tuesday June 28, 2016 @03:13PM (#11996627)
Because of the kernel/userspace model of Linux and missing efficient microkernel structure which would lend itself more fittingly to an efficient network tunnel. We're using monolithic kernels because they've attracted the most driver support over the years, but with things like seL4 out in the open, this is bound to change because there's no argument that there's no modern microkernel available to build hardware drivers on. On top of stability, you also get a viable capability system in seL4.
Re:WireGuard: next generation in-kernel modern VPN by Animats on Tuesday June 28, 2016 @05:00PM (#11997531)
This is a good application for seL4. As has been pointed out, the machine running this probably does nothing else. So you don't need 99% of Linux.

The less irrelevant code you have around in a security box, the better. The attack surface shrinks.