What’s the security model here? An app that gets user account access but gives it up if it can’t find exactly ssh keys?
My guess is that a malicious package is scanning your home directory for stuff like SSH keys, GPG keys, AWS keys, etc. It would have filesystem access permission already in the MacOS sandbox due to running inside a common interpreter like node or python, but it might be restricted from stuff like attaching to other processes memory, where it could just get the keys out of bitwarden.
Could also just be obscurity as most infostealers are programmed to grab keys from common locations and not many developers use bitwarden for keys.
If you want something resistant to a fully compromised system you need to use something hardware backed, whether an external key or an internal secure enclave.
Ok I played with this, made a very trivial encoding with 16 words in python for fun today.
code
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import ed25519
import itertools
import sys
if sys.argv[1] == "words":
withopen("wordlist-65536.txt", "r") as f:
words = [x.strip().lower() for x in f.readlines()]
assertlen(words) == 65536
k = serialization.load_ssh_private_key(open(sys.argv[2], "rb").read(),
password=None)
j = k.private_bytes(encoding=serialization.Encoding.Raw,
format=serialization.PrivateFormat.Raw,
encryption_algorithm=serialization.NoEncryption())
for a, b in itertools.batched(j, n=2):
z = a << 8if b isnotNone:
z = z | b
print(words[z], end=" ")
print()
elif sys.argv[1] == "key":
seed = [x.strip() for x ininput("Enter your mnemonic ssh key: ").split()]
assertlen(seed) == 16withopen("wordlist-65536.txt", "r") as f:
words = [x.strip().lower() for x in f.readlines()]
assertlen(words) == 65536
words_map = {}
for i, word inenumerate(words):
words_map[word] = i
k = bytearray()
for word in seed:
z = words_map[word]
b = z & 0xff
a = (z >> 8) & 0xff
k.append(a)
k.append(b)
k2 = ed25519.Ed25519PrivateKey.from_private_bytes(k)
private_bytes = k2.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.OpenSSH,
encryption_algorithm=serialization.NoEncryption())
open(sys.argv[2], "wb+").write(private_bytes)
```:::
My guess is that a malicious package is scanning your home directory for stuff like SSH keys, GPG keys, AWS keys, etc. It would have filesystem access permission already in the MacOS sandbox due to running inside a common interpreter like node or python, but it might be restricted from stuff like attaching to other processes memory, where it could just get the keys out of bitwarden.
Could also just be obscurity as most infostealers are programmed to grab keys from common locations and not many developers use bitwarden for keys.
If you want something resistant to a fully compromised system you need to use something hardware backed, whether an external key or an internal secure enclave.
Ok I played with this, made a very trivial encoding with 16 words in python for fun today.
code
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import ed25519 import itertools import sys if sys.argv[1] == "words": with open("wordlist-65536.txt", "r") as f: words = [x.strip().lower() for x in f.readlines()] assert len(words) == 65536 k = serialization.load_ssh_private_key(open(sys.argv[2], "rb").read(), password=None) j = k.private_bytes(encoding=serialization.Encoding.Raw, format=serialization.PrivateFormat.Raw, encryption_algorithm=serialization.NoEncryption()) for a, b in itertools.batched(j, n=2): z = a << 8 if b is not None: z = z | b print(words[z], end=" ") print() elif sys.argv[1] == "key": seed = [x.strip() for x in input("Enter your mnemonic ssh key: ").split()] assert len(seed) == 16 with open("wordlist-65536.txt", "r") as f: words = [x.strip().lower() for x in f.readlines()] assert len(words) == 65536 words_map = {} for i, word in enumerate(words): words_map[word] = i k = bytearray() for word in seed: z = words_map[word] b = z & 0xff a = (z >> 8) & 0xff k.append(a) k.append(b) k2 = ed25519.Ed25519PrivateKey.from_private_bytes(k) private_bytes = k2.private_bytes( encoding=serialization.Encoding.PEM, format=serialization.PrivateFormat.OpenSSH, encryption_algorithm=serialization.NoEncryption()) open(sys.argv[2], "wb+").write(private_bytes) ```:::