This bug is a masterpiece and you owe it to yourself to read this. So much effort for such a situational bug, it's heartbreakingly beautiful.
https://www.qualys.com/2023/07/19/cve-2023-38408/rce-openssh-forwarded-ssh-agent.txt
The key to it: OpenSSH will open and close dylibs in response to the agent protocol, because that's how it implements smart cards.
Then: ELF lets you mark functions in your dylib that get invoked on open (__attribute__(constructor)) and close (destructor).
Finally: lots of libraries in /usr/lib have constructors with side effects (like registering system call handlers that don't get unregistered because they're never expected to be unloaded, or invoking system call handlers by crashing when you randomly load them). So: UAF primitive.
@Shamar @tqbf What did plan9 do instead which provided similar reduction in resource usage?
I am indeed assuming it did something because I'd just be disappointed if the answer was just "lol suck it up".
Its lack would also make dynamic FFI profoundly annoying to implement, since it'd require the generation of stub programs and IPC.