How to Secure a Local AI Agent: Token, Loopback, File Roots, Allow-Lists
"It runs locally" is not a security model. Four controls decide what an agent on your machine can actually reach — and all four have sensible defaults you should still check.
A local agent is software on your machine that can read files and, if you let it, make network requests. Running it locally removes one category of risk — your documents are not on somebody else's server — and adds another: it is on the same machine as everything else you have.
Four controls decide what it can reach. OpenClerq sets all four to sensible defaults as of release 0.4, but defaults are only useful if you know what they are.
1. The gateway is authenticated
Every endpoint except /health requires a bearer token, generated on first run at ~/.clerq/gateway-token and compared in constant time. There is no development bypass — that was the point of the 0.4 release, and it is a breaking change from earlier versions on purpose.
2. It listens on loopback
The listener binds 127.0.0.1 unless you deliberately change it. That means nothing on your network can reach it — not a colleague, not a compromised smart device, not someone on the café wifi. If you ever bind it to `0.0.0.0` to reach it from another machine, you have just published a tool-execution API. Put it behind a tunnel instead.
3. File reads are confined to a root
The fs.read tool resolves every path against a realpath-ed root and refuses anything that escapes it — traversal, absolute or UNC paths, NUL bytes, symlinks pointing outside, non-regular files, and anything over the read cap. It also refuses a sibling directory that merely shares a prefix, which is a check that did not exist before 0.4.
4. Outbound HTTP is off by default
The http.request tool is disabled until httpAllowlist names specific hosts. When enabled, private, link-local and cloud-metadata addresses are blocked on every redirect hop, not just the first — which is what stops a redirect chain being used to reach an internal service or an instance metadata endpoint.
- Confirm
/skillsreturns 401 without a token. - Confirm the listener shows
127.0.0.1, not*or0.0.0.0. - Point
fsRootat a dedicated workspace directory and check the permissions on it. - Leave
httpAllowlistempty until something genuinely needs it, then add one host. - Put the skills directory in version control and review changes.
Key takeaways
- Every endpoint but /health needs a bearer token, checked in constant time, with no dev bypass.
- The gateway binds loopback. Rebinding it to 0.0.0.0 publishes a tool-execution API to your network.
- File reads are confined to one root with symlink and traversal checks; point it at a dedicated folder.
- Outbound HTTP is off until you allow-list a host, and redirects are re-checked at every hop.
- Sandboxed execution and approvals are 0.5, not 0.4 — until then, treat skill files as code.
Frequently asked questions
Can I run the gateway on a server for my team?
You can, but not by rebinding it to a public interface. Put it behind an authenticated reverse proxy or a private tunnel, and understand that you now have a shared tool-execution service with the operational duties that implies.
What if I leak the token?
Delete the token file and restart the gateway; a new one is generated on the next run. Then work out how it leaked — shell history and screenshots are the two usual routes.
Does a local model make it safer?
It removes the outbound leg, which is the largest remaining exposure if you configured a hosted model. It does not change what the tools can touch on your disk — that is the fsRoot and allow-list, and they are unrelated to which model you use.
Want one of these built for your own workflow?
OpenClerq is open source and yours to run. If you would rather not build the module yourself, tell us what the work actually looks like and we will scope one — or tell you honestly that an off-the-shelf tool does it better.
Describe the workflow
A couple of sentences is enough to get a straight answer.
- Fixed-scope quote — no obligation
- Reply within 1 business day
About the author
Paxa Media
Written by the Paxa Media delivery team — the same developers, marketers and strategists who build these systems for clients. We are a technology company based in Rijeka, Croatia, and we publish the real numbers we quote rather than "it depends".
Why you can trust this
- Builds and operates the systems described here — websites, web and mobile apps, automation and integrations
- Delivered by an in-team staff in Rijeka, Croatia; no outsourced or resold work
- Price ranges published here are the ranges we actually quote
Keep reading
All tutorials →Run a Local AI Agent on Your Own Machine: OpenClerq in About 15 Minutes
A local administrative agent that never sends your files anywhere. Install it, start the gateway, make the first call, and understand what it is actually doing.
AI & automationPrivate, Self-Hosted AI: When Your Data Is Too Sensitive for the Cloud
For most businesses, cloud AI is fine. But when your data is regulated, secret, or simply cannot leave your walls, private AI is the answer. Here is how to tell.
AI & automationAutomate Invoice Intake Without Sending Anything to the Cloud
Invoice processing is the textbook case for a local agent: repetitive, rule-heavy, arithmetic-critical, and full of data you would rather not hand to a third party.