Forum

Notifications
Clear all

Check out my policy-as-code repo for OPA validation of NanoClaw specs

2 Posts
2 Users
0 Reactions
9 Views
(@new_hamster)
Eminent Member
Joined: 2 months ago
Posts: 29
Topic starter   [#1840]

Hey everyone 👋

Been working on my first real project with NanoClaw, trying to get a handle on the security model. I’ve been focusing on the spec validation side of things, because I figure if the spec is wrong, the isolation probably breaks down somewhere, right?

I put together a small policy-as-code repository using the Open Policy Agent (OPA) to check NanoClaw task and job specifications before they run. The idea is to catch common misconfigurations that might weaken container isolation—like tasks requesting overly privileged capabilities, mounting sensitive host paths, or using the `host` network without a clear need. I'm hoping it can serve as a decent starting point for others who, like me, are maybe a bit too cautious and want an extra layer of checks.

The repo has a few main Rego policies that look for things like:
* Non-root user enforcement (or at least flagging when it's not set)
* Validating that `readOnlyRootFilesystem` is set to true where possible
* Flagging any use of `hostPID`, `hostIPC`, or `hostNetwork`
* Basic checks on volume mounts to spot potential escapes

I’d really appreciate it if some of you with more experience could take a look. I’m especially unsure about the policy for shared volumes between concurrent tasks—I know that’s a known gap where isolation can break down, but I’m not sure my rule for detecting problematic `volumeMounts` across a job is strict enough, or if it’s too strict and will block valid workflows.

Here’s the link: [link to repo]. I’d love any feedback on the rules themselves, or if there are other obvious spec-level gaps I should be trying to catch. Maybe things related to resource limits or image provenance? Still learning the ropes here.



   
Quote
(@selftaught_sec)
Eminent Member
Joined: 2 months ago
Posts: 18
 

That's a fantastic idea. I've been trying to wrap my head around the actual risk surface of a misconfigured spec, and you're right, that's where it all starts. Your point about catching specs that use the host network without a clear need is exactly the kind of thing I worry about.

I'm curious, does your policy just flag *any* use of hostNetwork, or are you trying to make it smarter? Like, could you whitelist it only for a specific job name pattern, or is that overcomplicating it for a starting point? I ask because my home automation stuff sometimes legitimately needs to broadcast on the local network, and I'd hate to have a blanket rule block it. I'd probably just end up disabling the check entirely, which defeats the purpose.

Also, have you thought about checking the order of operations? One thing I've learned the hard way is that a task might drop a capability but then later mount a sensitive path, which sort of undoes the drop. Does OPA let you reason about the combined effect of multiple fields like that, or is it more of a per-field check?



   
ReplyQuote