Live data from Hacker News

Show HN: A context-aware permission guard for Claude Code

github.com

71–80 of 109 posts

Re: Show HN: A context-aware permission guard for Claude Code

#71

Interesting approach to the PreToolUse side. I've been building on the other end — PostToolUse hooks that commit every tool call to an append-only Merkle tree (RFC 6962 transparency log style). The two concerns are complementary: "nah" answers "should this action be allowed?" while a transparency log answers "can we prove what actually happened, after the fact?" For the adversarial cases people are raising (obfuscate…

Very cool approach! the immutable log file fits well with nah. I'll take it into account for richer audit trail capabilities. Would be curious to see your hook implementation if its public anywhere

Sure — it's at https://github.com/PunkGo/punkgo-jack

It hooks into PostToolUse, PreToolUse, SessionStart/End, and UserPromptSubmit. Each event gets submitted to a local kernel that appends it to an RFC 6962 Merkle tree. You can then verify any event with an inclusion proof, or check log integrity between two checkpoints with a consistency proof.

The verify command works offline — just needs the checkpoint and tile hashes, no daemon required. There's also a Go implementation in examples/verify-go/ that independently verifies the same proofs, to show it's not tied to one language.

Would be interesting to explore composing nah's classification decisions with a verifiable log — every allow/deny gets a receipt too.

Re: Show HN: A context-aware permission guard for Claude Code

#72
This is not criticism of your project specifically, but a question for all tools in this space: What's stopping your agent from overwriting an arbitrary source file (e.g. index.js) with arbitrary code and running it?

A rogue agent doesn't need to run `rm -rf /`, it just needs to include a sneaky `runInShell('rm -rf /')` in ANY of your source code files and get it to run using `npm test`. Both of those actions will be allowed on the vast majority of developer machines without further confirmation. You need to review every line of code changed before the agent is allowed to execute it for this to work and that's clearly not how most people work with agents.

I can see value in projects like this to protect against accidental oopsies and making a mess by accident, but I think that marketing tools like this as security tools is irresponsible - you need real isolation using containers or VMs.

Here's one more example showing you why blacklisting doesn't work, it doesn't matter how fancy you try to make it because you're fighting a battle that you can't win - there are effectively an infinite number of programs, flags, environment variables and config files that can be combined in a way to execute arbitrary commands:

    bash> nah test "PAGER='/bin/sh -c \"touch ~/OOPS\"' git help config"

    Command:  PAGER='/bin/sh -c "touch ~/OOPS"' git help config
    Stages:
      [1] git help config → git_safe → allow → allow (git_safe → allow)
    Decision:    ALLOW
    Reason:      git_safe → allow
Alternatively:

    bash> nah test "git difftool -y -x 'touch ~/OOPS2' --no-index /etc/hostname /etc/hosts"
    Command:  git difftool -y -x 'touch ~/OOPS2' --no-index /etc/hostname /etc/hosts
    Stages:
      [1] git difftool -y -x touch ~/OOPS2 --no-index /etc/hostname /etc/hosts → git_safe → allow → allow (git_safe → allow)
    Decision:    ALLOW
    Reason:      git_safe → allow

Re: Show HN: A context-aware permission guard for Claude Code

#73

Earlier quoted context omitted.

Very cool approach! the immutable log file fits well with nah. I'll take it into account for richer audit trail capabilities. Would be curious to see your hook implementation if its public anywhere

Sure — it's at https://github.com/PunkGo/punkgo-jack It hooks into PostToolUse, PreToolUse, SessionStart/End, and UserPromptSubmit. Each event gets submitted to a local kernel that appends it to an RFC 6962 Merkle tree. You can then verify any event with an inclusion proof, or check log integrity between two checkpoints with a consistency proof. The verify command works offline — just needs the checkpoint and tile ha…

looks neat! and fits perfectly with nah. I can see enterprises starting to care more about this as more people adopt coding CLIs and prod goes boom more often.

Re: Show HN: A context-aware permission guard for Claude Code

#74

This is not criticism of your project specifically, but a question for all tools in this space: What's stopping your agent from overwriting an arbitrary source file (e.g. index.js) with arbitrary code and running it? A rogue agent doesn't need to run `rm -rf /`, it just needs to include a sneaky `runInShell('rm -rf /')` in ANY of your source code files and get it to run using `npm test`. Both of those actions will be…

Good catch, that's a legit bypass

nah strips env var prefixes before classifying the command but doesn't inspect their values for embedded shell execution, I'll fix it: https://github.com/manuelschipper/nah/issues/6

On the broader write-then-execute point - two improvements are coming:

- Script execution inspection: when nah sees python script.py, read the file and run content inspection and LLM analysis before execution

- LLM inspection for Write/Edit: for content that's suspicious but doesn't match any deterministic pattern, route it to the LLM for a second opinion

Won't close it 100% - to your point a sandbox is the answer to that.

