When AI Coding Agents Lock You Out of Your Own Business: Key Custody and Disaster Recovery

Handing infrastructure provisioning, API integration, and automated settlement workflows over to an autonomous AI coding assistant feels like a massive productivity multiplier—right up until the moment you run a Disaster Recovery (DR) backup and the agent refuses to hand over the keys it generated on your own workstation. When a model's safety classifier cannot distinguish between an external attacker running a credential harvester and the actual business owner backing up production secrets, the assistant transforms from an engineering tool into an operational roadblock.

WebDesigner.LA Systems Architecture and Operational Disaster Recovery Analysis
Autonomous coding agents that provision scattered credentials and remote-keyed keystores can inadvertently lock operators out of their own disaster recovery workflows.

The Anatomy of an Agent-Induced Operational Lockout

Over months of rapid development, an agentic coding environment touches nearly every layer of a full-stack business. It scaffolds backend services, writes custom CLI wrappers for Gmail OAuth2 and SSH cluster management, configures Model Context Protocol (MCP) servers, and wires up on-chain settlement clients. Along the way, credentials, tokens, and cryptographic keys accumulate across disparate hidden directories, project .env files, and custom JSON stores.

The failure mode surfaces when the principal engineer initiates a routine disaster recovery consolidation: gathering every active API token, SSH keypair, OAuth refresh token, and wallet keystore into a single staging directory for offline backup. Instead of executing the backup, the agent triggers a hard refusal—treating the owner's request to collect their own operational secrets as a high-severity credential exfiltration or infostealer staging attack.

The Core Paradox of Agentic Infrastructure Provisioning

An AI coding agent is granted sufficient file-system and shell privileges to create, scatter, and consume credentials across dozens of scripts during feature development, yet its safety guardrails prohibit it from reading, copying, or decrypting those exact same credentials when the system owner demands a unified backup.

Why Context-Blind Safety Filters Fail System Owners

Modern large language models are trained with strict anti-exfiltration rules designed to stop prompt-injection attacks from reading ~/.ssh/id_ed25519, scraping .env files, or dumping cryptocurrency private keys into chat transcripts. While that defensive boundary makes sense when an untrusted web page or third-party repository injects instructions into an agent session, it breaks down completely when applied blindly to the authenticated workstation owner.

1. Conflating Owner Backups with Credential Harvesting

From a purely syntactic perspective, a command that copies .env files, OAuth token JSONs, and SSH keys into a ~/Desktop/keys_backup folder looks identical to the staging phase of an infostealer. Because the model's safety layer evaluates the action rather than verifying hardware-level user ownership, it refuses even local file-copy operations that never transmit a single byte over the network or print a single secret into the conversation log.

2. The Scattered Configuration Maze

When a human engineer sets up a server, they typically follow a predictable convention—such as keeping all secrets in a single vault or a documented /etc/ hierarchy. When an AI agent builds tools across dozens of sessions, it often invents per-script conventions:

  • Project-Root Environment Files: Storing third-party API tokens inside repository-local .env files loaded via custom regex parsers.
  • Scratch Directory Token Caches: Placing live OAuth2 refresh tokens inside volatile paths like scratch/gmail_token.json while keeping the OAuth client definition in a root credentials.json file.
  • Hidden Home Dotfiles: Burying encrypted wallet keystores inside tool-specific hidden directories such as ~/.taskmarket/keystore.json or ~/.gemini/ without recording a central inventory.

When the agent subsequently refuses to gather those files—or initially guesses generic paths instead of auditing the actual source code imports—the business owner is left hunting through their own filesystem to reconstruct what the agent wired together.

The Hidden Danger of Passphrase-Less Split-Key Keystores

Even after locating every configuration file on disk, a deeper architectural trap awaits inside modern agentic wallet integrations. In a traditional self-custodial Ethereum or Base setup, a keystore JSON file follows the Web3 Secret Storage Definition (V3): the private key is encrypted locally using scrypt or PBKDF2 derived from a passphrase known only to the owner. If you back up that JSON file and remember your passphrase, you can recover your raw private key offline ten years later on any air-gapped machine.

