Oct 27, 202610 min read

The key is secure. What can the bot make it sign?

A compromised bot can request harmful signatures while the private key stays securely stored. The signer and contract determine what those requests can do.

JohnnyTimeFounder, Ginger Security

Suppose a trading firm’s bot needs to sign transactions. The private key lives in a secure signing service, and the bot has permission to request signatures. The key never appears in the bot’s configuration file.

Then someone compromises the bot process.

The attacker may never see the private key. They can still use the bot’s access to ask for signatures. If the signer accepts their requests, those signatures can move money or operate contracts just as effectively as requests from the legitimate bot.

I’d review three separate signers: one for treasury transactions, one for price updates and one that can pause a trading contract. The same bot compromise has different consequences for each.

Start before the signing request

The bot’s code builds transactions and sends them to a signing service. The service holds the key, checks requests against its policy and returns a signature for an allowed request. A separate broadcaster sends the signed transaction to the chain.

If an attacker controls the running process, they can change the requests it makes and may be able to use its credentials until those credentials are revoked or expire. They may also read data available to the process, interfere with the price inputs or stop the bot altogether.

I would start with the people and systems that can change the bot: repository maintainers, deployment approvers, CI credentials, container registry access and anyone who can change runtime configuration or connect to the host. A carefully reviewed repository won’t help if someone can replace the production image or alter the running process without the same controls.

For this example, I want protected code review, a controlled deployment identity, an approved image digest and recorded configuration changes. I would verify those against repository and deployment settings, logs and the image actually running. Then I’d try a safe unauthorized deployment in a test environment. A written instruction saying “only approved code runs” remains a procedure until the deployment path enforces it.

What does the signer actually see?

The signer is a separate boundary only if the compromised bot cannot change its policy or bypass it. If the bot can call the underlying key service directly, or ask another service to sign arbitrary data with the same key, the policy in front of it may not help.

I’d map every identity that can use the key: application credentials, service accounts, administrative users, backup integrations and emergency access. I’d check who can change those permissions and the signer policy. The key service should accept signing requests only through the intended policy enforcement path, and policy changes should require separate authorization. I’d test the direct and alternate routes too.

A key management service can protect a private key and control which identity may call a signing API, yet the operation it signs may be a digest with no readable transaction context. The team needs a trusted policy layer that receives and independently decodes the full request, checks its meaning, and signs the exact bytes it checked. If the signer only sees an opaque hash, it cannot itself establish the recipient, amount or contract function. AWS KMS documentation describes how an asymmetric private key is used through the service. It does not imply that KMS understands a team’s DeFi transaction policy.

I’d verify the complete chain, including transaction types and message-signing methods. Typed messages, permits and contract-specific signatures can authorize actions without looking like an ordinary token transfer. The signer needs to reject unsupported formats and bind approvals to the exact chain, account, destination and payload. Test malformed and undecodable requests as well as normal ones.

A treasury signer can put money at risk

Suppose the treasury gives the bot a signing role to trade up to 1,000 USDC at a time through an approved router. The WETH bought by the swap must return to the treasury’s trading wallet. The wallet holds 50,000 USDC.

If the compromised bot can request arbitrary signatures from an unrestricted treasury key, it may be able to transfer assets out, grant token allowances or sign other authorizations. If it is limited to the router but the output recipient is left open, it can pay for a swap and send the WETH elsewhere. That’s the gap we walked through in the wallet-policy article.

For the example, I’d have the independent signer enforce the chain, wallet, router, single-swap method, input and output assets, maximum input and destination wallet. It should bind the approved minimum output and deadline to the exact request. An independent quote or price check is needed if the bot itself supplies the minimum: a compromised bot could otherwise set a near-zero minimum and accept a terrible trade. The contract-side wallet can enforce corresponding limits where its design supports them. Inspect the actual implementation and all modules and execution paths.

For example, a 5,000 USDC daily budget can limit approved exposure if every signing route shares that accounting. I’d check the wallet’s existing allowances, separately authorize a bounded approval to the router, and test signed permit paths. A spending cap does not recover funds already moved or constrain an unreviewed route.

I’d verify the active policy and on-chain wallet configuration, then submit safe positive and negative cases through the actual supported test path: wrong receiver, wrong router, weak minimum output, oversized approval, repeated requests and two simultaneous requests competing for the remaining budget. Record the decision and policy version.

A price signer can change other people’s decisions

Now consider a separate key whose job is to post a price to a protocol’s oracle contract. It holds no treasury role and cannot directly transfer the treasury’s USDC in this example. A compromised bot may still post a bad price if the signer and contract accept it.

