News for hackers. Stuff that matters.
Re:OpenBSD system-call-origin verification by Animats on Sunday December 22, 2019 @05:19PM (#21860039)
This effectively treats libc as a trusted interface. Checking should be at the protection boundary, the system call. This just makes attacks more complicated, not less successful.
Re:OpenBSD system-call-origin verification by vlovich123 on Sunday December 22, 2019 @06:20PM (#21860326)
Yes it’s more complicated but that’s how all security works and why security exploits are more expensive today than before. The reason this defense requires libc is because syscalls are not a function calls (you push args onto the stack and then trigger a software interrupt).

This defense technique is both simple (in terms of relative change from how things work today) and effective in that buffer overflows can’t ever call into the kernel but now instead have to go through libc which has had its location randomized on the application launch.

To provide this protection at the syscall layer would require some kind of randomization of how a syscall is performed which is something that has no prior art since that’s just pushing arguments into the stack and triggering an interrupt through a single instruction meaning complexity of the work is unknown in terms of how to secure a buffer overflow from being able to do that (ie harden an arbitrary process to not be able to directly jump into a syscall). Additionally because there’s no prior art the scope of that kind of change wouldn’t have the benefit of having well-understood behavior. Not impossible or prohibitive but raises the bar for the benefit you’d have to provide (& probably get a chip manufacturer and compiler vendors to go along with you). Also even if you could 3rd party binaries wouldn’t gain that protection magically. Putting this in libc is fantastic. Arguably Linux’s decision to treat libc as an external unrelated project and keep ABI comparability at the syscall layer prevents a protection mechanism like this.

Re:OpenBSD system-call-origin verification by Animats on Sunday December 22, 2019 @08:57PM (#21860971)
Yes it’s more complicated but that’s how all security works and why security exploits are more expensive today than before.

That's how security theater for software works. Today's attackers are well-funded and technically competent. This is a a defense against script kiddies.

The way to get rid of buffer overflows is to get rid of C in trusted code, not requiring users to go through libc. It isn't hard any more. We have Go, Rust, C#, Java, and even node.js and Python for server side. If you're running C in a user-facing server application, you're doing it wrong.

Re:OpenBSD system-call-origin verification by saagarjha on Sunday December 22, 2019 @09:06PM (#21861008)
I hope you're not suggesting that modern mitigations such as W^X and ASLR are "security theater" :/
Re:OpenBSD system-call-origin verification by Animats on Sunday December 22, 2019 @10:03PM (#21861213)
There are now many known attacks that can overcome address-space randomization. From Javascript in the browser, even. If someone can execute something locally and can peek at memory even in a limited way, they can find the code.[1]

The problem is buffer overflows. Fix that, and you don't need ASLR. ASLR is a form of security theater. It protects against dumb attackers.

[1] https://threatpost.com/bypassing-aslr-in-60-milliseconds/121...

Re:OpenBSD system-call-origin verification by saagarjha on Monday December 23, 2019 @03:09AM (#21862178)
ALSR was never meant to be the only line of defense against buffer overflow attacks; it’s a mitigation and not a solution. It makes it so a single exploit is not enough to achieve full control.
Re:OpenBSD system-call-origin verification by pjmlp on Monday December 23, 2019 @02:59AM (#21862147)
Unfortunately the only UNIX derived OSes that seem to care about that are Solaris on SPARC, iOS and Android on ARM, given how they take advantage of hardware tagging.

On x86 clones Intel just dropped the buggy MPX, with no replacement in sight.

And by the way things are going, any form of Safe C variant, doesn't appear to ever be adopted by UNIX clones.

Re:OpenBSD system-call-origin verification by vlovich123 on Tuesday December 24, 2019 @03:14AM (#21870670)
So let's assume the argument you're making is valid. ASLR is security theater because it protects against dumb attackers and fixing buffer overflows is the real solution.

Let's ignore that only recently have languages become available that make it possible to do so for high-performance code. That's a straightforward problem to solve - we know how to rewrite code in other languages, we can build tools to help us do it effectively, etc.

Let's also ignore that the recency of the languages mean that few people know how to code that effectively. We can train armies of engineers.

Let's ignore that training engineers takes significant amounts of time & shifting massive industries is difficult. That will be solved over time.

Lets ignore that Rust is more difficult to write than C/C++ - after all we're just converting existing code so that could be easier & the more time spent during writing is paid off by less time debugging at runtime.

Let's also ignore that A LOT of money has been poured into existing software and a non-trivial amount would have to be donated/volunteered to migrate to languages where it's impossible. We have OSS volunteers and enthusiasts and corporate interests are aligned to sponsor conversions.

Let's ignore that it takes time to integrate new languages into large corporations with existing build systems, infrastructure, tooling, etc. They'll solve that - again, interests are aligned here.

Let's ignore ALL of those issues. XSS, Rowhammer, Meltdown, Specter, downgrade attacks, man-in-the-middle, spear phishing, bugs in cryptographic algorithm design, side-channel attacks, etc are all still security attacks that have very real, and perhaps sometimes more serious, consequences than buffer overflows and waving a magic wand and fixing all buffer overflows wouldn't really adjust the security landscape we deal with today (maybe exploits would get more expensive - maybe, but ASLR et all do that too).

Following the same logic you laid out, this focus on buffer overflows at all is just security theater: ASLR is to buffer overflows what buffer overflows is to all security bugs overall. Back in reality ASLR, syscall origin verification, etc are all tools to try to mitigate the impact of all the things we ignored above & we know they have an impact because exploits keep getting more expensive, the low-hanging fruit bugs always get patched quickly, etc.

So sure, once the world has switched to Rust and we can turn off all these other protections that make buffer overflows more difficult. Oh, except we can't because now we remember that Rust has "unsafe" & that's used A LOT for various reasons. So now you need those protections anyway in case there's a bug in the unsafe code. And I 100% promise you there will be exploits there or in the Rust compiler. We can have confidence this will be the case because it's already happened: https://medium.com/@shnatsel/how-rusts-standard-library-was-..., https://blog.rust-lang.org/2019/11/01/nll-hard-errors.html). So your claim that we know how to fix buffer overflows is just inane even on its face. Hell, this isn't even a Rust-specific thing. I would be very skeptical if you could find a single semi-popular language without a buffer overflow bug of some kind somewhere, even in managed languages. The Java VM is full of them. Go has them. etc.

TLDR: You may want to reexamine your arrogance. Security is an extremely hard topic that will never get solved. Are there shitty programmers? Sure. Are security problems exclusively written by them? No. Security issues are an emergent property of complex systems. Some are easy to solve once and for all once the root cause is known. Others are MUCH harder.

Re:OpenBSD system-call-origin verification by miohtama on Sunday December 22, 2019 @05:32PM (#21860096)
In a long run the non-complicated solution is to get rid of anything that can compile to something with a buffer overflow.

Just half trolling.

Re:OpenBSD system-call-origin verification by jacquesm on Sunday December 22, 2019 @06:18PM (#21860313)
There goes Rust I guess...
Re:OpenBSD system-call-origin verification by pjmlp on Monday December 23, 2019 @03:00AM (#21862151)
I doubt we will ever see a UNIX clone written in Rust.

An OS that happens to expose some support for POSIX, yeah (e.g. Redox), but anything else wouldn't be an UNIX clone per se.

Re:OpenBSD system-call-origin verification by clarry on Monday December 23, 2019 @04:53AM (#21862572)
And that's all good, we don't need more people cloning an OS that was good 50 years ago.

Modern software is sidestepping the UNIX way left and right. Rightly so, as anyone who's tried to write anything serious in shell would know. Or anyone who realizes that non-blocking I/O was an afterthought (look into the history of select(2) and why libraries like libev exist and what problems they run into on unix derivatives..) and that there's still nothing like a standard, robust, well designed async I/O API.

Re:OpenBSD system-call-origin verification by pjmlp on Monday December 23, 2019 @05:49AM (#21862814)
UNIX was good, for an OS given away with source code and an almost free license (versus what other mainframe OS were asking for).

History would be quite different if AT&T was allowed to sell it from day one.

Re:OpenBSD system-call-origin verification by alexgartrell on Sunday December 22, 2019 @05:35PM (#21860109)
If you can change libc then you have equal to or greater permissions than the calling process. So this strengthens the security model.
Re:OpenBSD system-call-origin verification by jacquesm on Sunday December 22, 2019 @06:21PM (#21860331)
Does that mean that linking against libc is mandatory and that applications are not allowed to bring their own version of libc along for instance when linked statically?
Re:OpenBSD system-call-origin verification by saagarjha on Sunday December 22, 2019 @06:23PM (#21860340)
Statically linked programs automatically lose this protection, apparently.
Re:OpenBSD system-call-origin verification by ori_b on Sunday December 22, 2019 @09:16PM (#21861040)
Partly. If they jit, or have shellcode injected, that code is not mappable with syscall privilege.
Re:OpenBSD system-call-origin verification by throwaway2048 on Sunday December 22, 2019 @07:10PM (#21860572)
This is a flag in the ELF binary section headers, if you don't want it, flag your entire binary as "syscalls allowed".
Re:OpenBSD system-call-origin verification by tedunangst on Sunday December 22, 2019 @06:50PM (#21860480)
No. There's nothing special about libc.

(Oh, double checked, and uh, maybe. ld.so does treat libc specially if it finds it in the library list, but at that point, you are linking with libc. But afaik there's no requirement you use the system ld.so either.)

Re:OpenBSD system-call-origin verification by jacquesm on Sunday December 22, 2019 @06:54PM (#21860495)
Then isn't Animats' point valid?
Re:OpenBSD system-call-origin verification by tedunangst on Sunday December 22, 2019 @07:15PM (#21860606)
The point of doing this is not to protect against people bringing their own bad libc.
Re:OpenBSD system-call-origin verification by quietbritishjim on Sunday December 22, 2019 @06:27PM (#21860363)
But surely applications can make syscalls directly without invoking libc at all, by setting up the registers directly and directly executing the processor instruction that causes the right software interrupt? In which case the parent comment's point still stands: you can bypass checking that's at the libc level in a way you can't bypass checking within the kernel.
Re:OpenBSD system-call-origin verification by saagarjha on Sunday December 22, 2019 @06:29PM (#21860371)
No, because the calling address would be wrong.
Re:OpenBSD system-call-origin verification by jacquesm on Sunday December 22, 2019 @06:56PM (#21860502)
Why? After all, if libc is optional then you could simply provide a statically linked binary and be done with it, there would be no way to change the addresses.
Re:OpenBSD system-call-origin verification by saagarjha on Sunday December 22, 2019 @07:10PM (#21860571)
If you link against libc, that’s the only place you can enter the kernel from. If you statically link that is relaxed to “system calls can come from anywhere on your code”. The former has stronger protections, obviously, but as far as I can tell you still have protection from “wild shellcode in a RWX region can make syscalls”.
Re:OpenBSD system-call-origin verification by throwaway2048 on Sunday December 22, 2019 @07:19PM (#21860620)
Should be noted, that by default on OpenBSD, an RWX page is impossible, mprotect() will fail and the process will get killed trying.
Re:OpenBSD system-call-origin verification by saagarjha on Sunday December 22, 2019 @07:22PM (#21860637)
Surely there is an “out” for JITs that have not yet adopted W^X?
Re:OpenBSD system-call-origin verification by tedunangst on Sunday December 22, 2019 @07:25PM (#21860649)
An opt in actually, to request looser checks.
Re:OpenBSD system-call-origin verification by lostmsu on Sunday December 22, 2019 @08:00PM (#21860764)
Can't you make page temporarily RW, JIT, then switch back to RX?
Re:OpenBSD system-call-origin verification by saagarjha on Sunday December 22, 2019 @08:24PM (#21860845)
You can, but the application needs to support this.
Re:OpenBSD system-call-origin verification by throwaway2048 on Sunday December 22, 2019 @07:09PM (#21860566)
If you can provide a staticly linked binary, its already game over as far as these protections are concerned.

They are designed as a protection against stuff like ROP and other memory based, zero information attacks that hit already running processes.

Re:OpenBSD system-call-origin verification by saagarjha on Sunday December 22, 2019 @06:27PM (#21860367)
> Checking should be at the protection boundary, the system call.

This doesn’t make sense, though. This would mean the OS would need to know the control flow of the program itself to figure out whether it “should” allow a system call to proceed.