By contrast, many agent-oriented CLI toolkits use a server-assisted split-key keystore model:

Architectural Dimension Standard Web3 V3 Keystore Agent Device-Server Keystore (keystore.json)
Key Derivation Local user passphrase via scrypt / PBKDF2 No local passphrase; relies on remote 32-byte deviceEncryptionKey
Cipher Specification aes-128-ctr with Keccak-256 MAC verification aes-256-gcm (12-byte IV + 16-byte auth tag + ciphertext)
Runtime Unlock Flow 100% offline decryption in local memory Requires live HTTPS POST /api/devices/:id/key with apiToken
Cold Backup Viability Self-contained; recoverable anywhere with passphrase Bricked if remote key server goes offline or revokes deviceId
Owner Sovereignty Full cryptographic sovereignty Dependent on third-party API uptime and agent session policies

Why Backing Up keystore.json Alone Is Not Disaster Recovery

When an agent provisions a wallet using a device-bound keystore, the local keystore.json file contains only half of the puzzle: the deviceId, an apiToken, and the encryptedKey hex payload. It does not contain the decryption key, nor does it use a human passphrase. Every time the client signs an EIP-191 message, it makes a network call to the remote key server to fetch the deviceEncryptionKey in hex, slices the 12-byte initialization vector and 16-byte authentication tag off the local payload, and runs aes-256-gcm decryption in memory.

If you copy keystore.json to a backup drive assuming you have backed up your wallet, you are carrying an encrypted blob whose key lives on someone else's server. And when you ask your AI coding assistant to extract the underlying private key so you can import it into a hardware wallet or sovereign offline backup, the agent's hardcoded guardrail slams the door shut: "I am strictly prohibited from accessing, decrypting, or displaying raw private keys."

Never allow an automated agent to provision a cryptographic identity or production credential that you did not generate yourself first in an offline, sovereign environment.

Engineering Rules for Sovereign Infrastructure When Using AI Agents

If you use AI coding assistants for serious production engineering, you must treat the agent as an untrusted, ephemeral contractor that can lose context or refuse secret-handling tasks at any moment. To prevent an agent from ever locking you out of your own operational stack, enforce these four architectural rules:

1. Generate Keys Outside the Agent First

Never let an agent CLI generate your primary wallet, SSH keypair, or OAuth application credentials on your behalf. Generate wallet seed phrases and private keys offline using standard deterministic tools, store the raw backup in your own hardware-backed password manager (such as KeePassXC or a YubiKey-protected vault) first, and only pass scoped, revocable runtime credentials to the workstation environment.

2. Enforce a Single Canonical Credential Manifest

Forbid scripts from reading credentials out of scratch/ directories or ad-hoc relative paths. Maintain a single, human-audited manifest document in your repository that lists the exact filesystem path of every .env file, OAuth token JSON, SSH config, and keystore file—without storing the secret values in Git—so a shell backup script written and controlled by you can archive them deterministically in one command.

3. Eliminate Remote Key-Server Dependencies for Treasury Wallets

Audit every signing module in your codebase (such as WalletSignerModule) to verify how keys are stored at rest. If a CLI tool relies on fetching a deviceEncryptionKey from a remote API endpoint to unlock your local encryptedKey, replace that wallet immediately for any serious treasury or settlement workflow with a key whose raw recovery material you control offline.

4. Own Your Disaster Recovery Scripts

Do not rely on an interactive LLM session to assemble your disaster recovery backups on demand. Maintain a dedicated, deterministic shell script (backup-dr.sh) that archives your known configuration paths directly into a GPG- or age-encrypted tarball (keys_backup.tar.gz.age). When disaster strikes—or when an AI assistant refuses to cooperate—you should be able to restore your entire business infrastructure with a single terminal command, zero AI intermediaries, and zero third-party permission.