ac4af582301a4e8a29245dbba767eba31334ddf9
24
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2b2abec457 |
redact: a one-word name the model flags goes out only beside a thing's word, never alone or in tool arguments
With a model that labels Rina a PERSON, at origin/main |
||
|
|
d7714b3f3b |
redact: every tool call's arguments are the tool's, mcp_tool_use and Responses *_call included
With Secrets and Personal masking on, at origin/main |
||
|
|
e4b0555a17 |
redact: a timestamp under a token's field name is not masked as a secret (#5002)
"access_token_expires_at": "2026-08-30T11:44:31.312645+08:00" went out as
"{{SECRET_…}}:44:31.312645+08:00": the field's name has token in it, and
the SECRET rule took the timestamp's head up to the hour (its colons are
not a secret's characters), so 2026-08-30T11 was masked and the rest was
sent as written. The same happened after 令牌是, 密钥为, token 是,
SERVER_KEY: and DB_PASS:, and in a tool call's arguments the whole value
was masked by its field's name (namedSecret).
An RFC 3339 timestamp, whole or its head to the hour, is now left as
written there (timestampValue, beside versionValue and pathValue in
fieldAt, keyAt and namedSecret). The exemption is by the value's shape,
not the key's name: a value that only starts as a timestamp
(2026-08-30T11x9k2abc) still masks, and a secret beside the timestamp in
the same tool call still masks.
Changed from the contributor's patch: the patch deleted fieldAt's doc
bullet for the next-field rule (nextField), which still exists; it is
kept.
Run (mote): go test -tags nogui ./internal/redact/... ./internal/pii/...
./internal/masking/... (ok); go vet -tags nogui ./internal/redact/...;
gofmt -l (empty).
Broken by hand: with the old fieldvalue.go, json.go and redact.go,
TestTimestampIsNoSecret fails on the reporter's line with the same
output as the report ("{{SECRET_2ojutfrk}}:44:31.312645+08:00") and on
the other lines.
Not tried: the local masking model on the reporter's whole request.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
45385f0eed |
redact: a secret's field name masks only in a tool's arguments and result, with secrets on (#2946)
#2946's patch masked any JSON value whose field name looks like a secret's (api_key, password, *_token) anywhere in a request body outside tool definitions. That is an exemption, and a mask, keyed on a field's name: it rewrote what the agent itself sends (mcp_servers' authorization_token, a top-level api_key, metadata.session_token) as well as the user's data. The name check now runs only where the user's data sits in the protocol: a tool call's arguments (Anthropic tool_use input, OpenAI arguments, Gemini functionCall args) and a tool's result (Gemini functionResponse.response is added to the places scan reads), and only with secrets masking on. The Authorization/Cookie rule masked the word after the header name in prose too ("Authorization: required for this route"). It now masks only a value with a credential's shape: one token, or a scheme word and a token, of 8 or more characters with a non-letter and not a ${VARIABLE}; or name=value cookie pairs. Tests: TestMaskJSONNamedSecrets puts its values in tool_use input, functionCall args and functionResponse response; TestMaskJSONSecretNamesOnlyInToolArgs holds the agent's own fields as written and nothing masked with secrets off; TestMaskAuthHeaders gains prose rows (no mask) and a Cookie row. docs/subsystems/gateway-routing.md says where the name check runs. Landing record (yetone): Run at the pushed batch head (tree a6b084d0b, on origin/main |
||
|
|
9a05a7bcec |
redact: the mask covers ark- keys, _KEY/_PASS names, auth headers, and JSON field names (#2946)
What changed (one per gap the reporter reproduced on main): - API_KEY gains the ark- value shape (#2946): Volcano Ark and the relays in front of it issue keys with an ark- prefix, and no value rule knew one. ARK_API_KEY=<ark key> was masked already (its name has api_key in it); ARK_KEY=<ark key>, a key in prose and one in a request body went as they were. - A new SECRET rule takes an upper-case env var whose name only ends in KEY or PASS: SERVICE_X_KEY=…, FOO_KEY=…, DB_PASS=… — quoted or not. Upper case is the boundary: in the lower case a name that ends in key is code's (a sort_key:, a cache_key:, a public key =), so nothing of TestMaskGatewayKey's rows moves; notAPlainKey turns the upper-case SORT_KEY/PUBLIC_KEY/PROMPT_CACHE_KEY/CACHE_KEY away too. - A new SECRET rule takes the value of an Authorization: or Cookie: header line, whatever it looks like — the opaque bearer tokens and session values the shape rules had no eye for (#2946). - MaskJSON masks the value of a field named for a secret by its name, before the ids and names that would keep it: {"api_key": "…"} with a value no rule knows, {"db_pass": "…"}, an AKIA under access_key_id (its _id kept it from the value's own AKIA rule), {"Authorization": "Bearer …"} and {"Cookie": "…"} (#2946). signature, encrypted_content and data: values still go as written (#1911), and the tools' definitions are untouched. SecretName now says a name ending in pass is a secret's name too, so the archive (ScrubJSON) and MaskJSON judge a field by the same names. Why: the reporter's five examples each leak a credential whose value has no key's shape; the rules judged values by shape alone and field names only ever kept a value. The boundary the reporter warned about — sort_key, cache_key, prompt_cache_key, public_key must stay unmasked — is held by case (lower-case names never enter the new rules) and by notAPlainKey for the upper-case ones. Run (rebased onto |
||
|
|
5218119456 |
redact: every reply gets its values back, a turn that masked nothing too
yapechan123 (Discord) saw a table the model wrote come back as
{{PERSON_kb32hzkg}}、{{PERSON_iye66366}} and {{PERSON_isyrz5ih}}、
{{PERSON_j5kluh3x}}, all four in canonical form. Every way a placeholder
could come back unrestored was probed with those literal bytes, on each
protocol's stream split at every byte and at 1..7 runes, and whole:
- The gateway put no restoring writer on a reply when the request in
hand masked nothing (redactedHits, redactedPromptHits returned early
on n == 0). A vendor that holds the conversation (Codex's compacted
history, a server-side session) answers with placeholders of earlier
turns while the request carries no value, so they went back as
written. Most likely the reporter's path. Now every reply on a masked
route is read.
- Responses streams: each event's random "obfuscation" string could end
like a placeholder start and take the stream's one held tail from its
delta, so the placeholder after 、 stayed (4 of 140 text runs, 6 of
tool args runs). The writer now holds a tail per string path and
never for obfuscation or kept keys.
- Kept keys (name, type, data, status...) were never restored in a
stream, so a Gemini functionCall args object {"name":"{{PERSON_…}}"}
kept it. Every string is restored now but signatures, data: URLs and
opaque blobs (sealedText).
- A whole body skipped restoring unless it held "{{", so a model's
PERSON_kb32hzkg or {PERSON_kb32hzkg} stayed; heldIn looks for any held
placeholder's hash.
- makeRoom let a random half of 200k values go though its comment said
the oldest; now the least recently used half (touch on every mask and
hit), so a value just masked is never the one let go.
- A binary reply (audio/, image/, video/, octet-stream, pdf, zip) goes
through as it comes instead of being held.
Not fixed by design: values are in memory only (README's privacy
promise, TestNoValueOnDisk), so a placeholder from before a restart that
only the vendor still holds can't be restored. Masking switched off
later also restores nothing.
Tests (all red on d159314e3's code, green now, run on mote):
TestReporterTableRestoredOnEveryStream (responses-text 4, responses-tool
6 fails before), TestPlaceholdersRestoredWhereverTheySit,
TestFullValuesKeepTheNewest (499 of 1000 newest lost before),
TestBinaryReplyIsNotHeld, TestReplyToAnUnmaskedTurnIsRestored (gateway,
real stack: first turn masks an email, second masks nothing and the
fake vendor answers with the first turn's placeholder).
Run: gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... on mote: clean. The full go test -tags nogui
-timeout 45m ./... on mote, one step before this head, found a nil
masker in redactedPromptHits with masking off (image drawing:
TestAntigravityDrawingOutOfQuotaInsideTheReplyGoesOn, internal/cli's
image MCP); fixed here (m == nil returns as before). At this head
internal/redact and internal/gateway pass on Linux (wsl-run, 594s).
That run's other reds are outside this change: internal/gui
TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll) and
TestColdTurnsTaken, internal/proc TestNoCommandBypassesProc
(internal/claudetui/child_unix.go uses os/exec). The full suite runs
again at the pushed head after the tag.
Not tried: a real Codex compaction round trip with a real account, and
the reporter's agent (unknown).
|
||
|
|
7632e1be1d |
redact: a text sent on a route goes on it as it went, the model's late finds too (vvrfxyz on X)
vvrfxyz on X: "脱敏功能是不是会降低缓存命中率 我开了脱敏后 dsh命中率暴跌".
Cause: the local model (AstrLink Guard, on by default) is waited for
2s a request (masking's defaultWait). A tool's output it hasn't read
by then goes with the rules' masking alone (pii.Partial). On the next
turn the model has read it, finds the names in it, and the same history
text now goes with {{PERSON_…}} in it. Everything from that message on
is a new prompt to the vendor, so its prefix cache misses.
|
||
|
|
5a85a9836c |
redact: a value at the end of a tool call's arguments keeps its closing quote (xiaojiang091499 on X)
xiaojiang091499 on X (v0.1.1808): "隐私脱敏误把 Codex 工具参数结尾的引号和
花括号一起替换了,破坏了参数格式,导致会话一直报错重连". Still the case on
main before this commit.
Cause, outbound: a tool call's arguments are masked as JSON text
(MaskJSON, escaped). A span is kept out of escapes (#3022) but not inside
its JSON string, so a span that runs past the string's end took the
closing quote with it. The local model does this: Privacy Filter's
tokenizer merges a punctuation run, so in {"cmd":"export
DB_PASSWORD=Hunt3r!"} the real model's SECRET span is `Hunt3r!"`, and a
secret's edges are kept by design (#3591). Same with "the api key is
AbC…!?\"", "ship to 221B Baker Street, London.\"", "pwd=Qq123456@#\"".
A user rule like `tok-\S+` does the same. The vendor got
{"cmd":"export DB_PASSWORD={{SECRET_…}}}: arguments no longer JSON, so
Codex's turn failed and reconnected. The model is on by default since
v0.1.1858, so this hits every user from then.
Fix: inStrings (redact.go) moves each span in escaped text onto the JSON
string it starts in and ends it where that string ends. A span that is a
whole bare value (a number a rule finds, "acct": 12345678901) is kept and
its placeholder goes in quoted (span.bare); any other span outside a
string is dropped. Text that isn't valid JSON is left as before. This is the
path for Responses function_call and Chat tool_calls arguments (JSON
text); Anthropic tool_use input and Gemini functionCall args are
objects, masked string by string, so a span there never leaves its
string.
Sibling, inbound: Writer.event and restoreJSON read an event's "type" as
the walk reached it, so a Responses function_call_arguments.delta whose
"delta" key comes before "type" (as a Go map or any key-sorting proxy
writes it) had its value put back unescaped: a password with a quote in
it ended the arguments' string. typeOf now reads the type first, and the
Writer falls back to the SSE event name. Chat tool_calls and Anthropic
input_json_delta were already right (key "arguments"/"partial_json").
Tests (internal/redact/argstail_test.go):
- TestArgumentsValueAtEndKeepsQuote: the real model's four spans
(captured from Privacy Filter on mote) and a \S+ rule, in Responses and
Chat bodies; arguments stay JSON, the value is gone, Restore gives the
original back.
- TestArgumentsBareValueQuoted: a bare number is masked as a string.
- TestWriterStreamArgumentsValueAtEnd: a value with a quote and a
backslash, at the end of the arguments, split at every byte after its
placeholder starts, through Responses deltas (delta before type),
Chat tool_calls and Anthropic input_json_delta.
- TestRestoreJSONDeltaBeforeType: the whole-body path.
Broken by hand: without inStrings, the first two fail; with the type
read in the walk again in writer.go, the stream test fails at cuts 28-43
({"cmd":"export DB_PASSWORD=Hunt3r!"\x"}); the same in json.go fails
TestRestoreJSONDeltaBeforeType.
Real model: a probe (not committed) ran Privacy Filter on mote over 36
argument texts through MaskJSON as the gateway does; before, the
arguments were broken for each case above; after, all 36 are valid JSON
with the value masked.
Run on mote (mote-run): go test ./... -timeout 45m -count=1 at this
change on
|
||
|
|
a5315c70d5 |
redact: the local model doesn't read an agent's tool definitions (niuniu_8964 on X)
码妞 on X: the official container on a 4-core, 8 GB server, AstrLink Guard on, Claude Code's requests sat at 脱敏中 for minutes and timed out, load 1.78, a short conversation. |
||
|
|
bea9f905d0 |
redact: a key can go as a made-up key of its own form, not a placeholder (Charles Cao on X)
Charles Cao on X (2114238140835844575) asked for a format-preserving
swap: sk_w3axCByTQgK1PxqPhfKTrJOLBqz6sbZv sent as another sk_ key of the
same shape and put back on the way home. With Mask secrets on, a key went
as {{API_KEY_xxxxxxxx}}, which a tool's check of the key's form fails
and a model may remark on.
Settings › Privacy has "Keep a key's form" under Mask secrets (shown only
while secrets are masked; off by default, so nothing changes for anyone
who doesn't turn it on). settings.RedactShape → redact.Options.Shape;
api.go keeps it when a page from before doesn't send it.
How (internal/redact/shape.go):
- Only a secret's kind, 16+ characters, all of [A-Za-z0-9-_.]. Personal
data, the user's words and anything else still go as placeholders. A
made-up key needs no JSON escaping.
- Prefix kept (sk-proj-, sk-ant-api03-, github_pat_, AKIA/ASIA, or up to
4 letters plus - or _), same length, separators in place, and each
other character a random one of the same class. A hex key stays hex
of its case. Random from HMAC(placeholder key, kind+value), so it is
the same every turn and a vendor's prompt cache still matches.
- Kept in values like a placeholder (makeRoom shared with placeholder),
so masking records, Value(), signed-thinking re-masking (the put
closure) and known-value re-masking work unchanged; kindOf reads it.
- restore() puts made-up keys back first, then placeholders.
RestoreJSON no longer returns early when one is in the body;
hasShapes copies nothing while none was made.
- A stream holds an event's end that may start a made-up key
(partialTail → shapeTail), but never one inside a key that has come
whole: a key ending in "s" is also the start of every sk_ key, and
without that its end was held and the key went out unrestored (found
as 1 in ~40 fresh processes; 0 of 150 after).
- apply() leaves a made-up key that came back unrestored alone
(outsideShapes), as it does a placeholder.
Tests: shape_test.go — form kept (the reporter's key, hex, ghp_,
sk-proj-), same fake twice, Restore; off is placeholders; email/short/
odd values not shaped; MaskJSON then RestoreJSON with escaped tool
args; signed thinking re-masked to the same fake; no re-mask of a fake;
a stream split mid-key, after one character, and a key ending as one
starts. GUI: redact-shape.test.cjs (both engines, 5 languages, 1100 and
640px; row under Mask secrets, Off by default, one save with the rest
kept, no scroll, a later save keeps it; no row while secrets are off).
redact-words-any-case now finds Mask personal data by place after the
new row, not by index.
Broken by hand, each red: no restoreShapes (KeepsForm, JSON, Stream),
no shapeTail (Stream), no outsideShapes (JSON), no hasShapes (JSON),
put ignoring Shape (all three), shapeTail without the whole-key bound
(Stream).
Budgets: app.js 1,321,994 → 1,322,289 and the core 1,529,542 →
1,529,837, the row's 295 bytes, Settings' own row, no room added.
Doc: docs/subsystems/gateway-routing.md, a bullet beside the other
masking options.
Run at
|
||
|
|
2dfaf75539 |
redact: a masked body is held at its size, not in a buffer grown by doubling (#3383)
With masking on, the masked body is what a request holds while it
streams (MaskJSON, 285 MB live in the report's heap). walk built it in a
bytes.Buffer grown by doubling, up to twice the body. It now makes room
for the body and a sixteenth at the first value it masks, and copies the
result to its size when placeholders grew it past an eighth spare.
Run:
- the heap probe, 8 requests of 9.7 MB held mid-stream with Privacy
masking on: 138 MB before, 86 MB after (Anthropic to Anthropic);
translated to Chat 235 MB before, 183 MB after.
- TestMaskedBodyHeldAtItsSize: green; red with both changes off
("the masked body of 4356589 bytes is held in 7077888").
- go test ./internal/redact/ ./internal/masking/ ok; gateway -run
'Mask|Redact|…' ok (see the commit before).
|
||
|
|
9b57261b62 |
masking: a record keeps its request as sent, how long masking took and what the answer put back
For the 观测 › 脱敏 page's request view. In memory only: the masked body of the latest 100 requests (each up to 4MB, 64MB in all), and by placeholder how many places of the answer had the value put back (redact.Writer.Put, counted once per place even when a stream splits the placeholder). Took (µs) is written to disk too; it holds nothing of the request. GET /api/masking/sent?key= gives the body, POST /api/masking/values the values the masker still remembers, both no-store. Run: go test ./internal/maskrec ./internal/redact ./internal/gui -run TestMaskingRecordsAPI and ./internal/gateway -run TestMasked; ok. Broken by hand: without toldBack, TestMaskedRecordKeepsSentAndBack is red. |
||
|
|
50f52b540b |
redact: a text masked for a vendor before is masked as it was then, so a cached prompt stays cached
With Privacy masking on, a value masked once is "known" and masked
wherever a later request has it (redact/known.go). When a rule first
finds a value in a later turn (a tool printing DB_PASSWORD=...), that
value was masked from then on in the system prompt and the turns already
sent with it as written. The prefix the vendor had cached changed, so
the whole prompt was written to the cache again and none of it was read.
Reported by audie on Discord: DeepSeek Harness on a routing group served
by a custom Anthropic-compatible provider. Adjacent turns 10s apart had
cache_read 0 and cache_write 412K to 427K.
Fix: Mask and MaskJSON (the vendor-bound paths, via masking.Masker) now
use sentKnownSpans. A text masked before gets the known values it had
the first time, keyed by a sha256 of the text and the options. Only
hashes and spans are kept, never a value, in two generations of 65536.
New text still gets every known value masked. Scrub (archives, sessions,
OTel; local only) keeps the latest known set.
Unchanged: if magpie restarts, or a text falls out of both generations,
the text is masked under the current known set once, as before.
What was run:
- internal/redact TestSentTextKeepsItsMasking and internal/gateway
TestMaskedConversationKeepsItsCachedPrefix. The gateway test sends a
dsh-shaped Chat Completions conversation to a group with an Anthropic
member, and a Claude Code-shaped /v1/messages one. It checks that each
turn's system, tools and earlier messages reach the fake upstream byte
for byte. Both tests are red with sentKnownSpans forced back to
knownSpans: the system prompt became "{{SECRET_...}}" on turn 3. Both
are green with the fix.
- With masking off, a probe of the same dsh shape had the system, tools
and earlier turns byte-identical on every turn.
- gofmt -l: clean. go vet: darwin, GOOS=linux -tags nogui ./...,
GOOS=windows ./...: clean.
- Full suite at 8187919d7 (this tree, on origin/main
|
||
|
|
243594410d |
redact: a tool call's arguments stay JSON when a value follows an escape (#3022)
A history tool call's function.arguments is JSON text inside a string.
MaskJSON masked it as plain text, so the n of a \n started a match:
"\n@mcp.tool()" became "\{{EMAIL_…}}()", the arguments were no longer
JSON, and Ollama Cloud refused every turn that replayed the call with
400 "invalid tool call arguments". Reported by xiaobaifly7 and reproduced
independently by Shane-Meng (\n\n\n@pytest.mark…).
Where a string holds JSON text (asJSON), mask now reads it the way the
vendor reads it once it is unescaped:
- unescapedView: a same-length view in which \n, \r, \t, \b and \f read
as control characters and a \u escape reads as line breaks, so no word
starts or ends on an escape's letter. \" \\ \/ stay as written, so the
SECRET rule's \"-aware quote and Windows paths read as before.
- outsideEscapes: any span (rule, word, model, known) that starts or
ends inside an escape is cut back to the escape's edges, so the JSON
holds and what the span held is still masked. A span left empty is
dropped.
- unescapedPut: the value kept for Restore is the unescaped one, so
Restore (which escapes it again in arguments) gives the agent exactly
what it wrote. Before this, a private key's \n came back as \\n.
Ported from ggbdpq's hunt53-f-redact-json-escape. Their test
TestMaskJSONKeepsArgumentsJSON is kept verbatim. Their guard alone let
"\njo@quill.dev" through unmasked, so this port also adds the view, the
trimming and the restore.
Run at base
|
||
|
|
b00c82acfa |
masking: each kind is masked, sent with a warning or held back; a Never mask list and Try it (#1977)
Settings › Privacy gets two sections under What to mask:
- When a value is found: Mask, Warn or Block per kind (redactActions;
a kind left out is masked). Warn sends the value as written and records
it with a placeholder nobody remembers, not counted as masked. Block
masks it as before and the gateway answers 400 naming the kind and the
value's hint, never the value, with nothing sent (maskBlocked); the
record is kept as Blocked. The secret kinds come first, the personal
ones behind Show all kinds. A Never mask list (redactAllow) lets a whole
value go as written in any case; a longer value it is part of is masked.
- Try it: POST /api/masking/preview masks a text as a request would
(redact.Preview) and remembers nothing: no placeholder stands for it
afterwards and its values aren't masked later as seen before. The page
shows the vendor's text, what was found and what would be done, and
keeps the text in no storage.
The masking card counts requests held back and values sent as written; a
call whose values only went as written gets an amber badge on Recent calls
and the Routing log. zh, zh-TW, ja and de throughout. Docs: gateway-routing
and gui-shell.
Broken by hand: the new GUI badge assertion fails on the old maskedBadge
(no .warn badge drawn); TestSettingsSaveKeepsWhatItDoesNotSend went red
until the two settings were in its fixture; "{n} held back" turned
i18n-keys red against the routing plugin's "{n} held" and was renamed.
Run at this tree (base origin/main
|
||
|
|
d3db461bbb |
redact: the local model's secrets leave UUIDs, digests and paths, and client_metadata goes as written
The owner's masking records showed Codex's turn metadata with every id as
{{SECRET_…}}: installation_id, session_id, turn_id, window_id,
context_window_id, root_turn_id, and a skill's file path in the
instructions. The local model (OpenAI's Privacy Filter) labels a UUID a
secret: run on Codex's x-codex-turn-metadata it took each id, and on a
log it took a request id and "sha256 9b74…". The vendor and magpie's own
sessions match a turn by those ids, so masking them can break what
depends on them, and hides nothing worth hiding.
- modelTakes: a secret the model finds is not taken when it names a
thing (namesThing): a UUID, with window_id's ":0" after it too; a
digest with its algorithm's name; a file's path. A password or a key
it finds is still masked, and the rules' secrets (sk-…, password=…,
API_KEY: …) are unchanged.
- client_metadata is in defKeys: the client's ids, which no model
reads, go as written, as tools and stream_options do.
docs/subsystems/gateway-routing.md says both.
TestModelSecretIsNoID uses what the real model labelled "secret" on these
texts (pf-serve with the q8 model, run here): the UUIDs, the request id,
the sha256 digest, plus the reporter's path; the password and the
32-hex key beside them are still masked. Broken by hand: without
namesThing 5 values are masked, without client_metadata in defKeys a
user word in it is.
Run:
- At 3fff6c011 (on origin/main
|
||
|
|
88119d4f67 |
redact: Codex's tool server names, stream_options and snake_case words go as written (#3143, #3144)
Two reports from hibaliqya-yonma (v0.1.1306, Codex Desktop through
/backend-api/codex), each a 400 on every request until masking was
turned down:
- #3143: a user's word that is part of an MCP server's name went into a
Responses function_call's namespace as mcp__{{TERM_…}}. Codex checks a
namespace against ^[a-zA-Z0-9_-]+$, and the call is replayed every
turn. namespace is kept as name is, and so are the server's name in
its siblings: a Responses mcp_call's server_label, Anthropic's
mcp_tool_use server_name.
- #3144: the local model took stream_options.reasoning_summary_delivery,
"sequential_cutoff", for a name. stream_options is a request setting
now (defKeys, with reasoning and text), and the model's name is never
a snake_case word (snakeWord), wherever it is, so an enum or an
identifier in a tool's arguments or in code is not taken either.
The same word in the user's own message is still masked, and a name
beside it still is. docs/subsystems/gateway-routing.md says both.
Tests from the reporter's bodies: TestMaskJSONKeepsReasoningSummaryDelivery,
TestMaskJSONKeepsToolServerNames (namespace, server_label, server_name),
TestModelTakesNoSnakeWord. Broken by hand: with json.go and model.go as
on main, all three fail; with the change they pass.
Run at this head (origin/main
|
||
|
|
f21dd99f5a |
privacy: every masking is recorded, and Settings › Privacy shows it
What was masked is now kept, so the user can see it. Settings › Privacy opens on a summary card: how many values were kept from vendors over 1, 7 or 30 days, by kind, by finder (rules, your words, the local model, known values) and by where they went, with a day strip. The page is grouped into What to mask, How it's found (rules and the local model are layers, not a toggle: the model adds names and addresses rules can't see) and Sharing. A records view lists each masked request: its kinds, finders, placeholders and, while magpie runs, the line around each value. Gateway › Recent calls and the Routing log carry a masked-N badge that opens the record. Originals never go to disk. internal/maskrec writes day files under ~/.config/magpie/masking (0600, 30 days, 100MB at most) holding kinds, finders, placeholders, a first character or key prefix and a length. The lines around values are kept in memory for the last 400 records only, and /api/masking/value answers only while the masker remembers a placeholder. Nothing is written under MAGPIE_TEST_SANDBOX. A masker says what it masked through gwmw.Teller (JSONHits, TextHits, Value); a plugin masker that doesn't is counted only, so older redact plugins keep working. Every route that masks notes it: chat, Responses, Codex backend and search, embeddings, images, video, transcription, decide and the search MCP query. Masking still fails closed: a masker that panics on any path refuses the request (TestMaskingOnAndOff's fake now panics on JSONHits and TextHits too, since the gateway asks a Teller through those). app.js grows to 1,314,432 bytes, so its budget rises to 1,335,000 and the core's to 1,528,800 (+1.5%): Settings is the core's own page. Run at this head (rebased on origin/main |
||
|
|
c0dad80da1 |
redact, pii: a local model finds what the masking rules can't (#1977)
WIP on pf/serve, recovered after the scratchpad holding it was wiped. internal/pii downloads OpenAI's Privacy Filter (q8 GGUF, sha256 pinned) and pf-serve, runs it on the GPU first, and answers redact's Model; settings.RedactModel turns it on, per computer. Off by default. Run: go vet and go test -race on internal/redact, pii, source, settings (all ok). Not yet released: pf-serve's serveSHA is empty until pf-v1 is tagged. |
||
|
|
62390fe92e |
redact: a masked word is never masked inside tool definitions or schemas, so Codex's apply_patch grammar reaches OpenAI intact (#1911, loveNangua)
What changed: MaskJSON masked custom words as raw substrings in every
string of the request, tool definitions included. A word "pd" turned
apply_patch's Lark rule name update_hunk into u{{TERM_..}}ate_hunk and
OpenAI refused the request with 400 "Invalid lark grammar". Definitions
are now kept by where they sit in the protocol, not by a key's name:
the request's top-level tools, tool_choice, functions, function_call,
toolConfig/tool_config, response_format, text (an object), reasoning,
include, output_format, output_config and generationConfig, and the
tools of a Responses input item of type additional_tools or
tool_search_output. Inside them only "description" strings are still
masked. A "tools" or "text" key in tool-call arguments, a message, a
Gemini part or a Responses message item is masked as before.
Run: go test ./internal/redact/ ./internal/provider/ (ok). The new
tests use Codex 0.162.1's real request (copied from the gateway's
testdata) with the top-level tools and as a Responses Lite
additional_tools item, plus Anthropic/Chat/Responses/Gemini schema
cases and negative cases. With the old json.go both tests fail
(update_hunk masked, every schema case changed). gofmt -l clean; go vet
-tags nogui on darwin, linux and windows. Not tried: a real request to
OpenAI with the word set.
|
||
|
|
3c7473eb3f |
redact: a value masked once is masked again wherever a request has it, whatever words are around it
The masking rules find a value by what is around it: DB_PASSWORD= before
a password, a bound an email may not touch (so an email that ends a
sentence isn't one). The vendor writes about a placeholder in words of
its own ("your password is {{SECRET_…}}", "I will write to {{EMAIL_…}}."),
the agent reads the value there (Restore), and on the next turn that text
is in the history, where no rule matches it, so it went out as written.
Now every value a placeholder was made for (redact's in-memory values,
bounded by maxValues, never written anywhere) is also matched as an exact
string in each string Mask and MaskJSON look at, and goes as the same
placeholder it had (same kind, same keyed hash), so history and vendor
caches stay stable:
- only from 8 characters (the assignment rule's minimum): the 3-character
passwords the user:password@ rule takes, and the user's own words
(which Options.Words matches everywhere already), are not;
- personal values only while personal masking is on, secrets only while
secret masking is on;
- not as a piece of a longer value: a phone or card number with a digit
beside it, an email inside a longer address (a full stop after it may
end the sentence), a secret with a letter or digit against it;
- where a rule finds the same span, the rule's kind still wins, so
nothing masked before changes placeholder;
- in what a vendor signed (
|
||
|
|
1965e1f0f4 |
redact: a tool call's arguments are masked again, whatever their keys are called (7137feb4 let them out)
|
||
|
|
7137feb4fc |
redact: what a vendor wrote and checks goes back as it wrote it — signed thinking and tool call ids (Jeremy.Zhou on Discord: OpenCode Zen answered 400 "invalid …" until 脱敏密钥 and 脱敏个人信息 were off)
Masking ran its rules over every string of the request except a fixed list
of keys, including two kinds of text the vendor itself wrote and checks
when it comes back:
- A thinking block (Anthropic's signature; also Gemini's thoughtSignature
and Responses' encrypted reasoning). The vendor thinks about the
placeholders it was given, the agent gets the values back (Restore), and
on the next turn the rules masked that text again. Rules depend on
what is around a value: "the password is {{SECRET_…}}" came back as
"the password is hunter2abc1", which no rule matches without its
DB_PASSWORD=, an email ending a sentence fails the email rule's bound,
and a number the vendor wrote of its own ("13800138000") turned into a
{{PHONE_…}}. The text no longer matched its signature, and Anthropic
answers 400 "messages.1.content.0: Invalid `signature` in `thinking`
block" — and the value itself went to the vendor in the clear.
Now an object that carries a non-empty signature, thoughtSignature,
thought_signature or encrypted_content is masked only by putting back
the placeholders of the values masked elsewhere in the same request
(longest first): what the vendor wrote, its own words untouched.
- A chat tool result's tool_call_id. "id", "tool_use_id" and "call_id"
were kept, "tool_call_id" wasn't. GLM's ids are call_ and 19 digits,
and ~5% of them pass Luhn as a bank card number, so the tool message's
id became call_-{{BANK_CARD_…}} while the assistant's tool_calls id
stayed, and the upstream refused the orphaned tool result ("messages
with role 'tool' must be a response to a preceeding message with
'tool_calls'"). Now every key named id, …_id, …Id (and their plurals)
is left alone.
Account masking (账号打码) is display only and doesn't touch requests.
Tests: TestSignedThinkingGoesBackAsSigned (a fake Anthropic upstream that
signs its thinking with an HMAC and checks it, two turns through the
gateway) and TestToolCallIDsGoBackAsGiven (a fake chat upstream that
refuses a tool result with no matching call) fail on origin/main with
exactly those 400s; TestMaskJSONSignedGoesBackAsWritten (Anthropic,
Gemini thought and functionCall, Responses reasoning shapes, plus an
unsigned thinking block still masked) and TestMaskJSONKeepsIDs fail there
too. All pass with the change.
Run: gofmt -l (nothing), go vet -tags nogui ./... on darwin, GOOS=linux
and GOOS=windows, go build -tags nogui (darwin, linux, windows),
go test -tags nogui ./... under a temp HOME: all ok. Not tried against the
real OpenCode Zen, and the reporter's exact error text and model weren't
seen; both upstream checks are modeled on Anthropic's and OpenAI's
documented errors.
|
||
|
|
67c539d5da | gateway: secrets can stay on the machine — with Settings › Privacy › Mask secrets on, API keys, private keys, tokens, JWTs and the passwords of connection strings and assignments in what an agent sends go to the vendor as placeholders like {{API_KEY_k3v9x2mq}}, and what the vendor answers has them back, streams included (a placeholder split between two events is put back whole, a tool call's arguments get the value escaped); personal data (emails, phone numbers, ID and bank card numbers, checksum-checked) and the user's own words can be masked too. A placeholder is the same for the same value every time, so a conversation's history and what the vendor cached of it stay the same turn after turn, and the request log shows what the vendor saw. Suggested on X as maskit's idea; written from scratch |