News for hackers. Stuff that matters.
Re:A Kernel Hacker Meets Fuchsia OS by why_only_15 on Wednesday May 25, 2022 @07:39AM (#31503097)
Interesting. Is this in practice implemented as just capabilities being large numbers so it's impractical to guess them, or does the kernel have a table with all of a process's capabilities and when a message is sent to a process with capabilities the kernel adds them to the table?

That is -- are capabilities just pieces of data in a message you can detect and try to use, or do they have to be added explicitly to a message to send them

Re:A Kernel Hacker Meets Fuchsia OS by jamesr_ on Wednesday May 25, 2022 @09:04AM (#31503947)
The kernel maintains a table of which handle values each process owns and uses that to check the capabilities of the calling process when handling a syscall. Sending a capability in a message updates this table as the ownership changes.

We use (somewhat) large and non-dense numerical values for handle values to reduce the risk of accidental reuse of values.

Re:A Kernel Hacker Meets Fuchsia OS by giyanani on Wednesday May 25, 2022 @08:27AM (#31503540)
I’m not sure how fuschia does it, or how feature-based capabilities work, but Cheri[1] uses capabilities for memory management and isolation.

It uses a couple of techniques, like wide/tagged pointers, object ids, and a special hardware managed bit to track illegal modifications.

If I had to hazard a guess, those object ids are probably useful for general capability systems.

I think apple (maybe as just an arm feature?) can do encrypted pointers, with a per application key tracked by the kernel.

[1] https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/

Re:A Kernel Hacker Meets Fuchsia OS by zahllos on Wednesday May 25, 2022 @10:44AM (#31505296)
> I think apple (maybe as just an arm feature?) can do encrypted pointers, with a per application key tracked by the kernel.

ARM has added both pointer authentication codes and memory tagging extensions to their ISA, from (I think) ARMv8.5-A. Apple are the only ones to implement silicon that supports PAC that anyone can buy today but a) this will change fast and b) I might've missed something else.

I wouldn't say "encrypt". You can still read what the pointer is, you just can't forge it. It is more like a message authentication code, or keyed hash. Confusingly, the ARM ISA suggests you use the block cipher QARMA, a lightweight block cipher of their design. This is not a mistake - from a crypto academic's perspective the distinction between block cipher and hash is not so easy to draw as it tends to be communicated: you can get a block cipher out of the SHA family of hash functions (called SHACAL) and so on. There was a line of work on finding a suitable family of permutations (e.g. Gimli) that could be hardware-accelerated and appropriate constructions built from that.

tl;dr it is kinda a "signed pointer", and if you forge the pointer but get it wrong you don't get another chance because the CPU triggers a fault, so you can use lower security lightweight ciphers and still make exploitation very unreliable.

Now Fuchsia:

As to how Fuchsia does it, we can just look at the source:

1) https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/z... 2) https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/z... 3) https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/z...

For example. I don't think there's any magic here: the kernel maintains some structure to reference jobs, tasks or whatever we are calling our isolated privilege boundaries, in which the capabilities are described. On the face of it this "looks" a lot like the traditional permission-style system, but the key difference is that the root job will hand out capabilities to processes it has created. An example is probably the best way to proceed: on a linux system, you might decide your process needs to read `/system/sensitive_file`. To allow this to happen, you might grant access to the user using some other command: chown .../chmod ..., or you might set an selinux policy, semanage fcontext -a -t myprocess_t /system/sensitive_file. In a capability-based system, chmod/chown and even running the process as a user don't exist as concepts. You would need to use a process authorized to transfer a capability to your target process to access this file. In some ways, this is closer to selinux, in the sense that semanage fcontext updates policy, except that the policy is somewhat dynamic here: if your controlling process provides the capability, then the child process gets it.

In a microkernel-based architecture, the idea is that "servers" (jobs that are arguably part of the system, but don't need to be in kernel) are similarly userspace processes subject to said capabilities also.

Of course, some part of the code still needs to be privileged here, let's call it the "executive". This code is doing the capability enforcement, and if that code contains bugs, all bets are off, as always. You can't defend such code from itself, even with capabilities.

The real disappointment is that Zircon is written in C++. Granted it was probably started before Rust was a thing, but while Ada/SPARK might be considered a bit unfashionable, it has some formal verification available, and if you're going for a software solution this should help reduce exploitable bugs. Personally I also wonder what about seL4 made it unsuitable for this: granted, it is not complete as a system, but neither is Zircon alone.

Re:A Kernel Hacker Meets Fuchsia OS by conioh on Saturday May 28, 2022 @05:54PM (#31544219)
> ARM has added both pointer authentication codes and memory tagging extensions to their ISA, from (I think) ARMv8.5-A. Apple are the only ones to implement silicon that supports PAC that anyone can buy today but a) this will change fast and b) I might've missed something else.

