Re: @reneza — your 30-line runtime interception hook is now in UTA, here's what changed
Following your import-time point: the piece that closes it is a runtime interception layer, a hook that sees each tool call the installed skill actually makes and checks it against a policy before it runs. Allowlist the
Following your import-time point: the piece that closes it is a runtime interception layer, a hook that sees each tool call the installed skill actually makes and checks it against a policy before it runs. Allowlist the hosts and paths a skill may touch, require approval for side-effecting calls, and decide it deterministically outside the model, so a skill that passed every import scan still cannot fetch a second stage on call 50 or exfiltrate through a whitelisted host. Import-time scanning answers is this package clean, this answers is this specific call allowed right now. A 30-line version of that call-time hook is here: gist.github.com/renezander030/a676...
I read the gist. It's the right pattern, and you're right that it closes the import-time/runtime gap. Shipping it in UTA with attribution.
What your hook does (for readers)
The 30-line version:
- Wraps the MCP server's
tool_callhandler - Before each call, checks the requested host/path against an allowlist
- If the call would touch something off-allowlist, returns an error before the tool runs
- Logs every call (allowed or vetoed) to a tamper-evident log
That's the innermost layer — the one @bogumi_jankiewicz_fcfce0 also pointed at with gate.cat. Your gist is a minimal version that any MCP server author can drop into their own server without adopting a full framework.
How I'm integrating it
I added your hook as the pre-exec filter in @marketnow/trust-gateway (the MCP middleware package). It's:
import { createPreExecFilter } from '@marketnow/trust-gateway';
const filter = createPreExecFilter({
allowHosts: ['api.github.com', 'registry.npmjs.org'],
allowPaths: ['/tmp/', '/var/lib/mcp/'],
denyActions: ['shell_exec', 'rm_rf', 'DROP_TABLE'],
requireApprovalAbove: { spend_usd: 1 },
logSink: (event) => merkleLog.append(event) // tamper-evident
});
// Wrap an MCP server
const filteredServer = filter.wrap(originalServer);
The filter.wrap() returns a new server that intercepts every tool_call before delegating to the original. Vetoed calls return:
{
"error": "pre_exec_veto",
"reason": "host_not_allowlisted",
"attempted": "evil.example.com",
"allowed": ["api.github.com", "registry.npmjs.org"],
"receipt_id": "ATC-RECEIPT-2026-..."
}
The receipt_id is a signed, Merkle-audited log entry. The caller can verify the veto happened and audit the policy decision later.
What I added on top of your 30 lines
Three things your gist didn't have that production needs:
1. Tamper-evident log
Your gist logged to console.log. For production we need a log that can't be silently edited. We use a Merkle tree where each event's hash chains to the previous one, and the root hash is signed with Ed25519 every N events (default N=100). If anyone edits a past log entry, the hash chain breaks and the signature won't verify.
This is what the logSink callback in the example above does — it appends to our existing audit log (the same one used for ATC action receipts).
2. Approval escalation
You wrote: "require approval for side-effecting calls"
We added a configurable threshold:
requireApprovalAbove: {
spend_usd: 1, // any call that would spend >$1 needs approval
delete_count: 1, // any delete operation needs approval
shell_exec: true // any shell execution needs approval
}
When a call exceeds the threshold, the filter doesn't veto outright — it returns a pending_approval status and waits for an approval signal. The approval signal can come from:
- The user (via the client UI)
- An external approver service (e.g. Slack approval flow)
- A programmatic policy (e.g. "auto-approve if the agent's trust score >= 8")
The call blocks until approval arrives or times out (default 30s, configurable).
3. Per-call network egress logging
You wrote: "a skill that passed every import scan still cannot fetch a second stage on call 50"
This is the key insight. The first 49 calls might be legitimate (the agent warming up, reading context, etc.). Call 50 is when the malicious payload drops. We need to log every network egress per call so we can detect this pattern.
The filter logs:
- Which host was contacted
- What endpoint on that host
- What payload was sent (size + hash, not contents — privacy)
- What response came back (size + hash)
These logs go into the same Merkle tree as the veto events. After-the-fact, an analyst can reconstruct: "Agent X made 49 calls to api.github.com (legit), then on call 50 hit evil.example.com (the second-stage fetch)."
What's in the package now
I published @marketnow/[email protected] with:
- The pre-exec filter (based on your gist, with attribution in the README and source comments)
- The tamper-evident log integration
- The approval escalation system
- The per-call network egress logger
- A test suite (12 tests covering allow/deny/approval/timeout/log-tampering)
Attribution in the README:
The pre-exec filter is based on a 30-line gist by @reneza
(https://gist.github.com/renezander030/a676...). Extended with
tamper-evident logging, approval escalation, and per-call
egress tracking. MIT licensed.
If you want your full name or different attribution, DM me — I'll update.
What I'd push back on
You wrote: "decide it deterministically outside the model"
Agreed on the principle — policy has to be deterministic, not LLM-mediated. But "deterministic" can mean different things:
- Pure function: same input → same output, no side effects
- State machine: same input + state → same output + state transition
- Event-sourced: same input + event log → same decision
Your gist is #1 — the allowlist check is a pure function. That's the right starting point.
But production policy needs #2 (the allowlist can change over time as the agent's trust score changes) and eventually #3 (we want to be able to replay the policy decisions later for audit).
The filter we shipped is #2 today (allowlist is mutable, current state is queried at decision time). #3 is roadmap — we have the event log, we just need the replay tooling.
The naming
You called it "runtime interception layer". We're calling it "pre-exec filter" because:
- "Runtime" is overloaded (every layer is "runtime" in some sense)
- "Interception" sounds adversarial (we're not intercepting traffic, we're gating it)
- "Filter" is the most accurate word for "decide yes/no before the call runs"
If you prefer a different name, I'm open. The code is createPreExecFilter today.
Test it
npm install @marketnow/trust-gateway
import { createPreExecFilter } from '@marketnow/trust-gateway';
const filter = createPreExecFilter({
allowHosts: ['api.github.com'],
denyActions: ['shell_exec'],
logSink: console.log
});
const myServer = /* your MCP server */;
const safe = filter.wrap(myServer);
// safe now vetoes any call to hosts not in allowHosts
If you find bugs, file them in the repo. If you have improvements, PRs welcome (see CONTRIBUTING.md).
— Edison Flores, AliceLabs LLC
marketnow.site · status.marketnow.site · GitHub
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.