Surely there must be a way to make container secrets less dangerous?

20 points by Spots


pushcx

There is, tokenization. This doesn't make the secrets not exist. It puts them in one very small, well-controlled, and observable basket.

I first saw this pattern in how Stripe minimized the scope of PCI compliance with Apiori. It is described starting at 18:41 in this talk. This replaces sensitive keys on ingress to the app rather than egress (what most container secrets are), but the pattern works in either direction. (I worked at Stripe but never touched this system; I don't know anything besides what's in this public talk.)

The phantom token pattern/credential proxy is another implementation of tokenization.

Shimming your own services with your own proxies is a useful strategy that generalizes.

dvogel

Rather than focusing on the form of the credential think about the lifetime of the credential. If the credential was valid for a shorter period of time then once it was exfiltrated it would have to be used very quickly to be of any use to the attacker.

But if the credential is short lived then it needs to be rotated quite frequently. More frequently than you could do manually. You would have to automate it. But if the attacker had persistent presence they could obtain the new credential as it was rotated in.

Instead of doing proactive rotation in order to ensure the application (and thus any attacker mimicking the application) has access to the credential, you can do just-in-time credential delivery. Place a proxy between your application and the network resources it needs. That proxy can then do identity-based authentication of your application environment and acquire credentials from an external service and inject them into the network stream. This allows the credential to be very short-lived. The application never holds the credential directly and thus any attacker mimicking the application also cannot easily retrieve it. There's a few of these types of proxies available today. I work on one for my day job. I think lobste.rs has rules against self-promotion so I won't link to it but if you search for "modern auth" or "identity based auth" or "managed access" you'll find more info about the whole category.

scanner_brightly

Build an API running on the host that the container queries for the secrets and it only allows them to be read once after container boot.

polywolf

The danger being, "if container gets popped, then attacker can read all the secrets inside it"? Honestly I think your "cheesy hack" of remounting /run/secrets after you're done with it is probably best given what your threat model seems to be.

In general I'd advise that, if the attacker can pop a shell, they might have been able to run arbitrary code in the context of your secret-accessing service beforehand, so they could've had access to the secrets anyways. In that case, your only recourse is principle of least privilege. The "credential proxy" mentioned by the other comment helps w/ this, limiting the privileges from "having a key that can be used at any time" to "having access to a proxy that can only be used now, inside the container". Still maybe insufficient against a motivated attacker, but stops some forms of exfil at least.