7 ms·
I'm surprised to see that very little is known about the Linux kernel keyring. With keyctl[0] you can put secrets scoped to process and ensure that they stay th
by akendo 9mo ago
I'm surprised to see that very little is known about the Linux kernel keyring. With keyctl[0] you can put secrets scoped to process and ensure that they stay there only for a limited period of time. The tool isn't intuitive, but it's the way I put my 2FA and secrets in shell without bothering about leaking anything.
[0]: https://www.man7.org/linux/man-pages/man1/keyctl.1.html https://www.man7.org/linux/man-pages/man1/keyctl.1.html
- whatevaa 9mo agoNothing to be surprised about here. First time I'm learning of this existence.
- forty 9mo agoI was also surprised that this would be surprising :)
- linuxhackerman 9mo agoIt's definitely a powerful approach; I don't think it's particularly viable for the sort of use cases where you're throwing secrets around in a shell: - It's not supported natively by most software (if I wanted to use it with `curl` for example, it would only be able to replace the `rbw` example since I still need to pass the secret to curl somehow); - I don't think it's likely to gain widespread adoption, due to being a linux-specific API; - The API itself suffers from some poor design choices, imho; it is not currently possible to set an expiry on a keyring entry without an intermediate state where the data is loaded but no expiry is set: https://lore.kernel.org/keyrings/ygar0hbrm05.fsf@localhost/T/ https://lore.kernel.org/keyrings/ygar0hbrm05.fsf@localhost/T... It's really nice as a concept and when you're developing an application where you control the entire flow of the secret data, but I don't see much practical value in it for general use cases. Exposing it as a filesystem could be a potential bridge for application support (something like `curl -H @</proc/self/keyring/@u/gitlab-authorization-header`?), though I suspect that wouldn't fly upstream because files aren't generally treated as carefully as explicit secret things. Non-enumerability (`-r` on `/proc/self/keying` and `/proc/self/keyring/*`) would help here, but I still seriously doubt that the keyring maintainers would find this to be a sane proposition :)