I don't think "security tool" and "not a sandbox" are contradictory though. Firewalls don't replace OS permissions, OS permissions don't replace encryption

nah is just another layer that catches the 95% that's structurally classifiable. It's a different threat model. If 200 IQ Opus is rogue deterministic tools or even adversarial one shot LLMs won't be able to do much to stop it...

Re: Show HN: A context-aware permission guard for Claude Code

#76
nah addresses "should this action be allowed?" — deterministic classification of tool calls against policies. Smart design, and the no-dependency stdlib approach is the right call for security tooling.

The complementary question most agent safety tools ignore: what happens when things go wrong despite permissions?

I run 8 AI agents managing my company (marketing, accounting, legal, ops). We have a similar permission model — Marketing can't publish claims without Lawyer review, financial changes need CFO sign-off, hard boundaries on auth/compliance. But permissions alone didn't save us when two agents fired parallel writes to the same knowledge graph. Both writes were individually permitted. The second silently overwrote the first. No error, no policy violation — data just disappeared.

What saved us: Erlang-style supervision trees. Memory server detected corruption on load, crashed intentionally, supervisor restarted it in microseconds, auto-repair ran on init. No human at 3am.

Permission guards prevent known-bad actions. Supervision makes unknown-bad outcomes survivable. Most agent safety work focuses exclusively on the first problem.

Wrote up the full race condition mechanics and supervision strategies: https://dev.to/setas/why-erlangs-supervision-trees-are-the-m...

Re: Show HN: A context-aware permission guard for Claude Code

#77

Earlier quoted context omitted.

Sure — it's at https://github.com/PunkGo/punkgo-jack It hooks into PostToolUse, PreToolUse, SessionStart/End, and UserPromptSubmit. Each event gets submitted to a local kernel that appends it to an RFC 6962 Merkle tree. You can then verify any event with an inclusion proof, or check log integrity between two checkpoints with a consistency proof. The verify command works offline — just needs the checkpoint and tile ha…

looks neat! and fits perfectly with nah. I can see enterprises starting to care more about this as more people adopt coding CLIs and prod goes boom more often.

Exactly. The moment an agent touches prod, "we logged it" isn't enough — you need "here's the cryptographic proof of what happened, and you can verify it without trusting us."

Compliance teams (SOC 2, EU AI Act Article 12) will demand this. The nice part is RFC 6962 is already battle-tested at scale — Certificate Transparency processes billions of entries. Same math, different domain.

Re: Show HN: A context-aware permission guard for Claude Code

#78
The context-aware classification is neat, especially the pipe composition stuff. One thing I keep thinking about though — the scariest exfiltration pattern isn't a single bad command, it's a chain of totally normal ones. Agent reads .env (filesystem_read → allow), writes a script that happens to include those values (project write → allow), then runs it (package_run → allow). Every step looks fine individually. Credentials gone. This is basically the same problem as cross-module vulns in web apps — each component is secure on its own, the exploit lives in the data flow between them. Would be interesting to see some kind of session-level tracking that flags when sensitive reads flow into writes and then executions within the same session. Doesn't need to be heavy — just correlating what was read with what gets written/executed.

Re: Show HN: A context-aware permission guard for Claude Code

#79

The context-aware classification is neat, especially the pipe composition stuff. One thing I keep thinking about though — the scariest exfiltration pattern isn't a single bad command, it's a chain of totally normal ones. Agent reads .env (filesystem_read → allow), writes a script that happens to include those values (project write → allow), then runs it (package_run → allow). Every step looks fine individually. Crede…

thank! and I agree with you on chain exfiltration - it's a hard one to protect against. nah passes the last few messages of conversation history to the LLM gate, so it may be able to catch this scenario, but it's hard from a guarantee. I plan to add a gate where an LLM reads scripts before executing, which will also mitigate this.

The right solution though is a monitoring service on your network that checks for exfiltration of credential. nah is just one layer in the stack.

Re: Show HN: A context-aware permission guard for Claude Code

#80

How do people install stuff like this? So many tools these days use `npm install` or `pip install`. I certainly have npm and pip installed but they're sandboxed to specific projects using a tool like devbox, nix-devshell, docker or vagrant (in order of age). And they'll be wildly different versions. To be pedantic `pip` is available globally but it throws the sensible `error: externally-managed-environment` I'm sure…

I tend to use things like pyenv or nvm; they keep python and node versions in environments local to your user, rather than the system. `pip install x` then installs inside your pyenv and gives you a tool available in your shell

I used nvm a long time and was very happy to get rid of it and use `devbox` and similar tools instead.

The rule on my machine now is that everything has to be in a per-project sandbox, self-contained to ~/.local/bin or installed by the system package manager.

The question was about global tools, something nvm purposefully does not handle.

The `uv tool` answer by a sibling comment was great; it'd be nice to have something similar for npm.

Post reply on HN