Imagine a lending contract uses the posted price to value collateral. An inflated price could let a borrower take too much credit. An understated price could trigger liquidations. The loss depends on the protocol’s positions, timing and safeguards. Even without a successful exploit, an attacker can stop updates and disrupt systems that rely on fresh data.

I’d restrict this signer to the oracle contract and its specific update function, including the intended asset and network. The signer should check a trustworthy, independently obtained reference, units and decimals, freshness, and a defined deviation bound before signing. The contract should independently enforce the authorized reporter, positive values, timestamp or sequence rules and its own bounds where feasible. Consumers also need freshness checks and a defined response to stale or suspect prices. An attacker may stay within a per-update deviation limit while moving the price gradually. Compare against independent references and cumulative movement, and account for real market gaps.

For a Chainlink feed used as a reference, I’d identify the exact feed and check its latestRoundData() answer and updatedAt, along with the application’s freshness and validity requirements. Chainlink documents those fields in its data feed API reference. A stale or unavailable reference should trigger the documented fail-safe, rather than silently accepting whatever the bot proposes.

I’d test a valid update, wrong asset, stale input, replayed sequence, extreme price and a series of individually small moves. I’d also test what the consumer does when prices stop arriving. I’d compare these results with the active signer policy and the limits configured onchain. A rejected signing request doesn’t establish how the consuming contract handles a stale price.

A pause-only signer can still stop the business

The third key can call pause() on a trading contract. In our example it has no permission to unpause, upgrade the contract, transfer funds or grant roles. A different, separately controlled authority can resume operations after investigation.

A compromised bot using this key could still pause trading at the worst moment. Orders may fail, positions may remain open and the team may be unable to rebalance. What happens to withdrawals, cancellations and liquidations depends on which functions the contract actually pauses. I would inspect and test each affected function rather than infer its behavior from the name pause.

I’d confirm the pause role on the live contract, inspect who can grant it, and test that the key cannot unpause, change roles or call other privileged functions. For a contract using OpenZeppelin’s role controls, hasRole and the role’s admin relationship are relevant starting points. The access-control documentation explains how role administration works. I’d verify those checks in the active implementation and current state.

Removing access takes more than one switch

If we suspect the bot is compromised, I’d want a rehearsed response with named owners and a backup. The team should stop the process and isolate the affected workload, disable its signing credentials and any alternate paths, and preserve logs and request records for investigation. Check that new requests are rejected. Credential revocation can take time to propagate, and other active sessions or identities may still work.

Then address the on-chain permission. An independent authority may need to remove the old signer from the wallet or revoke its oracle or pause role, and verify the resulting state on-chain. The required administrator, multisig threshold, timelock and gas need to be known beforehand. If revocation is delayed, the old role can remain usable until the change takes effect. If the bot can change its own access or the admin is compromised too, the recovery plan needs a different trusted route.

Depending on the system, the team may need to invalidate nonces, cancel pending operations, revoke allowances or change the contract’s authorized signer. Check the actual design and race conditions. A cancellation may lose the race to an existing transaction. Record confirmed transactions, remaining balances and active permissions after the response.

Recovery has to restore the service safely. Build from a trusted version, investigate how access was obtained, issue new credentials and a new signer where appropriate, grant only the required role, and test the new path before resuming. For an oracle, confirm how stale prices and dependent positions are handled while updates are stopped. For a pause role, make sure the independent team can still respond if the replacement isn’t ready.

Choosing the signing controls

I’d start with the request the compromised bot can make. A treasury transaction needs different checks from a price report or a pause call. These documented controls operate at different points in that request’s path.

Tool or system Where it helps What I would verify
AWS KMS Controlling access to a signing key KMS Sign accepts messages or digests. Review kms:Sign authority and enforce decoded recipient, price or function rules in a trusted layer before signing.
Fireblocks Policies Transaction approval within a managed workspace Confirm the supported operation and policy fields. Demonstrate the treasury restrictions and check whether the bot can change its own policy.
Safe Contract-account authorization and optional custom controls Inspect owner thresholds, guards and module logic. Verify that the intended bot route enforces its budget and that the recovery route stays available.

For the price poster, I’d keep the reference-price and freshness checks explicit in the signing path and consuming contracts. I’d ask any provider to demonstrate support for that exact message format before treating a general transaction policy as sufficient.

The signer owner must maintain permissions and test revocation with the contract engineer. I’d record the last successful rejection and recovery drill beside each key. No provider signing integration was exercised for this comparison.

What I’d want to see before trusting it

For each restriction, I’d check the signer policy, the key-service access configuration, the deployed contract and its role state, plus a recorded test that tries to cross the boundary.

I’d keep the treasury, price-reporting and pause roles on separate keys, with a recovery plan for each.

If you’d like help reviewing a trading bot, oracle or signer setup, we can discuss it through my ongoing security advisory service.