A Linux-first control pattern can stop risky agent actions before they reach the shell or filesystem. You can enforce a policy before AI agent tool execution using open source and Linux security controls.
Imagine a coding agent working inside a Linux project. It can inspect files, run tests, edit source code, install packages, and call network tools. Most of those actions are ordinary. The dangerous moment is the one where a bad instruction, compromised dependency, or poisoned context turns an ordinary task into a command that reads a secret, deletes the wrong directory, or sends data somewhere it should not go.
If the security control only notices the problem after the command has run, the log may be useful for an investigation, but it is too late to prevent the action. A safer design puts a policy decision directly in front of the tool call.
The dangerous gap is before execution
AI agents do not need root access to cause meaningful damage. A developer account can usually modify a repository, read configuration files, run a package manager, invoke Git, and reach the network. An agent that inherits those permissions inherits the same blast radius. The model may be the component deciding what to do, but the shell, filesystem, package manager, browser, and API clients are the components that actually do it.
That distinction matters. Monitoring model output is helpful, but a model can describe one action and a tool adapter can execute another representation. Post-execution telemetry is also helpful, but it records the event after the side effect. The reliable control point is the boundary where a proposed action has been converted into a concrete tool call but has not yet executed.
Put policy at the action boundary
At that boundary, normalise the proposed action into a small, deterministic record. For a shell tool, that can include the executable, arguments, working directory, environment references, and whether the command can reach the network. For a filesystem tool, capture the requested path and operation. For Git, capture whether the action is a read, commit, push, force-push, or history rewrite.
A policy check can then return one of three simple decisions: allow, deny, or require review. The important part is that the decision happens before the tool receives permission to execute.
action = {
"tool": "shell",
"command”: "git push --force origin main”,
"cwd”: "/srv/project”
}
decision = policy.evaluate(action)
if decision == "deny": stop()
if decision == "review": request_approval()
if decision == "allow": execute()
This pattern keeps the security decision outside the model. The agent can propose an action, but it cannot grant itself permission. That separation is the same reason Linux administrators do not treat an application process as the authority for its own access controls.
Use Linux controls as backstops
Pre-execution agent policy should complement Linux security rather than replace it. File permissions, containers, namespaces, seccomp, AppArmor, and SELinux can reduce what a process can do even if the agent-level control misses something. The two layers solve different problems.
Linux controls are strong at enforcing operating system boundaries. Agent-level policy can reason about higher-level intent before those boundaries are reached. It can distinguish a normal ‘git status’ from a force-push, a read from a write, or a package inspection from an installation that may run lifecycle scripts. A useful deployment has both: semantic checks close to the tool call and operating system limits underneath.
Treat tools as capabilities
A practical policy starts by treating every tool as a capability rather than giving an agent a single all-or-nothing trust level. Most agents need far fewer permissions than the human account that launches them.
For example, a coding agent may be allowed to read the project tree, write only inside the current repository, run a known test command, and inspect Git state. It may require review before installing a package, pushing to a remote, or making a network request. It should normally be denied access to SSH keys, cloud credentials, browser profiles, password stores, and unrelated home-directory files unless the task specifically requires them.
This capability model also makes policies easier to audit. Instead of asking whether an agent is ‘trusted’, you can answer concrete questions: which directories may it modify, which commands may it launch, which domains may it contact, and which operations require a human decision?
Keep policy deterministic
Security policy should be predictable. Avoid making the final allow-or-deny decision with another language model. A model can help classify context or explain why a rule fired, but the enforcement decision should come from deterministic rules whenever possible.
Teams can implement those rules directly in application code, in a small configuration format, or with an open policy engine such as Open Policy Agent. What matters is that the same proposed action produces the same decision under the same policy. That makes failures reproducible and lets administrators review changes in version control.
Escalate ambiguous actions
Blocking every mutation makes an agent safe but not very useful. Allowing every mutation creates the opposite problem. The review state gives teams a middle path for actions that are legitimate but unusually risky.
Good review candidates include a force-push, a recursive delete outside the workspace, a command that reads from a credential directory, a package installation with lifecycle scripts, or a network request that carries environment-derived secrets. The goal is not to ask a human about every command. It is to reserve review for the small set of actions where the cost of a mistake is high, or the policy lacks enough context to decide safely.
Test policy like application code
A policy that is not tested will drift. Treat security rules as code and build a small regression suite around the actions your agents actually perform. Each test should describe a proposed action and the decision you expect.
Useful tests include allowing a read inside the repository, denying reads from ~/.ssh, allowing the project test runner, reviewing a new outbound network destination, and denying a destructive command outside the workspace. Add a regression test whenever a real incident or near miss exposes an unexpected path. This turns operational lessons into durable controls rather than one-time warnings.
Where HOL Guard fits
HOL Guard an open source implementation of this pre-execution pattern for AI agents and coding-tool workflows. It intercepts supported actions before execution and applies policy so a risky operation can be allowed, denied, or stopped for review. The broader pattern is not specific to one product. Teams can build the same architecture with their own wrappers, agent hooks, policy middleware, and Linux controls.
The important design choice is where enforcement lives. If the check sits after the command, it is monitoring. If the model can bypass the check, it is advisory. If every side-effecting tool call must cross a policy boundary before execution, it becomes an actual control.
Build the smallest useful boundary
Start with the actions that have the largest blast radius: shell execution, filesystem writes, credential access, package installation, Git pushes, and outbound network calls. Normalise those actions, apply deterministic policy, and make review a first-class result rather than an exceptional path.
AI agents will keep getting more capable. The useful security question is not whether a model can be perfectly trusted. It is whether a proposed action can be checked before the system commits to it. On Linux, that boundary can be small, testable, open source, and layered with controls administrators already understand.















































































