Hacker News new | ask | show | jobs
by dangoodmanUT 29 days ago
A trick i've started doing is encrypting my env vars, then hard-code the decryption key in the code

that way if the provider gets popped, they need my binary to decrypt it

it shouldn't be necessary and it sounds stupid, but in cases like this, it proves invaluable (it appears they don't have customer code/binary access, but maybe that wasn't important enough to mention)

5 comments

I think this is a great example of temporarily effective "security through obscurity." It's also a trick that will only continue to work so long as it doesn't get adopted too widely.
It buys you time. I had my Anthropic key on Northflank set as an env var as-is and only found out about the incident from the HN front page 6 hours later (I didn't even get an email).

I rushed to the Claude platform console and was expecting to see a 4 figure usage bill or something. Luckily there was no usage.

But imagine if I were traveling. Even a rot13 of the key would've bought me enough time to rotate.

2 lessons:

- don't name your env var "CLAUDE_API_KEY". Call it "ARG_1" or something

- at least do some obscurin' so that the value doesn't start with "sk-ant..."

It's not security through obscurity. It makes it so that two things need to get breached to access the secrets: the application code and the stored secrets.
At this point, I kinda feel like the obscurity is our best mechanism for mitigation :(
Obscurity has always been party of security and will never go out of style.
Is there any security in internet traffic that isn't obscurity? It all boils down to private keys.
It's Obscurity Turtles all the way down.
Give it about a week until AI agents add his "tip" to their training...
it's not obscurity if they don't have the key, it's encrypted (yes i know quantum computers)
This would presumably be symetric encryptionwhich isn't typically vulnerable to quantum attacks...
Been doing something like this for a while with a single self contained .sh file that contains a python script:

https://github.com/thiswillbeyourgithub/envlocker

lock your env vars in hardware. even the whole server and code is compromised, the secrets are still safe.

so you dont need env2 to decrypt env1.

https://seal.zone/ does this

That's interesting but if the Azure hypervisor on the server hosting the VM is off limits then it's kind of false sense of security. They protect the key via a sidecar AMD SEV-SNP VM, and if you can't break into the hypervisor, sure, there might be an attack that doesn't involve doing that and only doing lateral movement, but an actual attacker isn't going to respect that boundary.
SEV-SNP treats the hypervisor as untrusted. So the only thing that can break it is a bug inside the enclave / hardware.
I will give you one better - encrypt the variables and move the secrets to a different server running hashicorp. Then load the secrets and keep them only in RAM.
Does Hashicorp actually employ any software engineers any more? I'm saying this having tried to deploy their product in an enterprise environment for the past couple of years. Almost nothing in their development, build, or delivery chain seems functional.
Or env1 is the key to decrypt env2
if the provider gets popped doesn't the binary get popped too? then simply use an LLM to reverse engineer the binary and get the key?
If its a targeted attack, they'll know and probably "crack" it. If its just data trawling, you might get owned one day if they bother, but likely the env `AWS_KEY=encrypted_abc` looks reasonably close to `AWS_KEY=unencrypted_abc` and any API key probing will just look like it got rotated already.

I think siblings are correct that the more widespread this is, the less effective once every dump is run through a "also look for keys in the binary" step.

If you want to be really paranoid you can make it an online process: application server makes an HTTPS request to a key server on different infrastructure to get the decryption key, then decrypts the secret. Use an IP whitelist.

That way read access to your infra provider is not sufficient, it requires an active component.