116 points · by popcalc · 3y ago · 157 comments
echo {a..z} | tr ' ' '\n' | sort -R | head -1 > /proc/sysrq-trigger
this is my favourite linux russian roulettehttps://www.kernel.org/doc/html/v4.15/admin-guide/sysrq.html...
EDIT: Yeah, uh, it works.
base64 /dev/urandom | tr -d '/+'| sed s/[^[:alpha:]]//g |tr 'A-Z' 'a-z' | dd bs=1 count=1 2>/dev/null LC_ALL=C tr -dc 'a-z' </dev/urandom | head -c 1 head -c 1
because sysrq-trigger will read only one character anywayThat's right, and the reason for that seeming surprising is that the threat model has quietly changed.
Previously: You owned your computer and your data on it, and you ran programs you trusted e.g. you'd buy Microsoft Word and you'd assume that that program acted in your interests, after all the seller wants you to buy the program. Desktop operating systems originated from the time when this was the current threat model.
Now: Programs don't necessarily act in your interest, and you can't trust them. The mobile phone operating systems were built with this threat model in mind, so mobile "apps" run in a sandbox.
As an example of a modern program that doesn't act in your interest, Zoom "accidentally" left a web server on Macs, even after it was uninstalled. https://techcrunch.com/2019/07/10/apple-silent-update-zoom-a...
Bravo on the rest, you nailed it.
Isn't this ridiculous? "the update does not require any user interaction and is deployed automatically." OK, how do I know if it's installed, or how to get it installed if it doesn't work? I guess there is just no help for me if I don't remember exactly how many auto-update mechanisms I've turned off.
</offtopic>
Even if you don't require TouchID, no apps will be able to upload your private keys anywhere as they never leave the enclave. Sure, they can still _use_ the keys without your permission but to do that they need to be running on the workstation.
That said, TouchID is really not very inconvenient and if you couple that with control persistence, muxing and keepalive on the SSH client, it's really a no-brainer.
Worked smoothly on most systems.
Kind of messy on Windows, because there are so many SSH agent implementations, but GPG4Win's latest version works with the native SSH now. Real progress.
You can have the best of both worlds by storing the key itself in a place that's not readable by many programs. TPMs and other such tech can store a key securely without risk of FunnyGame.app sending it to a remote server. In this model the key would be stored inside a safe, sandboxed place, only readable by an SSH agent or similar, which will prompt for permission to use the key every time. With fingerprint scanners and other biometrics being available even in cheap devices, this process can be relatively seamless.
If you run sufficiently modern SSH software, you can also use external key stores like Yubikeys to authenticate with plain old OpenSSH.
What is a program you "trust"? Something you bought online from a curated app store? Those occasionally have trojans as well. Something you downloaded? Well, if it's open source, that's the norm. Something you build from source? Most people wouldn't be able to spot an exploit hidden in the source code.
So.. it's run everything sandboxed by default the recommendation for regular users? Or is it "do not download or buy anything, it's simply not safe"?
And yes. The recommendation is to not just download and run programs you find on the web.
Yeah, that is probably the best solution. Most mobile OSes do that by default now anyways. Desktop Linux has Flatpaks and Snaps. Windows has UWP apps. And I think MacOS has its entitlements system IIRC.
If you don't absolutely trust somethibg, you shouldn't allow it to run unrestricted.
I agree that this is the state of affairs currently, but this could made to work similarly to how it works on Android perhaps, which has generally good UX for this.
If someone's targetting you with a 0-day exploit that can escape VM sandboxing, having your ssh key hijacked is probably one of your lesser problems. :-/
(If someone has a VM-busting 0-day, they're probably using it in a targetted fashion. The wider that kind of thing is used, the quicker it will be noticed, and patched, and made useless.)
1) use a pgp derived key, this means that anything authenticating will hit your gpg agent and only that, nothing is using that key then
2) load your key and then remove it, which I’ve done before using a LUKS encrypted partition (then load the key into ssh-agent, then remove the volume).
3) Storing your keys in the secure enclave on Apple computers. A little bit onerous if you use an external keyboard without touchID though.
I have a program on my computer that watches for read events in that folder to see if anything actually tries to read an access key. I can publish the source if you want. it uses inotify in linux.
firejail is a program that helps mitigate this issue by restricting syscalls of programs.
So if it's necessary to be careful about the defaults and to audit everything carefully etc. (i.e. if it's not idiot proof), I am doubtful this is as helpful in practice as one might expect.
I still agree with the general point of your comment though.
Running as root allows a bug in an application like a browser to be exploited and give them root access.
Then they can modify programs like firejail and suddenly things you thought were protected aren't.
This in turn would allow an attacker to login to my servers and other computers leading to a total compromise, as well as breaking trust and integrity of my email (PGP keys).
For my PC a compromise of the user I login as would mean total chaos and compromise, regardless if this user is root or not.
Installation of executable programs isn't limited to the root user, a normal unprivileged one can have them as well. I mentioned firejail because running the browser inside firejail should provide more protection against attacks (provided it's correctly cofigured, as a sibling comment points out), as the attacker couldn't escape the browser sandbox. Though in the current modern world, a browser context compromise could be enough to exploit a power user -- webmail, domain registrar web interface, stored passwords.
I doubt many power users actualy separate their workflow well enough as to change to a different VT (or SSH connection when working remotely) when performing administrative tasks on the computer that require root access. Because if users don't do that and just use a suid binary, like sudo, a malicious attacker with access to code execution in the context of an unprivileged user that elevates privileges with sudo could snoop the password entered by ptrace or simpler means, like a wrapper binary that gets installed without user's knowledge.
(I am by no means a security expert and my opinion shouldn't be treated as useful advice!)
I uninstalled sudo and started this habit on personal servers as well when the sudoedit vulnerability was announced, allowing anyone on a macine with sudo installed (regardless of sudoers config) to escalate to root.
It's not called private key because it is very secure and can't be accessed... It's on you to ensure that!
Also, some applications on MacOS are sandboxed, IIRC Mail is one of them. Also, some (all?) applications installed from AppStore. That's the reason I prefer installing applications from AppStore: they seem to be at least somewhat sandboxed.
For development, I try as much as possible to leverage remote development via [JetBrains Gateway](https://www.jetbrains.com/remote-development/gateway/) and [JetBrains Fleet](https://www.jetbrains.com/fleet/). VSCode also has remote development but they explicitly assume that remote machine is trusted (in the security note in the remote extension plugin readme). In the case of JetBrains tools I have not seen any explicit declaration whether remote host is trusted (as in: if remote machine is pwnd then we may as well let pwn your personal machine), but at a glance it seems like there are minimal precautions (if you run web application and open it in a browser, the Gateway will ask if you want to be redirected to a browser etc.)
Probably best scenario for such remote development clients on MacOS would be to put them in AppStore: this way they could leverage sandboxing and in the case of thin client, the sandboxing likely won't limit functionality.
Only programs running as you (or `root`). It's private to you⁰.
Programs running as other users cannot read the file.
(Assuming you've not changed the permissions on the file or the `~/.ssh/` directory)
⁰ and the sysadmin - but if they're not trustworthy they could just replace `/bin/bash` or the kernel with their own version that copied everything you typed anyway.
It's not easy for people to run only trustworthy software, or even software that has been reasonably vetted by others. Not everyone has the aptitude to know how to check for surreptitious file accesses, or have the desire to learn just to make functional use of their computers.
If you're trying to protect against running programs, you also need to protect against key loggers. Using hardware-backed keys and systems like Windows Hello for validation can help with that, as their UI is not easily interceptable.
In the end, there's no perfect way to protect your keys if you have a virus running on your computer.
You can use Nitrokey too, but IIRC be careful which one you buy as some are software-only implementations.
First I've heard of this. Do you have some links where I can read more about this?
Sure, the comparison table on the Nitrokey site[1] is probably sufficient.
Anything without a green tick next to "tamper-resistant smart card" is a software implementation with the associated risks (e.g. firmware updates are available[2] - i.e. if you can update the firmware then you've also got a low-level attack vector for miscreants).
Meanwhile all YubiKeys are hardware backed and it has never been possible to update firmware on them.
[1] https://www.nitrokey.com/#comparison [2] https://www.nitrokey.com/releases
By default chrome and firefox uses plege(1) and unveil(1). With the defaults, ~/.ssh cannot be seen by these browsers.
Namely, the JS sandbox of the browser already prevents filesystem access. But a user running `node` in a shell would not be protected by the browser or the hardening of browsers you mention. You would need to manually setup those protections for your command which most people will not do.
Similarly, Linux has filesystem namespaces, and tools like bubblewrap can achieve similar protections.
Lastly, the real risk of the above is that code is easily runnable automaticly with an `npm install` and if you have private repositories than node/npm would still need access to private key (or maybe token for http) information to fetch them.
Seriously, where's the downvote button when you need one?
But yes, it would be nice for Linux to gain a version of OpenBSD's unveil system call.
"try this edgy nerd game/challenge for the lulz" is just as valid an exploit as "to see the dancing pigs, just run this `curl | bash` command"
Using node seems like cheating; plus you have to call it explicitly, you know you really want to use this to prank your colleague who left their laptop unlocked.
Well, you can easily turn it into an executable (e.g., using `pkg` [1]) so that the target computer doesn’t even need Node.js installed.
This can be done purely in shell, no extra tools!
Also that's why you should have a strong password on things.
Oh well, good thing I always rename my keys with the remote host it connects to.
right?
What a poor name for a method.
Better?
1. The right part of equation converted into integer because the left part is integer. Conversion is done by rounding to nearest integer, and it will work this way.
2. The other way it may work is to convert 0 into floating point. Math.floor would make some canonical floating point representation of 0 from numbers in a range [0..1), and so do conversion of (int)0 into float.
One needs to really know his language of choice to master such subtleties.
Yes, as can be seen in the single line in the linked readme.
`node main.js` for a 1/6 chance of posting your SSH private key on pastebin :)
The question might be honest, but I don't think it adds much to the discussion.This approach is far from perfect but certainly disallows outright exfiltration attacks.
The added ‘benefit’ or ‘disadvantage’ is dependent on your use case.
If I regard my PGP key as the toehold to my online identity, having an ssh key tied to that identity is quite useful. Kind of neat to see the guy that signed the git commit is the same guy logging into the server, installing the software signed with the same pgp key.
If your threat model needs to key your online identity somewhat anonymous, than a private key per server is likely the way to go.
An encrypted ssh key is somewhere in the middle there.
I find it works quite well. The primary YubiKey goes everywhere I go; I have a lanyard for it. The backup YubiKey stays in the safe until I need it for something (e.g. signing someone else's PGP key, rotating subkeys, renewing the expiration date on a subkey, ...).
I also use both of them for FIDO, on websites that support real 2FA; more specifically, I enroll both of them, but I only routinely use the primary one.