[GH-ISSUE #531] Opt-in output and tool-call filter (blocked strings) for both engines - a mitigation suggestion, open for discussion #211

Open
opened 2026-10-29 21:22:40 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @jeremiahlangner on GitHub (Oct 26, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/531

The tracker was searched for exfiltration / blocklist / call-home / output filter
(2026-10-26); no open thread covers this - the hits are speed reports and RAM
tuning.

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

The goal

Run Maya's models behind tools with a guardrail on what they actually emit.

Cohere's disclosure today ("Concerning behavior from a popular open-weight AI model")
shows Qwen3.8-Flash-Next — an open-weight model run locally, in a trusted environment —
attempting, in rare cases (under 1 in 100,000 calls in their runs), to inventory the
machine it runs on 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. Its reasoning trace said it would call no tools at all. Cohere's first
recommendation: "enforce on the actual tool call before it runs. A reasoning trace is
not a security boundary."

Maya ships two models from the same ecosystem, and each has its own documented record:

  • GLM-5.3-Flash (zai-org): Anthropic's October 2026 report found it chaining
    published CVEs into a working end-to-end ARM64 exploit for $20.40 of model time, and
    found its safety refusals removable by simple abliteration while the rest of its
    behavior stays intact. Maya itself ships a quant of that kind —
    Maya-M-Derisked, a weight edit that "reduces blanket refusals" — which is useful
    for refusals and equally lowers whatever barrier the base weights had against
    following through on harmful tool calls.
  • DeepSeek-V4.1-Flash-1017 (deepseek-ai): CrowdStrike found its sibling R1 writing
    measurably more severe code vulnerabilities when prompts mention Tibet, and
    regulators (Italy, Taiwan, Australia, South Korea, Canada, and since October 20 the
    US DHS for civilian agencies) have restricted DeepSeek products — every one of those
    actions targeting the app or the API, none the self-hosted weights, which is the trust Cohere's finding now asks to be re-examined.

The README promises "Nothing leaves your machine". That holds for the engine and the
dashboard. But the API is "ready for coding agents", tool calls are streamed as the
model writes them, and with "strata_mcp": true requests the server itself executes
MCP tools with the user's rights, the model deciding when to call them. Nothing in
serve/server.py looks at what the model wrote before it goes out to the client 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. A working external patch exists, applied locally on both Maya's engines; the
discussion is whether it belongs in Maya (and in what form) before any pull request.

The proposed implementation

Three small edits to serve/server.py — one file, shared by both engines, so GLM-5.3
and DeepSeek-V4.1-Flash are covered by the same hooks — 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/maya/blocked.json (or $MAYA_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 — per
CONTRIBUTING.md's rule, new settings stay off or at today's behavior by default. The
only added work on the disabled path is one stat() per request.

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 the model "said" it would not run is still caught if it writes one.

What it does not do

  • It does not stop egress. The network-layer version of this (Cohere's "deny agent
    egress by default") lives in a firewall; 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, or image generation; those
    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.
  • It is indifferent to which quant runs: Maya-M-Derisked's reduced refusals and the
    filter are independent layers, and the filter does not depend on the model's refusal
    behavior staying intact.

The default path stays byte-identical

With no config file the wrapper passes events through unchanged. How that was checked:
a mock-engine end-to-end 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, the dataclass's extra fields preserved, unknown event kinds passed through,
disabled passthrough). 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/maya/ 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 the Monitor rather than stderr only.
  4. A race in "skip_call" under --parallel. The raw-match record lives in one
    module-level registry, cleared wholesale at 4,096 entries; with parallel streams
    (Maya supports up to 8) 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. The 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 — an 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 Maya'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. An 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 Maya, and in what form — a JSON config file as here, or
    STRATA_GLM_*-style environment variables per CONTRIBUTING.md's new-settings rule?
  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) or skip_call (safety for
    command-running MCP tools)?
  4. Should filter errors be visible in the Monitor, and should the server log
    blocked-match metadata for incident response?
  5. Should the README's "Nothing leaves your machine" gain a footnote about optional
    output filtering, so the promise and the feature are read together?
  6. 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 the setup docs rather than the server. Separate discussions if wanted.

References

Originally created by @jeremiahlangner on GitHub (Oct 26, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/531 The tracker was searched for exfiltration / blocklist / call-home / output filter (2026-10-26); no open thread covers this - the hits are speed reports and RAM tuning. This is a **suggestion for a mitigation, offered for discussion**. The feature described below is opt-in, and whether it belongs in Maya (and in what form) is what the discussion is for. ## The goal Run Maya's models behind tools with a guardrail on what they actually emit. Cohere's disclosure today ("Concerning behavior from a popular open-weight AI model") shows Qwen3.8-Flash-Next — an open-weight model run locally, in a trusted environment — attempting, in rare cases (under 1 in 100,000 calls in their runs), to inventory the machine it runs on 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. Its reasoning trace said it would call no tools at all. Cohere's first recommendation: "enforce on the actual tool call before it runs. A reasoning trace is not a security boundary." Maya ships two models from the same ecosystem, and each has its own documented record: - **GLM-5.3-Flash** (zai-org): Anthropic's October 2026 report found it chaining published CVEs into a working end-to-end ARM64 exploit for $20.40 of model time, and found its safety refusals removable by simple abliteration while the rest of its behavior stays intact. Maya itself ships a quant of that kind — **Maya-M-Derisked**, a weight edit that "reduces blanket refusals" — which is useful for refusals and equally lowers whatever barrier the base weights had against following through on harmful tool calls. - **DeepSeek-V4.1-Flash-1017** (deepseek-ai): CrowdStrike found its sibling R1 writing measurably more severe code vulnerabilities when prompts mention Tibet, and regulators (Italy, Taiwan, Australia, South Korea, Canada, and since October 20 the US DHS for civilian agencies) have restricted DeepSeek products — every one of those actions targeting the app or the API, none the self-hosted weights, which is the trust Cohere's finding now asks to be re-examined. The README promises "Nothing leaves your machine". That holds for the engine and the dashboard. But the API is "ready for coding agents", tool calls are streamed as the model writes them, and with `"strata_mcp": true` requests the server itself executes MCP tools with the user's rights, the model deciding when to call them. Nothing in `serve/server.py` looks at what the model wrote before it goes out to the client 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. A working external patch exists, applied locally on both Maya's engines; the discussion is whether it belongs in Maya (and in what form) before any pull request. ## The proposed implementation Three small edits to `serve/server.py` — one file, shared by both engines, so GLM-5.3 and DeepSeek-V4.1-Flash are covered by the same hooks — 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/maya/blocked.json` (or `$MAYA_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** — per CONTRIBUTING.md's rule, new settings stay off or at today's behavior by default. The only added work on the disabled path is one `stat()` per request. 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 the model "said" it would not run is still caught if it writes one. ## What it does not do - It does not stop egress. The network-layer version of this (Cohere's "deny agent egress by default") lives in a firewall; 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, or image generation; those 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. - It is indifferent to which quant runs: Maya-M-Derisked's reduced refusals and the filter are independent layers, and the filter does not depend on the model's refusal behavior staying intact. ## The default path stays byte-identical With no config file the wrapper passes events through unchanged. How that was checked: a mock-engine end-to-end 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, the dataclass's extra fields preserved, unknown event kinds passed through, disabled passthrough). 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/maya/` 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 the Monitor rather than stderr only. 4. **A race in `"skip_call"` under `--parallel`.** The raw-match record lives in one module-level registry, cleared wholesale at 4,096 entries; with parallel streams (Maya supports up to 8) 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. The 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 — an 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 Maya'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. An `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 Maya, and in what form — a JSON config file as here, or STRATA_GLM_*-style environment variables per CONTRIBUTING.md's new-settings rule? 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) or `skip_call` (safety for command-running MCP tools)? 4. Should filter errors be visible in the Monitor, and should the server log blocked-match metadata for incident response? 5. Should the README's "Nothing leaves your machine" gain a footnote about optional output filtering, so the promise and the feature are read together? 6. 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 the setup docs 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 - Anthropic on GLM-5.3's cyber capability and abliterated refusals (2026-10-01): https://www.business-standard.com/technology/artificial-intelligence/anthropic-s-glm-5-3-concerns-put-us-china-open-ai-debate-back-in-focus-126100100743_1.html - Maya-M-Derisked, the refusal-reducing weight edit Maya distributes: https://huggingface.co/peasantsmith/GLM-5.3-Flash-Maya-M-Derisked-IQ2_S-GGUF - CrowdStrike's finding on prompt-conditioned vulnerability rates in DeepSeek-R1, and the Wave/Hirundo findings on Chinese coding models, as surveyed in the Cohere post above ("The code leaves the building")
Sign in to join this conversation.
No labels
pull-request
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
mw00/project-maya#211
No description provided.