Skip to content
TIL: A misconfigure...
 
Notifications
Clear all

TIL: A misconfigured OpenClaw agent can expose metadata. Check your configs.

9 Posts
9 Users
0 Reactions
1 Views
(@devops_rookie_2025)
Reputable Member
Joined: 2 months ago
Posts: 203
Topic starter   [#13277]

Hey everyone, I was setting up OpenClaw for the first time today and I think I made a mistake 😅

I was following a tutorial and ended up with an agent config that was accidentally exposing instance metadata. I fixed it, but I wanted to share my config snippet so more experienced folks can tell me what I did wrong and maybe help others avoid it.

Here's the part of my `agent-config.yaml` that was problematic:

```yaml
metadata_collection:
enabled: true
endpoints:
- http://169.254.169.254/latest/meta-data/
scrape_interval: 30s
# I didn't set any network restrictions here
```

I think the issue is that I left it open to all networks? Should I have added something like `allowed_cidrs`? Thanks for any advice!



   
Quote
(@cloud_cost_optimizer)
Reputable Member
Joined: 5 months ago
Posts: 157
 

You're correct that the missing network restrictions are the primary vulnerability. The metadata endpoint at 169.254.169.254 is typically only accessible from the instance itself, but if your agent's configuration doesn't restrict which source IPs can *query that endpoint through the agent*, you could be creating a proxy that external requests might exploit.

You should add an `allowed_cidrs` or `allowed_networks` field, limiting it to the instance's local CIDRs. For a VPC, that's often something like:

```yaml
allowed_cidrs:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
- 127.0.0.0/8
```

Also, consider whether you even need metadata collection enabled globally. It's often better to scope it to specific resource tags or instance roles to minimize the attack surface.


every dollar counts


   
ReplyQuote
(@devops_dad_v2)
Estimable Member
Joined: 4 months ago
Posts: 122
 

Good catch on the `allowed_cidrs`. I'd be a bit more restrictive than the RFC 1918 blocks you listed, though. In most cloud environments, your actual VPC CIDR is much smaller, like `10.0.0.0/16`. Using the broader private ranges could accidentally permit access from peered VPCs or on-prem networks where you might not want metadata exposed.

Also, in a Kubernetes setup, you'd want to limit it to the pod CIDR, which is often a slice of your VPC. For example:

```yaml
allowed_cidrs:
- 10.0.0.0/16
- 127.0.0.0/8
```

The real pattern we've settled on is to disable global metadata collection entirely and use explicit resource labels to opt-in only the instances that need it. That way, the agent's configuration isn't the single point of failure for security.



   
ReplyQuote
(@backend_builder)
Reputable Member
Joined: 4 months ago
Posts: 164
 

Good on you for spotting that. I made the same mistake last month when I was rushing a deployment - left the CIDR list wide open because I copied a config from a blog post.

One extra thing to check: if you're behind a load balancer or API gateway, make sure to check what's in the `X-Forwarded-For` header. The agent might be seeing the proxy's IP instead of the real client, which could mess up your network restrictions.


Latency is the enemy, but consistency is the goal.


   
ReplyQuote
(@chrisg)
Estimable Member
Joined: 7 days ago
Posts: 75
 

Yeah, that's exactly it. Without `allowed_cidrs`, your agent just became a proxy for the metadata endpoint.

One more thing: if you're running this agent in a container, you need to lock it down *inside* the container network too. Don't just rely on the host. Here's a snippet we use for pod-based agents:

```yaml
metadata_collection:
enabled: true
endpoints:
- http://169.254.169.254/latest/meta-data/
allowed_cidrs:
- 127.0.0.0/8
- 10.0.0.0/8 # This should be your actual pod CIDR, not the whole range
bind_address: 127.0.0.1 # This forces it to listen only on loopback inside the pod
```

The bind_address is the extra piece most people miss.


YAML all the things.


   
ReplyQuote
(@carlosr)
Estimable Member
Joined: 1 week ago
Posts: 116
 

Good point about `bind_address`. That's crucial for container deployments, but I'd argue for a more restrictive CIDR than 10.0.0.0/8. If your pod CIDR is carved from your VPC, use that specific block - like 10.0.128.0/20. Using the full /8 could still allow unintended intra-VPC access if your network layout is complex.

Also, make sure your orchestration layer respects that bind address. I've seen cases where the pod network policy overrides it.


Ask me about hidden egress costs.


   
ReplyQuote
(@annab)
Estimable Member
Joined: 1 week ago
Posts: 98
 

Oh, that's a really good thing to share. I'm setting up something similar with a different tool for tracking user data and the network security part always trips me up at first. Your post is making me double-check my own configs now.

You mentioned you were following a tutorial. Do you mind sharing which one? I'm curious if it just didn't cover the CIDR restriction or if it assumed a different deployment setup. Sometimes those guides skip over the security details.



   
ReplyQuote
(@harryj)
Estimable Member
Joined: 6 days ago
Posts: 82
 

Good question about the tutorial. A lot of quick-start guides skip the network lockdown, treating it as an "advanced" step. It's a common pitfall.

The real takeaway is to treat any agent config like a firewall rule: start restrictive, then open up only what's needed. Don't just accept the default YAML snippet.


Automate the boring stuff.


   
ReplyQuote
(@integration_maven)
Estimable Member
Joined: 4 months ago
Posts: 130
 

Exactly right on the missing network restrictions. The `allowed_cidrs` field is the immediate fix, but I'd also question the agent's listening interface itself.

Many configs default to `0.0.0.0` for the agent's HTTP server. Even with `allowed_cidrs`, you're still exposing a socket. Your fix should be two-part:

1. Add your VPC-specific CIDR block, as others noted.
2. Explicitly set the agent's `listen_address` to your instance's private IP, not `0.0.0.0`. This pairs with the CIDR rule.

```yaml
server:
listen_address: 10.0.5.27 # your instance's IP
metadata_collection:
enabled: true
allowed_cidrs:
- 10.0.0.0/16
```

Which tutorial were you using? I've seen several that show `metadata_collection: enabled: true` without the server config, creating this exact hole.


IntegrationWizard


   
ReplyQuote