AI agent adoption is booming. Tools like OpenClaw let companies build assistants that carry out real tasks —send emails, manage CRMs, automate processes— without human intervention. But with that capability comes a responsibility many are ignoring: the security of the infrastructure where these agents run.
You deployed your OpenClaw instance. You connected your tools. Your agents are working. Everything runs. But how secure is the infrastructure that supports them, really?
When an AI agent has access to your email, your CRM, third-party APIs and your customers' credentials, the attack surface isn't just technical —it's a business risk. A breach doesn't just expose data: it exposes the ability to act on behalf of your company.
This article comes from a real security audit we ran on our own AI agent orchestration platform. We found 14 findings. We fixed them all. Now we share the lessons so anyone deploying OpenClaw, LangChain, CrewAI, AutoGPT or any autonomous agent system can review their own infrastructure.
1. Plaintext secrets: your AI agents' credentials exposed
The problem
Your OpenClaw agent needs an OpenAI API key to think, a Gmail token to send emails, and credentials for your ERP to query data. Where are those secrets?
If the answer is "in a .env file on the server", you have a problem. That file holds your AI agent's ability to act across every connected system. If someone gets to that file —through a vulnerability, a careless backup, a compromised SSH access— they have the keys to everything: they can read emails, modify customer data, and make API calls on your behalf.
And worse: it's probably the same .env you use in development.
Why this is especially serious with AI agents
A traditional web server with compromised secrets exposes data. An AI agent with compromised secrets exposes the ability to act. Anyone holding your OpenClaw agent's token can send emails to your customers, modify records in your CRM, or run automated actions that look legitimate.
What you should do
Separate secrets from code and the server:
-
Use a cloud secrets service. AWS SSM Parameter Store is free and unlimited. Google Secret Manager and Azure Key Vault are equivalents. They store secrets encrypted and deliver them only to authorized services.
-
Generate the
.envdynamically at startup. If your stack needs an environment variables file (Docker Compose, for example), write a script that pulls the values from the secrets service and generates the file at deploy time. The file should never exist in your repository. -
Never duplicate secrets. If the same API key lives in a
.env, in a secrets service and in your CI/CD variables, you have three attack surfaces instead of one. A single source of truth. -
Rotate your agents' secrets periodically. OpenAI, Anthropic and other LLM provider API keys can be rotated without downtime. Do it at least every 90 days.
Principle: a secret should live in exactly one secure place. If your AI agent has access to 5 services, that's 5 secrets an attacker can use to act as your company.
2. "Temporary" infrastructure permissions still running in production
The problem
When you set up cloud infrastructure for your AI agent platform, there's always a moment when something doesn't work. A permission is missing. You don't know which one. You put "Action": "*" on "Resource": "*".
It works.
You tell yourself: "I'll tighten it tomorrow". But tomorrow there's an agent bug to fix, and the following week a client needs a new integration. That permission stays. Your agent server now has administrator permissions over your entire cloud account.
Why this is especially serious with autonomous agents
A web server with excessive permissions is dangerous. A server running autonomous agents with excessive permissions is a nightmare: if the agent has a prompt injection vulnerability or a compromised library, the attacker inherits the permissions of your entire AWS/GCP/Azure account.
What you should do
Apply real least privilege:
-
List exactly which cloud services your agent platform uses. If your OpenClaw uses EC2, EFS and S3, those are the only services that need permissions. Nothing else.
-
Restrict by resource. Not "can write to any S3 bucket", but "can write only to the
my-project-statesbucket". -
Use your provider's access analyzers. AWS IAM Access Analyzer and GCP Policy Analyzer tell you which permissions you actually used. Start broad, monitor for 30 days, and trim what went unused.
-
Review when you change the architecture. Did you add a new tool to your agents? Check whether it needs new cloud permissions. Did you remove an integration? Remove the corresponding permissions.
Principle: if your agent server is compromised, the server's permissions become the attacker's permissions.
*/*means they can delete your entire account.
3. SSH open to the world: the door bots find in seconds
The problem
Port 22 open to 0.0.0.0/0 is the most universal security finding on cloud servers. If you have a server running OpenClaw or any AI agent platform, bots are scanning that port right now.
Not tomorrow. Now.
What you should do
The best solution is to have no open SSH port:
-
AWS SSM Session Manager, GCP OS Login or Azure Bastion. All three providers offer remote access without open ports. The connection goes through an authenticated tunnel using your cloud credentials. There's no attack surface for bots.
-
If you need SSH, restrict it by IP. Allow connections only from your fixed IP or your VPN. Never from
0.0.0.0/0. -
Use SSH keys, never passwords. And rotate the keys at least every 6 months.
Principle: every open port is a door. Every closed door is an attack that cannot happen.
4. Agent API without rate limiting: an invitation to abuse
The problem
Your orchestration API manages AI agents. It lets you create instances, send tasks and query statuses. What happens when someone sends 10,000 requests per minute?
Without rate limiting, your platform gets saturated, your OpenClaw agents can't process legitimate tasks, and your clients lose service. A 5-line Python script can cause this.
Why it's critical for AI agent platforms
Every request to your agent API can trigger costly actions: LLM calls (which cost money), tool execution, external API queries. Without rate limiting, an attacker can generate massive costs on your OpenAI or Anthropic account within minutes.
What you should do
Implement rate limiting differentiated by operation type:
| Operation type | Suggested limit | Rationale |
|---|---|---|
| Create/destroy agent instances | 5-10/minute | Heavy infrastructure operations |
| Send tasks to agents | 30/minute | Each task can consume LLM tokens |
| Query status | 60/minute | Light reads, permissive for monitoring |
| Health checks | No limit | Internal monitoring |
Tools by stack:
- Python/FastAPI: slowapi
- Node/Express: express-rate-limit
- Nginx: limit_req module
- Cloudflare/AWS WAF: rate limiting rules at the edge
Principle: if your AI agent API has no limits, the attacker sets the limit. And every request that gets through can cost real money in LLM tokens.
5. Unvalidated inputs: when your agent receives malicious instructions through the API
The problem
Your API has an instance_id field of type string. What does it accept? Everything. A UUID, a name, ../../etc/passwd, a 50MB payload, or an injection attempt.
"But I use parameterized queries, so there's no SQL injection." Correct. But your agent API inputs don't only go to the database. They end up in cloud resource names, DNS subdomains, infrastructure tags, Terraform templates and tool configurations. A malicious string in any of those contexts can cause real damage.
Why this is especially relevant for AI agents
On platforms like OpenClaw, inputs can end up as part of prompts, file names, tool configurations or external API parameters. Input validation is your first defense against indirect prompt injection arriving through the API.
What you should do
Validate at the entry point:
- Define explicit patterns. If an instance ID may only be alphanumeric with hyphens:
^[a-z0-9][a-z0-9-]*[a-z0-9]$ - Always limit length.
max_length=63(DNS limit, RFC 1035) is a good default for identifiers. - Validate in the model, not on each endpoint. With Pydantic, Zod or Joi, validation is defined once and applies automatically to every endpoint.
- Don't trust the frontend. Security lives in the backend.
Principle: all external input is hostile until proven otherwise. This applies doubly when that input can end up in an AI agent's context.
6. Unencrypted traffic: your agent credentials traveling in plaintext
The problem
Your agent platform has HTTPS thanks to the CDN. But if someone discovers the server's IP and accesses it directly —bypassing Cloudflare— all traffic travels unencrypted. Including API keys in headers and your agents' responses.
What you should do
Protect in layers:
-
Redirect HTTP to HTTPS. If your server receives an HTTP request, respond with a
301to HTTPS. -
Block direct access to the origin. If it should only receive CDN traffic, create an allowlist of CDN IPs and reject everything else with a
403. -
Add standard security headers:
Strict-Transport-Security— forces HTTPS in the browser foreverX-Content-Type-Options: nosniff— prevents MIME sniffingX-Frame-Options: DENY— prevents clickjackingReferrer-Policy— limits information leaked in referrers
Principle: if your AI agent server accepts HTTP, anyone on the network can see your agents' credentials, prompts and responses.
7. Internal services without a password: when perimeter defense fails
The problem
"Redis doesn't need a password because it's only reachable inside Docker."
That argument is reasonable. Until an attacker manages to run code inside your application —an RCE in a dependency, a template injection, an SSRF. If your app can talk to Redis without a password, so can the attacker.
Why it matters for AI agent platforms
On a platform like OpenClaw, Redis typically stores task queues for the agents. An attacker with access to Redis can inject fake tasks, delete legitimate ones, or extract data from the queues. If your agents act automatically based on what's in the queue, an attacker can control what your agents do.
What you should do
- Redis:
--requirepass+ password in the client. One line on each side. - PostgreSQL/MySQL: strong passwords, even if the database isn't reachable from outside.
- Message brokers (RabbitMQ, Kafka): per-user authentication with permissions per queue/topic.
- On internal SSL: if services run on the same machine (Docker bridge), traffic never leaves the kernel. Internal SSL adds no real security in that scenario.
Principle: perimeter security is necessary but not sufficient. If an attacker is already inside, internal authentication is the only thing preventing lateral movement toward your task queues and your agents' credentials.
8. Containers running as root: the privilege nobody needs
The problem
If your Dockerfile has no USER directive, your AI agent platform runs as root inside the container. Docker isolates processes, but isolation isn't perfect. Container escape vulnerabilities are discovered periodically —and a root process has more capabilities to exploit them.
The solution
# Create unprivileged user
RUN useradd -r -s /bin/false appuser
COPY --chown=appuser:appuser . /app
USER appuser
CMD ["python", "main.py"]
If your OpenClaw agent needs to write to temporary directories, create those directories and assign ownership before switching user. If you need to install system packages, do it before USER.
Principle: your AI agent doesn't need to be root. If it doesn't need the power, don't give it. A non-root container limits the damage if there's an escape.
9. Errors that say too much: giving the attacker intelligence for free
The problem
{"detail": "error: connection to 10.0.1.45:5432 refused (PostgreSQL 16.2)"}
This error just told the attacker your database's internal IP, port and exact version. On an AI agent platform, errors can leak even more sensitive information: agent configuration paths, names of connected tools, or fragments of system prompts.
What you should do
Log the detail internally. Return the minimum to the client:
except Exception as e:
logger.error(f"Database check failed: {e}") # For your logs
return {"status": "error"} # For the client
- Client errors: generic ("error", "unavailable", "invalid request")
- Details: to your internal logs, where you can read them and an attacker cannot
- Never expose: stack traces, internal IPs, software versions, LLM model names, or agent configurations
Principle: every technical detail in an error message is free intelligence for an attacker. And on an AI agent platform, that intelligence can reveal the full architecture of your automations.
Security checklist for AI agent platforms
If you're deploying OpenClaw, LangChain, CrewAI, AutoGPT, or any autonomous agent system, review these 9 points at least once a quarter:
- [ ] Secrets: do your agents' credentials (LLM API keys, service tokens) live in an encrypted secrets service, not in plain files?
- [ ] Cloud permissions: do the IAM roles of your agent servers have only the minimum permissions needed?
- [ ] Ports: are all ports you don't need closed, including SSH?
- [ ] Rate limiting: does your orchestration API have limits per endpoint and per operation type?
- [ ] Input validation: do all your API fields validate pattern, length and type before being processed?
- [ ] HTTPS: do you enforce HTTPS and block direct IP access to the origin?
- [ ] Internal services: do Redis, PostgreSQL and your message brokers have authentication enabled?
- [ ] Containers: does your application run as a non-root user?
- [ ] Errors: do your endpoints return generic messages without internal details?
If the answer to any of these is "no" or "I don't know", you already have your next task.
Deploying AI agents securely shouldn't be your problem
If you got this far and recognized several of these problems, that's completely normal. They aren't the mistakes of careless engineers —they're the natural result of building fast under pressure. Autonomous AI agents like OpenClaw are transformative tools, but the infrastructure beneath them needs the same level of care as the agent itself.
The reality is that security for AI agent platform infrastructure is ongoing work. Every cloud provider changes its APIs, every library publishes security patches, and every new tool integration adds attack surface. For a team focused on building product, keeping up is a full-time job that competes directly with feature development.
There are platforms that abstract all of this away —where you focus on configuring your agents and the infrastructure already comes secured, isolated and monitored. It's the same model that made you stop managing your own email server: someone else did it better, more securely and more cheaply.
At Orquestio we built exactly that: a platform where you deploy your OpenClaw instance and all the infrastructure —encrypted secrets, minimum permissions, isolation between clients, rate limiting, enforced HTTPS, hardened containers— is already solved from the first minute. Every point in this article is something our users never have to think about.
But regardless of whether you use our platform, another one, or manage your own infrastructure: security isn't a feature you add at the end. It's a practice built from the start. And when your AI agents can act on behalf of your company, the consequences of not doing it are far greater.
We hope this article was useful. If you have questions, we're at orquestio.com.