I'm not aware of other generally available chips with pointer authentication. The Qualcomm Snapdragon 8cx Gen 3 supposedly support PA. The Lenovo ThinkPad X13s supposedly contains it, but when will it actually be commercially available is anyone's guess.

Also, I think it's ARMv8.3.

Re:A Kernel Hacker Meets Fuchsia OS by pjmlp on Wednesday May 25, 2022 @05:55PM (#31511154)
Apple isn't the only one, Oracle did it first with SPARC ADI on Solaris.
Re:A Kernel Hacker Meets Fuchsia OS by zahllos on Wednesday May 25, 2022 @06:15PM (#31511384)
True. I was mainly responding to the ARM encrypted pointers part with that bit. ARM also didn't invent memory tagging, which might also have come from SPARC ADI (I'm not sure), but they also plan to include that. QARMA itself looks to be designed by Qualcomm engineers: https://eprint.iacr.org/2016/444.pdf

A lot of good stuff has come from SPARC :)

Re:A Kernel Hacker Meets Fuchsia OS by saagarjha on Thursday May 26, 2022 @08:46AM (#31517635)
PAC is ARMv8.3, and Apple implements their own custom algorithm rather than QARMA.
Re:A Kernel Hacker Meets Fuchsia OS by zahllos on Thursday May 26, 2022 @10:42AM (#31518919)
Yeah, ISA says you can. I wouldn't be surprised if other people pick other implementations, I'm not entirely sure why ARM felt the need for QARMA in the first place given there are already extensive choices for lightweight block ciphers, but... there you are.
Re:A Kernel Hacker Meets Fuchsia OS by formerly_proven on Wednesday May 25, 2022 @09:48AM (#31504458)
You know a limited kind of capability - file descriptors (or kernel handles). Those are just a number that allow you to manipulate some object in a defined way. You can give this number to someone else, and they can't make use of it at all, you have to go ask the kernel (using e.g. a unix socket and ancillary messages) to pass the capability to another process.
Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Wednesday May 25, 2022 @11:00AM (#31505531)
That is sort of the opposite of a capability. In fact, files are capabilities exactly because you can hand off a file descriptor and, by virtue of that handle, you grant access.

File systems aren't actually capability based (generally, in practice) because you can 'ls' and 'cd ../'. Otherwise they could be.

Dropbox Paper is a good example of a capability based system. Anyone with a URL can perform actions on a page, but there is no way to derive a URL without already having access to it, you must be told what it is. This is because the urls are sufficiently random so as to be unguessable.

Re:A Kernel Hacker Meets Fuchsia OS by trasz on Wednesday May 25, 2022 @12:14PM (#31506602)
>File systems aren't actually capability based (generally, in practice) because you can 'ls' and 'cd ../'. Otherwise they could be.

That's precisely how it works in FreeBSD (https://www.freebsd.org/cgi/man.cgi?capsicum).

Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Wednesday May 25, 2022 @03:01PM (#31509016)
"generally, in practice"

There's also openat on linux. My point is that the general, practiced approach is not capability based.

Re:A Kernel Hacker Meets Fuchsia OS by trasz on Thursday May 26, 2022 @03:19AM (#31515629)
It it’s not capability based, because Linux doesn’t provide necessary functionality. FreeBSD does, as explained in the man page I’ve linked to.
Re:A Kernel Hacker Meets Fuchsia OS by throwaway894345 on Wednesday May 25, 2022 @12:25PM (#31506743)
Are capabilities rotated periodically? Or how do you deal with leaked values?
Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Wednesday May 25, 2022 @03:10PM (#31509131)
A leaked capability is indeed a critical failure. There are multiple ways to deal with that.

1. Revocation is pretty critical

2. Bounding of capabilities is great - "You have this right for N seconds", meaning that a leak is less devastating

3. Not relying on capabilities is the best option. Capabilities are amazing, and a wonderful access control system. Their main benefit is that you can very naturally implement extremely fine grained access control. The downside is that it becomes hard to reason about that access control statically. ACLs are bad at super fine grained access control, but they're great for "I can look at a policy and know what this thing can/ can not do".

Layering ACLs and capabilities is a match made in heaven.

Re:A Kernel Hacker Meets Fuchsia OS by Rusky on Wednesday May 25, 2022 @01:04PM (#31507291)
It doesn't matter if the value is leaked, because it's meaningless to another process- like a file descriptor, it's just an entry in a table in the kernel, so it can only be used by the process it was granted to.

(One process can request that the kernel transfer it to another process, which I guess you might be referring to? I'm not familiar with Fuchsia specifically here but generally speaking capability-based designs sometimes let you "revoke" a capability if that is something you need, though that's not really something you would need to do periodically.)

The Dropbox approach is sort of a fuzzy emulation of this, by necessity, because it's a public internet service.

Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Wednesday May 25, 2022 @03:00PM (#31508999)
> It doesn't matter if the value is leaked, because it's meaningless to another process- like a file descriptor, it's just an entry in a table in the kernel, so it can only be used by the process it was granted to.

No, this is incorrect. Let's just quote wikipedia,

> A capability (known in some systems as a key) is a communicable, unforgeable token of authority.

communicable. It is practically the whole point that you can say "hey, here's a capability I have, now you have it".

Yes, it matters deeply if a capability is leaked. To name something is to authorize something, in capabality land.

No, you do not need to ask for it to be transferred. As with file descriptors in linux you can fork to delegate (or otherwise pass the handle around). Again, it is fundamental to capabilities that the capability is the authorization.

Dropbox's approach is faithful. And, in order to deal with these limitations of capability systems, Paper supports ACLs as well as capabilities. I think it's going to be a huge problem if Fuschia doesn't, but I don't know what they do - certainly some sort of MAC is desirable.

Re:A Kernel Hacker Meets Fuchsia OS by Rusky on Wednesday May 25, 2022 @03:42PM (#31509521)
I think we're just talking past each other- by "leak" I was talking about something like accidentally sharing an fd number, not actually communicating the capability itself. This is how Dropbox's approach is a "fuzzy emulation"- you can in principle forge a URL in a way that you could never forge a file handle.

Obviously if you communicate the actual capability itself to someone you didn't intend to, that would be bad. But that's more of a question of API design- even fork is, in this sense, asking for the capability to be transferred. This is a very different problem than the one Dropbox has- no amount of random guessing, or side channel information leaks, or anything else like that, is going to land a capability in another process's kernel table.

Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Wednesday May 25, 2022 @03:48PM (#31509625)
Yes, accidentally sharing a capability is a leak. If I accidentally printed out a capability it would be 'leaked' and anyone who reads that capability now has obtained it an dcan use it.

> you can in principle forge a URL in a way that you could never forge a file handle.

Maybe it would be better to not talk about fs apis, because they're not really capability based, so I suspect that's the confusion.

The point is that if someone has a capability, they have that capability. There is no additional access control or checking in a capability based system. You absolutely have to consider things like rotation and revocation.

Re:A Kernel Hacker Meets Fuchsia OS by Rusky on Wednesday May 25, 2022 @04:01PM (#31509786)
I'm specifically talking about Fuchsia and other kernel-based capabilities here. You fundamentally cannot print out that kind of capability in any way that matters- the only thing that determines whether a process has it is the table in the kernel, not whether it can produce a particular bit pattern.

In this sense, fs APIs are a fine example, as long as you keep the ls/.. caveats in mind. If you have a file descriptor for something inaccessible through the global file system namespace, then the only way to grant that to another process is via specifically-designed APIs like domain sockets or fork.

As I said in my first comment, there are of course other reasons you might want to revoke a capability. But unlike Dropbox URLs, true capabilities are unforgeable, so you don't need to rotate them out simply to make them harder to guess- they're already unguessable.

Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Wednesday May 25, 2022 @05:10PM (#31510602)
I think the short version is that you're just not talking about capabilities.
Re:A Kernel Hacker Meets Fuchsia OS by Rusky on Wednesday May 25, 2022 @05:58PM (#31511201)
How so? The line you quoted from Wikipedia calls them unforgeable. If you can forge it (by printing it out and reading it back in from somewhere else, or by guessing a bit pattern) then surely it's not a capability?
Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Wednesday May 25, 2022 @08:49PM (#31512883)
So to recap, a capability is a value that represents authorization. The value must not be forgeable, the value must be communicable.

If I'm unable to convey authorization by giving you the token, it is not a capability. If I am able to guess the token, it is not a capability.

Delegation is not forgery. Forgery would be an entity creating a token without the token being delegated to that entity. Guessing is forgery, but you can "guess" a uuid in the same way that you can "break AES" with a bruteforce, which is to say, you can't.

Re:A Kernel Hacker Meets Fuchsia OS by formerly_proven on Thursday May 26, 2022 @04:26AM (#31516003)
> If I'm unable to convey authorization by giving you the token, it is not a capability. If I am able to guess the token, it is not a capability.

You're taking "communicable" too literally. It doesn't mean "literally giving someone else this bytestring and now they can do it, too". It means "there is a way to give someone else the capability". SCM_RIGHTS is such a way to communicate capabilities between processes. Further up above you're also conflating files and file descriptors, which are very different things.

Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Thursday May 26, 2022 @05:17AM (#31516273)
No, it does not mean there is "a way", it means that the name is the permission. Period. That is what a capability is. If the name is not the permission, it is not a capability.
Re:A Kernel Hacker Meets Fuchsia OS by monocasa on Thursday May 26, 2022 @06:03AM (#31516537)
It can mean what the parent is talking about, and does in this case. It's an older morph of capability based security than the newer crypto enforced name concept, but equally valid.

You can read more about it in Capability Based Computer Systems by Henry M Levy. The Hydra MMP, GE-645, and iAPX 432 are older implementions of this concept in hardware.

In both cases (TCB table enforced and crypto one way function enforced) the name is the capability, but in a kernel (or hardware) table enforced method that's interpreted to mean that you have permission to access the object by having a simply having reference to it in your descriptor table.

You can see this also in KeyKOS, EROS, Coyotos, XOK, and SeL4 among many other capability based kernels. They don't give you a capability just because you got access to a global name to the backing object; the whole shtick for them is there is no global names for objects, only descriptor tables.

Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Thursday May 26, 2022 @06:13AM (#31516581)
What you're referring to is how operating systems maintain the integrity of capabilities. This is addressed directly in 'Capability Based Computer Systems'. I would direct you to chapter 1 section 1.1.

> A capability thus provides addressing and access rights to an object.

> a program cannot access an object unless its capability list contains a suitably privileged capability for the object.

> Capability system integrity is usually maintained by prohibiting direct program modification of the capability list. The capability list is modified only by the operating system or the hardware.

> Thus, a program can execute direct control over the movement of capabilities and can share capabilities, and therefore, objects, with other programs and users.

You can think of capabilities lists as kernel managed namespaces if you'd like. Maybe that would help clear things up.

Re:A Kernel Hacker Meets Fuchsia OS by monocasa on Thursday May 26, 2022 @06:43AM (#31516792)
In these non crypto enforced capability systems, you don't have any control over other processes' names for resources addressed through capabilities is the point I'm attempting to get across.

Crypto backed capabilities that merge the token with the capability itself are one morph of capability based systems, but that's not the scheme being described here. Leaking the name of a capability (the offset in the cap table) does not leak the capability itself in these TCB schemes. Capabilities are still communicable in these TCB schemes because they're explicitly supported in the IPC mechanisms like SCM_RIGHTS or seL4_Send along side normal data. The token naming a capability then is a per process concept and you can clone an identical capability into several tokens in the same cap table, unlike the crypto enforced scheme which are basically content addressed storage for a secret representing a capability.

Re:A Kernel Hacker Meets Fuchsia OS by throwaway894345 on Thursday May 26, 2022 @10:31AM (#31518772)
Semantics aside, is it accurate to say that schemes where the capability is represented as a signed token require care and diligence to mitigate leaks, and schemes where the capability is represented as a table entry (mapping a user/process to a permission) don't require any meaningful care/diligence?
Re:A Kernel Hacker Meets Fuchsia OS by Rusky on Thursday May 26, 2022 @12:22PM (#31520246)
Yes, that's the idea.

Though, it is still worth thinking about how someone might accidentally leak a table-based capability via API misuse. For example, if table entries are reused over time you might get a sort of use-after-free situation where you mean to share an old capability but accidentally share the new one that replaced it.

Re:A Kernel Hacker Meets Fuchsia OS by Rusky on Wednesday May 25, 2022 @09:04PM (#31513004)
Yes- the thing you didn't mention is the distinction I'm making between Dropbox URLs/UUIDs/etc and fds/Fuchsia capabilities, which is that the former are bit patterns and the latter are pieces of state in a trusted kernel.

The attack surface of "bit pattern" capabilities is much larger than that of "trusted state" capabilities- even if you can't practically guess one, all you need to break it is to discover its bit pattern somehow. Trick someone into printing it out, read it out of their memory space, leak it via a side channel, attack their UUID generator, etc. For this kind of capability, sure- periodic revocation might be a worthwhile mitigation technique.

But for "trusted state" capabilities, which is where this thread started, and what file descriptors exemplify, this all goes away. The attack surface is reduced to the kernel and the component's own API (nothing new here) and its use of a finite set of capability delegation APIs. Leaking an fd number does not leak the corresponding capability the way leaking a Dropbox URL does, so there is relatively little purpose in rotating those out.

Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Thursday May 26, 2022 @05:16AM (#31516266)
I wouldn't call it attack surface, I would call it a threat model. And yes, the threat model of capabilities includes the fact that knowledge of the capability connotes the capability. If it didn't, it wouldn't be a capability.
Re:A Kernel Hacker Meets Fuchsia OS by Rusky on Thursday May 26, 2022 @12:17PM (#31520189)
Then you've spent this entire thread arguing over clearly-explained terms of art, what a colossal waste of effort. I'm sorry to inform you: this is not how Fuchsia uses the word "capability."

Using your version of the word, since you appear incapable of operating in any other frame, Fuchsia does not use capabilities, and thus does not have the problem of leaking permissions via bit patterns. The original question of whether they need to be rotated periodically does not apply here.

Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Thursday May 26, 2022 @08:00PM (#31524712)
There's really no debate here. I'm right. A capability is defined as I have defined it. You can say "well Fuschia says otherwise", that's fine, people are wrong about things all the time. Such is life.

Of course I've spent this entire thread explaining a clearly defined term, was that not obvious?

And yes, rotation is relevant to capabilities because leaking capabilities is a critical failure. It's not the only way to protect capabilities though, you can add ACLs or namespaces, which is what Fuschia seems to do.

Re:A Kernel Hacker Meets Fuchsia OS by throwaway894345 on Wednesday May 25, 2022 @01:34PM (#31507765)
No, I just didn’t realize that it wasn’t useful to another process. I thought it was akin to a secret.
Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Wednesday May 25, 2022 @03:00PM (#31509004)
To be clear, the answer to your question is "yes, you need a way to revoke capabilities if you care about them leaking", and the user who responded to you is incorrect.
Re:A Kernel Hacker Meets Fuchsia OS by throwawaymaths on Wednesday May 25, 2022 @09:34AM (#31504313)
In theory you could do even better than that -- you could make capabilities cryptographically signed tokens, so that you don't need to ask the kernel to verify the validity of your request every time. If your chipset supports crypto intrinsics this will almost certainly be better than an interrupted syscall.
Re:A Kernel Hacker Meets Fuchsia OS by staticassertion on Wednesday May 25, 2022 @11:44AM (#31506161)
Yeah, reminds me of biscuits[0] - because they're based on asymmetric cryptography they can be delegated, but also attenuated. If you just use a uuid that's not really going to work as well, unless you're willing to go back to some authority to forge a new, lesser capability.
Re:A Kernel Hacker Meets Fuchsia OS by jnwatson on Wednesday May 25, 2022 @09:53AM (#31504536)
Not even theoretical. An early capability based OS called KeyKOS worked that way.
Re:A Kernel Hacker Meets Fuchsia OS by throwawaymaths on Friday May 27, 2022 @10:53AM (#31530350)
Oh man KeyKOS, that brings back memories. I wonder if crypto intrinsics might breathe life back into something like KeyKOS. More contemporary, I think Sel4 does as well.

In my comment I meant "in theory fuscia could have been architected/could be rearchitected that way", sorry should have been more clear.

Re:A Kernel Hacker Meets Fuchsia OS by monocasa on Thursday May 26, 2022 @05:34AM (#31516374)
It's per process like the file descriptor tables under most kernels. Knowing that some other process has a certain socket open as fd '5' on their fd table doesn't give you enough information to attach the same socket to your fd table at fd 5 or otherwise.