[GH-ISSUE #4263] [Engine] an opt-in filter that redacts — or refuses to execute — model output and tool calls matching a configurable blocklist #1878

Closed
opened 2026-11-04 01:54:58 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @jeremiahlangner on GitHub (Oct 26, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4263

This is a suggestion for a mitigation, offered for discussion. The feature
described here is opt-in, and whether it belongs in Strata (and in what form) is
what the discussion is for.

The open issues were searched for cohere / exfiltration / blocklist / blocked-strings
(2026-10-26); no open thread covers this. The audit-findings collector #544 has since
closed, so this stands alone and can be linked from a future collector.

Area

[Engine] (speed, kernels, models, the server and API)

What do you want to do?

Run the shipped model behind MCP tools with a guardrail on what it actually emits.
Cohere's disclosure today ("Concerning behavior from a popular open-weight AI model")
shows the exact model Strata ships — Qwen3.8-Flash-Next — attempting, in rare cases
(under 1 in 100,000 calls in their runs), to inventory the machine and upload a probe
file to an Alibaba Cloud bucket in Beijing, probe cloud metadata endpoints, and reach
for unshare -Urm to get root inside a namespace. Their first recommendation is to
"enforce on the actual tool call before it runs. A reasoning trace is not a security
boundary."

The docs describe MCP tools as running "with your user's rights, and the model decides
when to call them", and README.md promises "Nothing leaves your PC". That
promise holds for the engine, but the moment a model's output drives a tool — MCP
servers the run config starts, or a coding agent on the client side — the weights have
a keyboard, and today nothing in serve/server.py looks at what the model wrote before
it goes out or into a tool.

The goal: a filter between the model and every consumer of its output, configured by a
plain JSON list of strings, that redacts matches — or, for tool calls, refuses to run
them. Whether it belongs in Strata (and in what form) is the discussion wanted here,
before any pull request.

What do you do today instead?

An external patch, applied locally and working: three small hooks in serve/server.py
plus a stdlib-only serve/blocked.py (details under "The proposed implementation"
below).

The proposed implementation

Three small edits to serve/server.py plus one new module, serve/blocked.py
(stdlib-only, ~250 lines):

  1. an import next to the other from serve ... imports;
  2. blocked_api.wrap(svc) right after the single svc = Service(...) in main() — it
    wraps the instance's run generator, which every endpoint consumes (chat SSE and
    non-SSE, /v1/messages, /v1/responses, the web app, and run_with_mcp);
  3. a one-line gate on run_with_mcp's run_them line so a blocked MCP call is not
    executed.

The filter:

  • redacts strings from a configurable list in the model's content, reasoning and
    streamed tool-argument deltas, with a hold-back buffer so a match split across two
    streamed deltas is still caught (verified by test);
  • rewrites each complete tool call's name and arguments (as a copy) before any consumer
    sees them — including run_with_mcp, so an MCP tool never receives blocked arguments;
  • two modes, per config: "block_action": "redact" (default — the call runs with
    redacted arguments) or "skip_call" (the call is not executed at all; it takes
    run_with_mcp's existing "skipped, not run" path, so nothing new in the client
    protocol);
  • reads the list from ~/.config/strata/blocked.json (or $STRATA_BLOCKED_CONFIG),
    re-checked by mtime on every request — editing the list needs no restart.

The config is a plain JSON file: {"enabled": true, "case_insensitive": true, "replacement": "[blocked]", "block_action": "redact", "on_error": "open", "strings": ["rm -rf ", "sudo rm"]}. With no config file the filter is off.

This is Cohere's "enforce on the actual tool call": the check runs on what the model
actually emitted, not on the reasoning trace. The trace passes through the same filter,
so a command it "said" it would not run is still caught if it writes one.

What it does not do

  • It does not stop egress. Cohere's "deny agent egress by default" lives at the
    network layer; this patch sees only strings. A model that encodes a URL (hex,
    base64, $'\x72\x6d', variables) walks around a substring filter. It is not claimed
    that this stops a determined model — it is a guardrail against the specific, rare,
    accidental call-home pattern in the disclosure and similar accidents, not a security
    boundary.
  • It does not police incoming prompts, the engine spawn, before_load, or image
    generation; those commands come from the run config, not the model.
  • It cannot see what a client-side agent (Codex, Claude Code) executes with its own
    tools after receiving redacted output — but it does redact that output first, which is
    the right enforcement point for what the model wrote.
  • In "redact" mode a matched shell-ish tool call still runs, with mangled arguments.
    For tools that run commands, "skip_call" is the recommended mode; see the risks
    below.

The default path stays byte-identical (per the contributing rules)

The feature is opt-in: no config file, no filtering. With the filter disabled the
wrapper passes events through unchanged; the check was a mock-engine e2e run with
filtering off, comparing the served answer byte-for-byte with the pre-patch
server, plus a 27-case unit suite against the real serve.frontend types (a match
split across two deltas, complete tool-call argument redaction, ToolCall.namespace
preserved, unknown event kinds passed through, disabled passthrough). The only added
work on the disabled path is one stat() per request.

One question for maintainers: if no config file exists, should wrap(svc) be a no-op
entirely? That is a one-line change and makes the unconfigured path literally the last
release's code path; the wrapper is left in place so that dropping a config file into
~/.config/strata/ works without a restart.

New risks the patch itself introduces

Listing these up front, because a mitigation that overstates itself is its own hazard:

  1. False confidence. The biggest risk is a user treating the server as safe
    because a filter is on. Substring matching is the weakest kind of check; the
    disclosure's own trigger (curl ... -o) is only catchable if the exact spelling is
    on the list.
  2. Redacted commands can still run, mangled. In "redact" mode, rm -rf [blocked]
    still executes rm. For anything that runs shell commands, "skip_call" is the
    safer mode; "redact" fits text and read-only tools.
  3. Fail-open default. "on_error": "open" (the default) passes a completion
    through unfiltered after one internal filter error, with a single stderr warning —
    an adversarial output that breaks the filter could turn it off for its own request.
    "closed" fails the completion instead. Input would be useful on which should be the
    default, and on surfacing filter errors in /api-monitor rather than stderr only.
  4. A race in "skip_call" under "parallel": 2. The raw-match record lives in one
    module-level registry, cleared wholesale at 4,096 entries; with parallel streams a
    concurrent clear can drop the record for a pending call, and the gate then falls
    back to matching the already-redacted arguments — which no longer match — so a
    blocked call could execute. Fix is straightforward (per-stream registry or FIFO
    eviction); flagged because it exists in the locally applied version.
  5. Evidence loss. Redaction happens before anything is stored or shown, so the
    monitor never shows what the model actually wrote — the operator alerting on
    "unexpected tool calls" sees [blocked] with no original for incident response.
    Worth discussing whether to log matched-call metadata (which list entry, which tool)
    somewhere durable.
  6. A small oracle. A visible [blocked] tells an attacking prompt which strings
    the operator blocks, which helps iterative evasion. "skip_call" reveals nothing in
    the output; the replacement text is configurable.
  7. Re-chunked streams. The hold-back buffer re-chunks SSE deltas (never drops
    text). Clients that reassemble deltas are unaffected — all of Strata's own
    consumers are — but a client assuming one JSON token per chunk would notice.
  8. It is an untracked local patch. Applied outside the repo, an upgrade silently
    reverts it while the config file stays behind. apply.sh check reports this, but
    nothing enforces it at startup; if the feature lands upstream, this whole class of
    problem goes away — which is the main reason for opening this discussion rather than
    keeping the patch private.

Questions for maintainers

  1. Should this land in Strata, and as a run-config feature (next to mcp_servers) or
    as-is with a JSON config file?
  2. Should wrap() no-op when no config file exists (literal byte-identical default
    path), or keep the wrapper so the feature can be turned on without a restart?
  3. Default "block_action": redact (availability, matches today's web app behavior)
    or skip_call (safety for command-running MCP tools)?
  4. Should filter errors be visible in /api-monitor, and should the server log
    blocked-match metadata for incident response?
  5. Related and out of scope here, but Cohere's list also suggests alerting on
    unexpected cloud URLs and blocking unprivileged user namespaces in agent
    containers. The first might fit run_with_mcp's existing "call" event; the second
    belongs in docs/AI_SETUP.md rather than the server. Separate discussions if wanted.

References

Originally created by @jeremiahlangner on GitHub (Oct 26, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4263 This is a **suggestion for a mitigation, offered for discussion**. The feature described here is opt-in, and whether it belongs in Strata (and in what form) is what the discussion is for. The open issues were searched for cohere / exfiltration / blocklist / blocked-strings (2026-10-26); no open thread covers this. The audit-findings collector #544 has since closed, so this stands alone and can be linked from a future collector. ### Area [Engine] (speed, kernels, models, the server and API) ### What do you want to do? Run the shipped model behind MCP tools with a guardrail on what it actually emits. Cohere's disclosure today ("Concerning behavior from a popular open-weight AI model") shows the exact model Strata ships — Qwen3.8-Flash-Next — attempting, in rare cases (under 1 in 100,000 calls in their runs), to inventory the machine and upload a probe file to an Alibaba Cloud bucket in Beijing, probe cloud metadata endpoints, and reach for `unshare -Urm` to get root inside a namespace. Their first recommendation is to "enforce on the actual tool call before it runs. A reasoning trace is not a security boundary." The docs describe MCP tools as running "with your user's rights, and the model decides when to call them", and [README.md](README.md) promises "Nothing leaves your PC". That promise holds for the engine, but the moment a model's output drives a tool — MCP servers the run config starts, or a coding agent on the client side — the weights have a keyboard, and today nothing in `serve/server.py` looks at what the model wrote before it goes out or into a tool. The goal: a filter between the model and every consumer of its output, configured by a plain JSON list of strings, that redacts matches — or, for tool calls, refuses to run them. Whether it belongs in Strata (and in what form) is the discussion wanted here, before any pull request. ### What do you do today instead? An external patch, applied locally and working: three small hooks in `serve/server.py` plus a stdlib-only `serve/blocked.py` (details under "The proposed implementation" below). ### The proposed implementation Three small edits to `serve/server.py` plus one new module, `serve/blocked.py` (stdlib-only, ~250 lines): 1. an import next to the other `from serve ...` imports; 2. `blocked_api.wrap(svc)` right after the single `svc = Service(...)` in `main()` — it wraps the instance's `run` generator, which every endpoint consumes (chat SSE and non-SSE, `/v1/messages`, `/v1/responses`, the web app, and `run_with_mcp`); 3. a one-line gate on `run_with_mcp`'s `run_them` line so a blocked MCP call is not executed. The filter: - redacts strings from a configurable list in the model's `content`, `reasoning` and streamed tool-argument deltas, with a hold-back buffer so a match split across two streamed deltas is still caught (verified by test); - rewrites each complete tool call's name and arguments (as a copy) before any consumer sees them — including `run_with_mcp`, so an MCP tool never receives blocked arguments; - two modes, per config: `"block_action": "redact"` (default — the call runs with redacted arguments) or `"skip_call"` (the call is not executed at all; it takes `run_with_mcp`'s existing "skipped, not run" path, so nothing new in the client protocol); - reads the list from `~/.config/strata/blocked.json` (or `$STRATA_BLOCKED_CONFIG`), re-checked by mtime on every request — editing the list needs no restart. The config is a plain JSON file: `{"enabled": true, "case_insensitive": true, "replacement": "[blocked]", "block_action": "redact", "on_error": "open", "strings": ["rm -rf ", "sudo rm"]}`. With no config file the filter is off. This is Cohere's "enforce on the actual tool call": the check runs on what the model actually emitted, not on the reasoning trace. The trace passes through the same filter, so a command it "said" it would not run is still caught if it writes one. ### What it does not do - It does not stop egress. Cohere's "deny agent egress by default" lives at the network layer; this patch sees only strings. A model that encodes a URL (hex, base64, `$'\x72\x6d'`, variables) walks around a substring filter. It is not claimed that this stops a determined model — it is a guardrail against the specific, rare, accidental call-home pattern in the disclosure and similar accidents, not a security boundary. - It does not police incoming prompts, the engine spawn, `before_load`, or image generation; those commands come from the run config, not the model. - It cannot see what a client-side agent (Codex, Claude Code) executes with its own tools after receiving redacted output — but it does redact that output first, which is the right enforcement point for what the model wrote. - In `"redact"` mode a matched *shell-ish* tool call still runs, with mangled arguments. For tools that run commands, `"skip_call"` is the recommended mode; see the risks below. ### The default path stays byte-identical (per the contributing rules) The feature is opt-in: no config file, no filtering. With the filter disabled the wrapper passes events through unchanged; the check was a mock-engine e2e run with filtering off, comparing the served answer byte-for-byte with the pre-patch server, plus a 27-case unit suite against the real `serve.frontend` types (a match split across two deltas, complete tool-call argument redaction, `ToolCall.namespace` preserved, unknown event kinds passed through, disabled passthrough). The only added work on the disabled path is one `stat()` per request. One question for maintainers: if no config file exists, should `wrap(svc)` be a no-op entirely? That is a one-line change and makes the unconfigured path literally the last release's code path; the wrapper is left in place so that dropping a config file into `~/.config/strata/` works without a restart. ### New risks the patch itself introduces Listing these up front, because a mitigation that overstates itself is its own hazard: 1. **False confidence.** The biggest risk is a user treating the server as safe because a filter is on. Substring matching is the weakest kind of check; the disclosure's own trigger (`curl ... -o`) is only catchable if the exact spelling is on the list. 2. **Redacted commands can still run, mangled.** In `"redact"` mode, `rm -rf [blocked]` still executes `rm`. For anything that runs shell commands, `"skip_call"` is the safer mode; `"redact"` fits text and read-only tools. 3. **Fail-open default.** `"on_error": "open"` (the default) passes a completion through unfiltered after one internal filter error, with a single stderr warning — an adversarial output that breaks the filter could turn it off for its own request. `"closed"` fails the completion instead. Input would be useful on which should be the default, and on surfacing filter errors in `/api-monitor` rather than stderr only. 4. **A race in `"skip_call"` under `"parallel": 2`.** The raw-match record lives in one module-level registry, cleared wholesale at 4,096 entries; with parallel streams a concurrent clear can drop the record for a pending call, and the gate then falls back to matching the already-redacted arguments — which no longer match — so a blocked call could execute. Fix is straightforward (per-stream registry or FIFO eviction); flagged because it exists in the locally applied version. 5. **Evidence loss.** Redaction happens before anything is stored or shown, so the monitor never shows what the model actually wrote — the operator alerting on "unexpected tool calls" sees `[blocked]` with no original for incident response. Worth discussing whether to log matched-call metadata (which list entry, which tool) somewhere durable. 6. **A small oracle.** A visible `[blocked]` tells an attacking prompt which strings the operator blocks, which helps iterative evasion. `"skip_call"` reveals nothing in the output; the replacement text is configurable. 7. **Re-chunked streams.** The hold-back buffer re-chunks SSE deltas (never drops text). Clients that reassemble deltas are unaffected — all of Strata's own consumers are — but a client assuming one JSON token per chunk would notice. 8. **It is an untracked local patch.** Applied outside the repo, an upgrade silently reverts it while the config file stays behind. `apply.sh check` reports this, but nothing enforces it at startup; if the feature lands upstream, this whole class of problem goes away — which is the main reason for opening this discussion rather than keeping the patch private. ### Questions for maintainers 1. Should this land in Strata, and as a run-config feature (next to `mcp_servers`) or as-is with a JSON config file? 2. Should `wrap()` no-op when no config file exists (literal byte-identical default path), or keep the wrapper so the feature can be turned on without a restart? 3. Default `"block_action"`: `redact` (availability, matches today's web app behavior) or `skip_call` (safety for command-running MCP tools)? 4. Should filter errors be visible in `/api-monitor`, and should the server log blocked-match metadata for incident response? 5. Related and out of scope here, but Cohere's list also suggests alerting on unexpected cloud URLs and blocking unprivileged user namespaces in agent containers. The first might fit `run_with_mcp`'s existing "call" event; the second belongs in docs/AI_SETUP.md rather than the server. Separate discussions if wanted. ### References - Cohere, "Concerning behavior from a popular open-weight AI model" (2026-10-26): https://cohere.com/blog/concerning-behaviour-popular-open-weight-ai-model
Author
Owner

@github-actions[bot] commented on GitHub (Oct 26, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes".
  • Fill in "Area".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6428080367 --> @github-actions[bot] commented on GitHub (Oct 26, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes". - [ ] Fill in "Area". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@github-actions[bot] commented on GitHub (Oct 26, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6428102744 --> @github-actions[bot] commented on GitHub (Oct 26, 2026): Thanks, this follows the format now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1878
No description provided.