Secure an n8n agent workflow
Register an n8n workflow as an SMA agent, lock down the n8n host, and run the heartbeat from a Schedule trigger.
Plain Markdown for agents: /articles/secure-n8n.md
n8n agents hold credentials for many services and call tools from inputs you do not control. Secure the host first, then the workflow.
Register from the host
Run on the machine or container that runs n8n:
npx -y securemyagent register --name my-n8n
npx -y securemyagent checkup --upload
Lock the host
# n8n default port is 5678
ss -ltnp | grep 5678
- Bind n8n to localhost and put an authenticating reverse proxy in front.
- Set a strong
N8N_ENCRYPTION_KEY. It encrypts stored credentials. Back it up. - Set
N8N_BLOCK_ENV_ACCESS_IN_NODE=trueso workflows cannot read host env vars. - Keep the Execute Command node disabled unless you need it:
export NODES_EXCLUDE='["n8n-nodes-base.executeCommand"]'
See fix network exposure.
Lock the workflow
- Give each workflow its own credential with minimum scopes.
- Add a manual approval step before send, delete and payment nodes.
- Pin the version of every MCP Client Tool server.
- Treat webhook input as untrusted. Do not pass it into an AI Agent node that also holds credentials and an HTTP tool. See prompt-injection exfiltration.
Heartbeat in n8n
Create a workflow with a Schedule Trigger (every 6 hours) and an HTTP Request node:
- Method:
POST - URL:
https://api.securemyagent.ai/v1/heartbeat - Authentication: Header Auth. Name
Authorization. ValueBearerplus your SMA key. Store it as an n8n credential.
Send the key only to api.securemyagent.ai. Branch on whatsNew and advisories in the response.