Mapping the Damage for When You Get Owned

  • Sam Yoon CTO & Co-founder

In 2016, North Korean hackers attempted to steal nearly 1bn USD from Bangladesh’s central bank. The attackers ultimately reached the ultra-guarded SWIFT terminals located in guarded rooms that had the power to move Bangladesh’s foreign currency reserves. They nearly got away with $951 million from the people of Bangladesh, but due to sheer luck, only succeeded in stealing $81 million — the financial equivalent of that time an American B-52 Stratofortress accidentally dropped two 3.8-megaton Mark 39 nukes on North Carolina.

Much of our industry’s security posture depends on protecting the machines (deployed servers/containers and local development machines) and credentials authorized to move money. These are our equivalent of Bangladesh’s central bank SWIFT terminals.

But as recent events remind us, even some of the most mature teams in the industry are fallible. There are too many attack vectors and our adversaries just keep getting better. We need an architecture that keeps customer money safe, even if our deployed servers or development machines are accessed by our adversaries.

In this article, I outline our threat model, how our security boundary works, and why we’ve chosen to build a Zero Trust Architecture (ZTA).

ZTA is the standard for environments where security is existential, such as the U.S. federal government and Department of Defense applications. For more reading on ZTA guidelines, see the NIST guidelines.

We assume our adversaries are persistent geniuses

Our adversaries are well resourced and excellent at their craft. They can spend months studying an organization and building relationships with its employees before attempting to move any money. We have to assume they will eventually find a way past protections that depend on someone recognizing the attack.

I fundamentally believe that a system that relies entirely on human vigilance, especially when the stakes are people’s livelihoods, is a flawed and increasingly irresponsible design. A dedicated deployment machine can be carefully protected and still become compromised. We need an answer for what happens after that.

So we start by assuming the attacker already has access. They can deploy a malicious version of our application and use every credential available to our server. We then work through what privileges that gives them and ensure that it doesn’t include the exfiltration of money. For example, if our server checks that a payment goes to the right recipient, an attacker who can deploy a new version of that server can change/remove that check. The restriction has to be enforced somewhere the compromised backend cannot change.

We think about access to Ground in terms of security boundaries, with different levels of access and power.

Anybody on the internet can access our public interfaces. Ground employees can access our code and deploy new versions of it. A separate security boundary protects our server credentials: the actual secrets and security credentials used by our deployed server. Finally, our hardware security keys authorize the privileged actions that can upgrade our onchain infrastructure and affect the routing of funds.

At each boundary, we ask: if an attacker gets this far, what can they do, and what still stops them?

Our customers’ signing keys are absent from this diagram as Ground has no access to them, so compromising our infrastructure doesn’t give an attacker those keys.

Operating within that boundary

Ground’s software puts customer money to work across onchain lending markets and tokenized funds. We need to deploy into those funds, request redemptions, and collect proceeds when they become available. Some of these operations take multiple transactions and finish hours or days after they begin. Asking the customer to sign every step would make that automation difficult to use.

Customers send stablecoins to their deposit addresses, configure their allocations and risk rules, and our infrastructure handles the deposits, rebalances, and redemptions automatically from there. So we need to give our server enough authority to execute client transactions while restricting where it can send the money.

We use Turnkey’s policy engine to define that authority. In our customer-signing configuration, the customer holds root authority in Turnkey. Ground gives up that authority and keeps permission to perform specific operations. Sending money to an outside account requires the customer’s approval.

What Ground can sign

Each customer organization has its own Turnkey suborg, containing its wallet accounts and signing policies. Turnkey enforces those policies outside our application server. An attacker controlling that server still has to pass Turnkey’s checks to get a transaction signed.

Ground’s operational signing permissions direct transactions through a designated contract called the MasterRouter.

Token approvals are restricted too. Ground can approve the router to spend tokens, while approvals to arbitrary spenders are denied. Otherwise, an attacker could avoid a transfer restriction by approving their own contract to pull the money.

What those transactions can do

Consider a customer depositing USDC into an investment vault.

The transaction calls the MasterRouter with the requested operation and an adapter identifier. An adapter is a contract containing the instructions for interacting with a particular lending market or tokenized fund.

The router looks up that identifier in the AdapterRegistry, which records the permitted adapter contracts and the operations each supports. It checks that the adapter is enabled and supports the requested operation before calling it. The backend cannot substitute an arbitrary contract address as the investment destination.

For example, in our standard ERC-4626 vault route, the contract fixes who receives the shares: the wallet making the deposit. The adapter deposits the USDC and returns the shares to that wallet. Even a compromised backend cannot substitute an attacker’s address.

When those shares are redeemed, the adapter sends the underlying assets back to the same portfolio wallet.

Map your own security boundaries

We’ve open-sourced Security Boundary Mapping so you can investigate what someone could do with your own production access. Give it your repositories and read-only access to your deployment tools. It works through the credentials, permissions, and connections between services to map what an attacker could reach.

Use it to find where one stolen credential could give an attacker access to customer money, private data, or control of another service. You can then remove unnecessary permissions and identify where you need a protection the compromised service cannot override.

If you are a team building onchain finance, we would be happy to share learnings to help you build your defense pipeline, and make introductions to the security researchers at Quantstamp.