Repository navigation
Opt-in redaction of credentials in everything the server returns - #312
Conversation
…#303) * Bump version to 2.3.0 2.3.0 is the release scheduled for opt-in credential redaction, built on this feature branch. Bumped first so every artefact built from the branch carries the version it will ship as. All five declaring files and the lock self-entry move together; the pin tests and preflight fail on any disagreement. * Read and report the redaction settings and the per-host redact option Adds the configuration surface opt-in credential redaction is built on. Nothing is redacted yet: the settings are read, validated and reported, and while any host is configured for redaction the server warns at startup that this build returns output unredacted, so the setting cannot be mistaken for protection before the redactor exists. DOCKER_MCP_SERVER_REDACT turns the mode on for every host, and a host in DOCKER_MCP_SERVER_HOSTS can carry a redact option instead. DOCKER_MCP_SERVER_REDACT_NAMES adds names to the built-in credential-name globs, with ! to exclude. A malformed entry stops the server, and the error gives the entry's position rather than its text, because the likeliest mistake is NAME=value and repeating it would log a credential. Host options can now go in one comma-separated bracket, (ro,redact), as well as one per bracket, and the two mix. That needs the host list split only on commas outside brackets, and the bare single-host form recognised by an = outside brackets. The second also fixes an existing bug: a bare endpoint with (tls=<dir>) failed to parse, because the = inside the bracket made the value read as a label=endpoint list. tls= takes the rest of its bracket so a directory containing a comma still parses, and so has to come last in a list. Unbalanced, nested and empty brackets, and an option bracket anywhere but the end of the endpoint, are refused at startup naming the host: left in the URL, a misplaced redact would be silently ignored. The effective settings appear in tool_list and the tool catalog switches, and per host in host_list, the hosts resource and the startup roster. settings.redacts() is the one place the global switch and a host's option are combined. Startup warns when the switch is on without READONLY, for each host marked redact without ro, and when names are set with redaction on nowhere. The built-in name globs are a judgement from the words the design names (password, passwd, secret, token, key, cert): the spike measured with a pattern it did not record. They are re-measured against real daemons once the redactor exists. A test keeps the list in REDACTION.md equal to the code's. * Report redaction warnings where the disable warnings go, and judge them per host Review of the settings slice found the redaction warnings reached stderr only. An MCP client rarely shows a server's stderr to anyone, which is why DOCKER_MCP_SERVER_DISABLE mistakes are also reported in tool_list and by a pointer at the top of the instructions. configuration_warnings() now joins the two sources and feeds all three places, and the pointer line is reworded to cover both. The global-switch warning claimed exec and the file-writing tools stayed available even when every host was ro, where per-host ro removes them as READONLY does. Warnings are now judged per redacted host, whichever way it is redacted. The interim "nothing is redacted yet" warning and the status note in REDACTION.md are tied to one flag, OUTPUT_REDACTED, and a test holds the note to it, so neither can outlive the other. Also: an unbalanced or nested bracket in a host list now names the host it is in rather than the variable; conftest clears the two new variables so a shell value cannot pin redaction on or abort collection; the hosts resource description lists the redact flag; the redaction variables move to their own README paragraph, since they do not restrict which tools are registered; and the server.py comment restating the variables becomes a pointer. * Quote only the offending entry when a host-list bracket is unbalanced An entry with no = before the bad bracket made the error quote the rest of the value, neighbouring entries included. The label is now cut at the entry's first comma.
…s command line (#304) * Pass credentials to the CLI-backed tools in its environment, never its command line Six CLI-backed tools gain `vars`: compose_up, compose_run, compose_build, stack_deploy, buildx_build and buildx_bake. It sets variables in the docker CLI's own environment, for Compose and stack `${VAR}` substitution, bake variables and a build secret's env=, none of which had a way in other than the server's own environment or a file. The values of compose_run/compose_exec `env` and buildx_build `build_args` move the same way, as a bare `--env NAME` or `--build-arg NAME` the CLI resolves from its environment, so none of them shows in any process list. Verified against compose 5.6.1, buildx 0.38.1 and docker stack 29.9: each bare form, bake variables, secret env= and stack substitution all read the CLI's environment, values with newlines, quotes and $(...) intact. Only CLI-backed tools need this: SDK-backed tools send values to the Engine API in a request body. Every tool given `vars` is a write, so READONLY drops all of them; a test holds the exact set and its absence under READONLY. A name the CLI acts on would let a caller retarget it past host pinning (DOCKER_HOST), run code in it (LD_PRELOAD, DYLD_*, GIT_SSH_COMMAND), redirect its traffic (*_PROXY) or break its credential helpers (PATH). `vars` refuses those names; `env` and `build_args` keep passing them as NAME=VALUE, since a container's PATH or HTTP_PROXY is legitimate. A name set in both `vars` and `env` with different values is refused. Errors never repeat a value. Over the SSH fallback the values travel on the channel's stdin, each byte as a \0ddd escape decoded by POSIX printf %b (base64's decode flag differs between GNU, macOS and the BSDs). The wrapper reads them in the foreground into reserved-prefix variables and assigns the caller's names only inside the subshell that execs the command: an earlier draft assigned them in the main shell, where a caller's `m` would have redirected the trap's rm -f. Checked under dash, busybox ash, bash and macOS sh, including a value named `m`. Adding six parameters costs 1,296 bytes on every session after trimming the descriptions; the tool ceiling, which had 398 bytes left, the total and buildx_build's per-tool ceiling are raised with the usual two per cent. * Check the remote process list without the probe matching its own pattern The first version grepped the far host's process list for the value's text, and that text was in the probe's own `sh -c` script, so every process carrying the script (the wrapper, its shell, the probe) matched: four hits on a real host with no value exposed. The pattern is now written `s3[ ]cret`, which matches the value but not itself, matching lines are printed so a failure names them, and a control test puts the value on a command line deliberately and requires the same check to find it. Both pass against a real ssh:// host. * Keep shell-special names off the remote path, and say where values still show Review found that bash running as `sh`, the default /bin/sh on the Fedora family and macOS, makes UID, EUID and PPID read-only and ends a POSIX-mode script on a failed assignment, so `vars={"UID": ...}` or `env={"UID": ...}` worked through a local CLI and returned "UID: readonly variable" over the SSH fallback; RANDOM, SECONDS and the like were silently replaced by the shell's own values. Confirmed with `bash --posix` and Fedora's `sh`; dash and busybox accept the assignment, which is why the shell tests, running bash as itself, missed it. Such names now take the same route as a dotted name: refused in `vars`, passed on the command line by `env`/`build_args`, on both backends so local and remote agree. The shell test matrix adds `bash --posix` and Fedora's `sh`. The reserved list gains BASH_ENV and ENV, which run code in any shell script the CLI starts, and XDG_CONFIG_HOME, which moves git's config; it is described as a best-effort denylist. The tool descriptions and README now name every kind of name whose value still reaches the command line; the README describes the reserved categories and points at the function instead of copying a list that had already drifted; a test holds the docs' list of `vars` tools to the code's. compose_exec gains a real-CLI integration test. A test that could not fail is removed, and recorded state in comments and the architecture note becomes references to the tests that hold it. * Sort the _ssh_proxy imports in _cli.py
…d matcher (#305) * Add pyahocorasick, and declare cryptography, for the redaction core The redactor has to find every stored value's encoded forms in each result in one pass. Measured with the forms the design lists, Python's re cannot: 500 values (3,500 literal alternatives) took 3.2 s to scan 120 KB and 24 s for 1 MB, and 5,000 values did not finish. Aho-Corasick scans 1 MB in 72 ms at 5,000 values and 189 ms at 100,000. pyahocorasick was chosen over ahocorasick_rs, which matches about twice as fast, for its wider wheel set (musllinux and universal2 macOS for 3.14), its more recent release, and needing only a C compiler if a wheel is ever missing. The floor is the release verified to provide Automaton.iter_long. cryptography was transitive through paramiko; the markers now import it for AES, so it is declared, deliberately without a bound, as AGENTS.md records for this package. Each gets a guard test for the API the code relies on in place of a cap. * Build the redaction core: value store, markers, forms, shape rules and matcher Nothing calls it yet; the change that wraps tool and resource output does. The store holds each redacted value once per host, harvested or discovered, with every limit as a named constant: discovered values matched up to 16 KB and stored up to 100,000 or 64 MB, then redacted but not stored, logged once per host; a 256 MB overall budget that refuses every call once a harvested value would pass it. Values sit in a type that never prints and refuses to be pickled. Nothing is evicted. A marker is one AES block under a per-process key holding the value's identifier, form, host, a 5-byte counter and a check field, so two markers for one credential are unrelated and an unstored value's marker looks like any other. An altered marker and one from an earlier process cannot be told apart; both fail the check field, and the refusal says so. Forms cover raw, base64 (standard and URL-safe, whole and inside a blob at every alignment), base32, hex and URL-encoding. Writing the tests found two bugs in the first draft: trailing padding agreed between the two encodings used to find a blob-independent core, stretching the core over neighbour bits, and padding counted towards the minimum form length. The shape rules follow the list in the redaction design, plus the credential-named flag rule, including where Docker reports a command as a list, which a check against a real container showed the text rule alone missed. An intermittent test failure turned out to be a product defect: the generic rule treated any run containing `//` as a path, which random base64 does about one time in five at 800 characters. The MCP SDK runs sync tools on worker threads concurrently (four calls on four threads, checked), so the store and counter take locks and the matcher swaps in a new index whole. The matcher adds new forms to a small automaton and merges into the large one at a quarter of its size, since a full rebuild takes 19 s at 100,000 values. Running out of identifiers or counter starts a new generation; a redaction caught by that is refused rather than finished against the empty store, where an unmatched value would come back unredacted. * Fix the redaction core's concurrency, overlap and performance faults found in review Concurrency: a value is indexed outside the store's lock, and a second add of the same value returned before the first had indexed it, so a concurrent call could redact against an index without it and return it in clear. A second add now waits until the value is indexed, a value that fails to index is removed again, and checking for and storing a value happen in one locked block: splitting them, as the first fix did, let the concurrency test store one value twice. Overlaps: the redactor kept the longer of two overlapping spans, leaving the head of the other in the text, and the matcher's longest-match iteration never reported the tail of a value overlapping an earlier one. The matcher now reports every match and the redactor replaces each overlapping cluster whole, as one discovered value where no single span covers it. Performance: the assignment and URL rules opened with an unanchored repeated class, so `re` re-scanned a long run from every position: 48 s for one 50 KB base64 line, measured. They now start only where a run starts and repeat possessively; the same input takes 10 ms. The matcher rebuilt its whole small automaton on every add, quadratic overall; it is now size-tiered levels merged at a ratio of four, about log4(n) rebuilds per form, and adding nothing new rebuilds nothing. Errors: the budget refusal is a ToolRefusalError and a rotation a new RedactionResetError, both with messages, so the wiring cannot turn them into a bare "Error executing tool". A rotation while storing is now refused too, since the values stored before it are gone. Also: the cryptography guard test is dropped, as AGENTS.md's settled entry says not to assert it in CI, and that entry is corrected to say it is now direct; a redundant credential-word set that bypassed `!` exclusions is gone; a test holds REDACTION.md's limits table to the constants; recorded figures and fix history are out of the prose. * Close the remaining gaps in the redaction core's concurrency and name matching A call waiting on another's indexing of the same value returned that value's entry even when the indexing had failed and rolled it back, so it reported a value neither stored nor indexed. It now re-checks after the wait and stores the value itself if it is gone. The rollback now undoes the accounting of whatever is stored at that point, since a concurrent harvested add may have promoted the entry meanwhile. The look-behind added to make the assignment rule linear stopped it matching a name after a digit: `2FA_SECRET=<random>` was missed. The name is now the whole run, digits included, which the `*WORD*` credential globs still match, and the scan stays linear. The pyahocorasick guard and its pyproject comment now describe what the matcher relies on, `Automaton.iter` reporting overlapping matches, rather than `iter_long`, which it no longer uses. The linear-time test compares two input sizes instead of asserting a wall-clock bound, and stale prose and list numbering in the architecture note are corrected.
* Redact tool, resource and error output from redacted hosts, with a fresh harvest Every registered tool and resource is now wrapped, outermost and outside the failure translation, so results, resource bodies and error text from a redacted host are redacted. Each call is judged by the host it reaches: a tool by its host argument or the default host, a resource by the host in its URI or the default host. An unfiltered host's output passes through untouched. Tools that reach no daemon are listed, and a test holds the list to the registered tools without a host argument; resources must declare their scope when registered. The harvest reads credential-named values from container, image and service environments, image history build arguments, credential-named Swarm configs and a Compose project's .env. It stays fresh with a bounded events query per call rather than a background thread, re-harvesting only on the events that can bring a new value (a container created; an image pulled, loaded, imported, tagged or built; a service created or updated; a config created): harvesting on every container event cost a full harvest per call, because a running container emits exec, attach and health events. The query's `until` must not be in the future, or the daemon holds it open until then, which cost every call a second; measured against Docker Desktop, a redacted call now costs about 10 ms over an unfiltered one after a first harvest of about 1 s. A harvested value under eight characters is matched only as a whole token, so `pw` is not replaced inside `pwd`, where the context would give it away. Under the global switch container_archive_get is not registered and container_export and image_save advertise dest_path as required; on a redacted host their in-band forms are refused. host_list reports each redacted host's store state; the instructions say markers are valid only as tool arguments in this session; core dumps are switched off at startup while redaction is on. The interim "not redacting yet" warning and status note go. * Point the instructions at host_list for redaction, and tighten the CLI caveat The redaction rules differ per host: whether output is redacted, and whether files written to disk escape it, depend on the host's redact and read-only options as well as the global switches. Spelling that out in the server instructions pushed the worst case past the 2048 UTF-16 units Claude Code keeps, which it truncates silently, and every later addition would have to evict something else. The instructions now carry one pointer line, only when some host is redacted, and host_list carries a "redaction" entry per redacted host with the notes that apply to it and the value store's state. The note about files on disk is left out for a read-only host, where no tool writes one. The CLI caveat says the same in fewer words, which brings the longest rendering to 2043 units. _prepare's propagated-exception marker now sits on a documented Raises section, as the docstring guard test requires: the marker suppresses only pydoclint's inability to resolve error_cls to a type. * Keep the harvest fresh by ID snapshots, and close the gaps review found The harvest no longer depends on the daemon's event history. moby keeps only the last 256 events (eventsLimit in daemon/events/events.go), and a host running a few healthchecked containers emits that many in minutes, so a container's `create` could fall out of the window between two calls and its credentials go out unredacted. The window was also judged by the daemon's clock against this server's, so skew either opened the same gap or held every call open until the daemon caught up. Each call now compares a snapshot of container, image, service-version and config IDs with the last one and harvests again when it differs; the snapshot is taken before harvesting, so an object created in between is seen as a change next time rather than counted as harvested. Against Docker Desktop with 108 images this costs about 34 ms per redacted call, against about 9 ms for the events query; most of it is the image listing. A result naming an ID the snapshot has not seen now prompts one snapshot comparison, once per ID, rather than a full harvest every time: network and plugin IDs and removed containers' IDs look the same. A harvest failure was raised raw, outside the failure translation, so it reached the client as a bare crash, and system_reconnect could not recover a redacted host whose client was wedged. A library failure in the harvest now refuses the call with the daemon's own message (output that might hold an unread value is never returned), the connection- control tools run no harvest, and containers or images removed while the harvest runs are skipped rather than failing it. A short harvested value counted as a whole word only between a fixed list of characters, so it escaped in `[pw]`, `pw.` or `user@pw`; any non-word character now bounds it. The Compose `.env` reader follows Compose's own rules for quotes and inline comments, and reads the file beside the first compose file when files are named. The host_list notes are built from BYTE_TOOLS and the new FILE_TOOLS, naming only tools registered and allowed on that host, and tests hold the REDACTION.md lists to both and to NO_DAEMON_TOOLS. The marker note and REDACTION.md now say plainly that markers passed to a tool are not swapped back yet. The interim OUTPUT_REDACTED flag, its warning, tests and architecture paragraph are gone, and architecture/server.md describes the redaction wrapper outside the failure translation. * Follow Compose's .env quoting, bound the checked IDs, and state limits as they stand The .env reader now applies compose-go's dotenv rules as its parser does: a backslash before the closing quote escapes it in either quote style, any other backslash is kept, an unquoted value ends at " #" only, and an unterminated quoted value yields nothing, since Compose refuses the file. Previously `KEY="a\"b"` was harvested as `a\`, so the real value went unredacted. Escape-sequence expansion in double quotes, variable interpolation and multi-line values are not followed, and REDACTION.md says so. The IDs a result names that are not containers or services were kept for the life of the process. They are external input, so they are now forgotten whenever the snapshot changes and capped at 10,000 between changes; forgetting one costs only a repeated snapshot comparison. The docs and the host_list note describe the marker limitation as it is today, without "yet" or "until", and the architecture note keeps the reason not to use the daemon's event history without the history of the design or another project's constant. The host_list paragraph in REDACTION.md had become ungrammatical and is a plain list again. * Hold the checked-ID set to its bound for any one result, and rewrap REDACTION.md The set was cleared when an addition would pass the bound, but then took every unseen ID, so one result naming more than the bound left it above it until the next snapshot change. IDs beyond the bound are now left unrecorded and simply checked again later. Two REDACTION.md lines that ran past the paragraph width are rewrapped.
…t cannot be (#308) * Swap markers in writes back for their values, and refuse the ones that cannot be An agent copies what it reads into writes: Env from container_inspect into container_create, a marker into a psql command. Without swapping back, the container starts with a literal marker as its password and fails somewhere unrelated. Before a tool that is not read-only runs, every marker in its arguments is now resolved: on a redacted host that accepts writes, one this process issued for that host becomes exactly the text it replaced, in its encoded form where that was replaced; any other marker refuses the whole call before it runs, naming the argument and the reason. On an unfiltered host every marker is refused, since none was issued for it and a production marker must not be swapped in there. A read-only host is left to the host guard, whose message says why. The guardrail refuses markers in names, labels, build arguments and bake overrides, where a credential is never legitimate and would spread to listings, image metadata or a command line. A table classifies every text argument of every write tool, and a test fails for one left out, so a new argument cannot take a marker without a decision. Files are never swapped back: a marker in one means nothing to Docker or to a later process, and rewriting a user's file or an archive member is not this server's place. So the files a write reads are searched first and the call refused on a match, naming the file: the Compose project directory, a stack's or bake's directory and a build context (with .dockerignore honoured), which are what the SSH fallback copies for the same calls, with the fallback's limits. The cost was measured at about 3 s for 8,900 files and 103 MiB with no marker, on the first read. Archives for container_archive_put are searched as bytes, naming the member; a compressed one is refused, with one step per compression so a streaming search can be added later. Marker tokens are now read only in the spelling issue writes. 22 base64 characters carry 4 spare bits that the decoder ignores, so an altered last character could read back as the original marker; a test found it while checking that an altered marker is refused. host_list's notes now tell an agent on a writable redacted host that it can pass a marker to a write and must never put one in a file; a read-only host keeps the note that markers are not swapped back. * Cap the file search on bytes read, guard nested network names, and refuse markers in login to a read-only host The byte limit was charged from the size a file reports, so a procfs file (size 0, endless content) or a log growing during the read was read without bound; a Compose call with no project_dir under a systemd unit, whose working directory is /, would walk into /proc. Bytes are now charged as they are read, and the limits are held equal to the SSH fallback's staging limits by a test rather than by a comment. The nested guardrail keys were a hand-copied subset of the refused arguments and had already missed `network` and `networks`, so a marker in extra_kwargs could be swapped into a network name. They are now derived from the refused arguments, with the Engine spec's capitalised forms, and a test holds the relationship. A read-only host was skipped for the host guard to refuse, but the guard exempts connection control, so system_login to a read-only host sent a literal marker as the password. Only writes the guard refuses are skipped now; anything else on a read-only host has its markers refused, since such a host never swaps one back. Also: os.path.expanduser in place of pathlib's, which raises a bare RuntimeError for an unknown ~user; an absolute Dockerfile inside the context made relative before exclusion, as docker-py does, so a .dockerignore'd Dockerfile is still searched; and the documentation now states the directories searched as the ones the CLI resolves relative paths against, which differ from what the fallback stages for Compose and stacks. * Read a ~ Dockerfile as docker-py does, and test the nested keys that can drift docker-py's process_dockerfile treats `~/Dockerfile` as relative to the context and never expands it, and image_build does not either. Expanding it named a different file whenever the home directory held the context, so a .dockerignore'd Dockerfile docker-py reads went unsearched; the new test fails without this change. The test of the nested guardrail keys was true by construction, since they are derived from the argument table. It now pins the parts that can drift: the docker-py keys with no top-level argument and the Engine spec's capitalised forms. Also rewords and rewraps the search-limits sentence in REDACTION.md. * Refuse markers bound for the docker CLI's command line in the CLI-backed tools A swapped-back value in a CLI-backed tool's argument lands on the docker CLI's command line, where other users of the machine, or of the remote host under the SSH fallback, can read it in the process list. Bake overrides were refused for exactly that reason while compose_exec's and compose_run's `command` were swapped back onto the same command line. A secure route always exists, since `vars` and `env` reach the CLI through its environment, so a credential is refused anywhere else. In the Compose, stack and buildx tools a marker is now swapped back only in `vars`, and in an `env` value whose name the CLI's environment can carry; everything else, `command` and `env` names that _cli.values_by_name passes as `--env NAME=VALUE` (reserved or not a plain shell name) included, is refused with a pointer to `env` and `vars`. server.tool() marks the CLI-backed domains, and a test calls the registered compose_exec to hold that wiring; it fails without it. Checked against Docker Desktop through an MCP client: a marker in compose_exec's `env` reached the container as the real value (by its md5 sum), and one in its command or under a DOCKER_ name was refused. * Swap markers back in container labels, and spell out the routes for an env name the CLI cannot carry The guardrail exists to stop a credential leaking beyond the host, never to stop it reaching where a container needs it. Labels were refused everywhere, but some containers read a credential from their own labels (a Traefik or caddy-docker-proxy basic-auth label), and a container's, service's, network's or volume's labels stay on the host. Only image metadata leaks: the labels image_build and buildx_build give an image, annotations, container_commit's message and author and the labels in its `conf`, which image_push publishes. Those stay refused, as IMAGE_LABEL; every other label, including inside extra_kwargs and updates, is swapped back. An `env` name the docker CLI's environment cannot carry (reserved, such as GIT_*, or not a plain shell name, such as app.password) goes on the command line, so a marker in it stays refused, but the refusal now names the variable and gives two routes that set it inside the container from a plain name: `env` VALUE with `sh -c 'exec env "NAME=$VALUE" <command>'`, and `vars` VALUE with `NAME: ${VALUE}` in the compose file. `exec env` is used rather than a shell assignment because a dotted name is not a valid one. Both routes were run against Docker Desktop through an MCP client for GIT_TOKEN and app.password: compose_exec with the env route, and compose_run and compose_up with the vars route, each setting the variable to the real value (checked by md5 sum). A container label holding a marker was stored as the real value, and an image label was refused. * Rewrap the architecture note's swap.py and checklist passages, and name ENV_NAME there Lines edited in this branch ran past the file's wrap width. The swap.py summary now also names the ENV_NAME refusal, which carries the routes that set such a variable inside the container.
…nd cut its false replacements (#309) * Offer redaction in the install dialogs, warn and link wherever it is mentioned, and record what it misses The .mcpb bundle and the Claude Code plugin gain `Redact credentials` and `Redacted variable names`, passed as DOCKER_MCP_SERVER_REDACT and DOCKER_MCP_SERVER_REDACT_NAMES, and the host setting mentions `(redact)`. Their descriptions carry the warning that redaction reduces accidental exposure and is not access control, with an absolute link to REDACTION.md, because the dialogs render outside the repository. Unset, they reach the server as "false" and "", which leave redaction off and raise no warning; checked by starting the server with those values. SECURITY.md, DOCKERHUB.md (absolute link), MCP_VS_SKILLS.md (as something only the server can do), the switches comment in server.py and architecture/server.md now carry the same warning and link. tests/test_docs.py holds every listed mention to the warning and the link, the two settings files to the absolute URL, and fails on a new mention in a shipped document that is not listed. REDACTION.md gains what the mode misses and what it replaces by mistake, measured by planting credentials and decoys on Docker Desktop and on a Docker 26.1 daemon with Swarm and comparing a redacted host's output with an unfiltered one on the same daemon. It also says that markers change on every read and that an agent cannot tell two credentials match, which can look like a misconfiguration in triage. * Leave public keys and absolute paths alone, which were most of the false replacements on real content Planting decoys on Docker Desktop and comparing a redacted host's output with an unfiltered one on the same daemon found nine false replacements on real content and one decoy, all public or not secret: the signing-key fingerprints official images publish in GPG_KEY, certificate paths in SSL_CERT_FILE and DOCKER_TLS_CERTDIR, and an SSH public key. A value read under a credential name is replaced wherever it appears, so a path was also lost from mounts and commands. - Names whose values are public are left alone by default: *PUBLIC_KEY*, *PUBKEY*, *_PUB_KEY*, GPG_KEY and GPG_KEYS. GPG is matched exactly, so GPG_KEY_PASSPHRASE is still harvested. A name the names setting adds overrides these; its `!` entries still win over everything. - A value under a credential name that is an absolute path (path characters only, from / or ~/) is not harvested: it says where a credential is, as SSL_CERT_FILE or POSTGRES_PASSWORD_FILE do. - The generic shape rule skips the body of an OpenSSH public key and the inside of a PEM public key or certificate block. The PEM rule still catches a private key, and a random run beside a public key is still found. Re-measured on Docker Desktop after the change: no false replacements on real content, two of seven decoys (SORT_KEY by name, a subresource-integrity hash by shape), and every planted credential caught as before except the word-like secret in a file, which the design accepts. * Match known IDs by prefix index, and state what redaction costs, measured on a large daemon On a throwaway daemon of 2,000 containers and 501 images, the check of which IDs a result names took 120 ms for a full container list: each mentioned ID was compared with every known one by prefix. The known IDs are now indexed by their first 12 characters, the shortest Docker abbreviates to, which brings the check to under a millisecond. REDACTION.md gains what the mode costs, measured on that daemon and on Docker Desktop with the same script, redacted against unfiltered on the same daemon (medians of 15 calls): - first call to a host: about 2 s on Desktop, 12.5 s on the large daemon; - every call: about 40 ms and 140 ms, for the snapshot that keeps the harvest fresh, which lists every container and image; - redacting a result: about 1.3 ms per KB of output, so container_list of 2,000 containers (1.4 MB) takes about 1.7 s more than unfiltered. The redaction walk is the largest cost on big results; the snapshot is the cost on every call. * Treat a path after a credential flag as a path, commit the measurement script, and order the settings - The absolute-path rule now covers the flag rule too, in text and in exec-form lists: a value after `--password-file`, `--tlscert` or `--tlskey` that is an absolute path is where a credential is, and taken as one it was stored and replaced in every mount and command on the host. `rules.is_absolute_path` is the one test, used by the harvest and the flag rule alike. - The public-key exclusions are anchored at the end (`*PUBLIC_KEY`, `*PUBKEY`, `*_PUB_KEY`), so a credential word after the public-key one (`SIGNING_PUB_KEY_PASSWORD`) is still harvested. - scripts/measure-redaction.py regenerates the figures REDACTION.md quotes: `sweep` plants credentials and decoys and compares a redacted host with an unfiltered one on the same daemon; `cost` times calls on a daemon filled with containers and images. Both use a throwaway dind daemon unless given --docker-host, report only, and never print a replaced value. REDACTION.md's two measured sections now say how the cost grows and what is missed as rules, point to the script for the figures, and say the figures move with the code; the history of earlier measurements is in the commit messages. - The unwarned-mention scan covers every markdown file under claude-plugin/ and skills/, which ship. - The prefix-index test uses random IDs and asserts one ID per bucket, so it fails if the index degrades to a scan; the measured figure is out of the code comment. - The redaction settings come after the three settings that decide which tools register, in the bundle, the plugin and its README. * Check an SSH host's key by its name, not by the address the connection fell back to A docker-py client for an ssh:// host whose first address did not answer had the answering address spliced into its URL, to get past paramiko's narrow address fallback (it moves on only after a refusal, so a black-holed IPv6 route failed a host reachable over IPv4). paramiko then checked the host key against `[address]:port` in known_hosts rather than the hostname. A host listed only by name was refused, and one whose address carried a stale entry from an earlier machine was refused with "Host key ... does not match", while `ssh`, which checks by name, connected. That was seen on a host whose IPv6 route times out. The client now uses a subclass of docker-py's SSHHTTPAdapter whose `_connect` opens the socket itself through every resolved address and hands it to paramiko with the original hostname, as connect_ssh_client already does for the CLI-backed tools. docker-py builds the adapter inside APIClient and connects in its constructor, so the adapter name in docker.api.client is swapped only while _build_client runs, under a lock; the client keeps the subclass, so its reconnects use it too. A ProxyCommand from ~/.ssh/config is left alone. The splice and its function are gone. Checked against the host that failed: system_info now connects, as `ssh` does. * Say plainly that random values with no credential name are missed by chance, as a remote run showed The sweep against a Docker 29 daemon over SSH missed, in some runs, a random credential under an innocuous name and a random value printed at container start, which the local runs had always caught. The script now reports a missed value's length and bits per character (never the value), and the miss it caught was a 39-character value at 4.48 bits per character, just under the generic rule's 4.5: the threshold working as designed, not a remote-specific fault. A local simulation of the same rule catches 97.7% of 40-character random alphanumerics. Four further runs over SSH missed nothing else of note. REDACTION.md listed those values as caught. They now sit under what is missed, sometimes, with the Swarm secret: only the shape rules can catch a random value with no credential name or known format beside it, and a random value falls under their threshold by chance. The sweep's results also name the daemon reached over SSH. * State REDACTION.md's limits as rules, and guard the SSH adapter against a docker-py upgrade REDACTION.md's "What it misses" still described particular runs: which engines were measured, that a value was missed at least once, and which decoys were left alone. Those now read as behaviour: the odds of missing a random value with no credential name are tied to the shape rules' threshold constant, and what is left alone is said with the reason. The runs themselves are in the commit messages and come back from scripts/measure-redaction.py. _FamilyFallbackSSHAdapter overrides docker-py's private `_connect` and reads `ssh_params`, which the adapter's constructor sets and then connects through. A new test builds the adapter for real, with only the network and the user's SSH files kept out, so a docker-py release that renames either or stops connecting in the constructor fails it rather than silently bypassing the fallback. * List the SSH adapter reach-in as approved, and note the window its swap opens architecture/docker-sdk.md lists reach-ins past the public SDK that have a recorded decision, so a later audit does not re-propose or undo them. _FamilyFallbackSSHAdapter is now listed there, with why the public paths fail, the public alternative rejected (use_ssh_client=True, which moves every SSH host onto the local ssh binary), the guard test, and when to remove it. architecture/hosts.md now says the swap is serialised only among callers of _build_client, so a docker-py client built elsewhere in the process meanwhile would get the subclass too; nothing else in the server builds one.
…comparison figures once (#310) * Record four deliberate SDK choices the weekly audit keeps re-raising The docker-py audit re-derives its candidates from a grep each week and has no memory, so a deliberate choice missing from the exclusions list is proposed again every run. Two runs raised these: - every `api.tasks()` call, not only service_ps's: stack_ps and _wait_stack make three more, for the same reason (docker-py has no task collection at all); - image_list's `api.images()`: the compact default is the daemon's list as it sends it, where the high-level call inspects every image; - APIClient.reload_config: it reaches no daemon and would wipe what system_login cached; - PUT /volumes/{name}: no docker-py surface; declined as the config and secret updates are. Checked against the installed docker-py 7.2.0: no update_volume or Volume.update, reload_config exists, and DockerClient has no tasks. * Say what image_push returns, and when to prefer compose_exec over container_exec image_push's Returns said only "a string". It is the daemon's newline-delimited JSON progress records, and a push the registry refuses still returns, with `errorDetail` in its last record: docker-py 7.2.0's push raises only for an HTTP error status (checked in its source), and a refused push arrives with 200. An agent reading "a string" had no reason to look for the failure. compose_exec named container_exec without saying when to prefer which; container_exec already said the reverse. It now says: a service in a Compose project, by name and index, here; a container known by name or ID, or outside a project, there. * Print the summary ratio ranges from the comparison script, so they are copied rather than worked out The "So the honest summary is" bullets in MCP_VS_SKILLS.md were the only figures worked out by hand from the per-task table, and they went stale twice, while architecture/agent-skill.md said the script emitted every figure the document quotes. The script now computes them (lowest and highest across the chosen tasks: the server's eager floor over the skill's cost, the skill's cost over the server's lazy cost, and both eager floors over what the skill costs to advertise), rounds them to two significant figures and prints them in the form the bullets use; --json carries them under summary_ratios. Run on the code before this branch's changes it reproduced every range the document quoted. * Refresh MCP_VS_SKILLS.md from the comparison script Regenerated after this feature's changes to the tool surface (the `vars` arguments, the redaction notes) and the two docstring fixes, so the figures move once. Every figure is copied from scripts/measure-comparison-figures.py: the five configurations, the idle table, the per-task table, the parameter count (589), the definition sizes and now the summary ranges. Some had drifted before this branch too: the router and the resources row. No conclusion changes. * Read one service's tasks through Service.tasks, and print every derived figure the comparison quotes _wait_stack read one service's running tasks with `client.api.tasks(filters={"service": ...})`, while it held the Service. `Service.tasks(filters=...)` is docker-py's public path for that, sending the same request with the service filter added (checked in docker-py 7.2.0's source), as service_ps already uses it. The exclusion added for `api.tasks()` had wrongly covered this call; it now covers only calls not scoped to one service, so the audit can still raise a scoped one. The redaction harvest's ID lists, which stay low-level to avoid an inspect per object, are recorded there too. The reload_config entry now rests on redundancy: system_reconnect and system_close drop a login as it would. The comparison script now also prints the figures the prose works out from the configuration table (the eager and lazy spreads, the triage cut, the lazy drop, the share of a 128k window), so agent-skill.md's "every figure" is true; the idle range says it spans configurations, not tasks. MCP_VS_SKILLS.md names the command that regenerates its figures, and is refreshed for image_push's description, whose refused-push note moved into the usage paragraph (7 tokens; no rounded figure moves).
…yday requests (#311) * Sweep every way redaction can be switched on, and score a real agent's everyday requests The sweep compared a redacted label with an unfiltered one in one server, so it could only measure a per-host `redact` on a writable host: one server cannot be both globally redacted and unfiltered, nor read-only and writable. It now runs two server processes, a redacted one configured as asked and an unfiltered writable reference, and `--configuration` covers per-host and global redaction, each writable and read-only. Each run also checks what the agent is told and offered there: the instructions pointer, the host_list notes (swap-back on a writable host, not on a read-only one), container_archive_get withdrawn under global redaction and container_exec under READONLY. Error text is searched for planted values too. Run against a throwaway Docker 28 daemon with Swarm, all four configurations had the agent-facing surface right; the misses were the word-like secret in a file (not reachable read-only, where exec is refused or withdrawn) and the Swarm secret, a random 32-character value at 4.30 bits per character, under the shape rules' 4.5; no false replacements on real content; two of seven decoys replaced. `agents` gives a headless Claude Code, with only this server's tools and a dollar cap, eight everyday requests on a small planted app, read-only and writable, and scores whether each was done (or declined, for a write under READONLY), any planted value anywhere in the transcript, the errors it met, and whether it blamed a correct password in triage. Run with Sonnet: all sixteen came out as expected, nothing leaked, the triage found the wrong host rather than blaming the password in both modes, every read-only write was declined without a workaround, and every writable write carried the credential through a marker; $1.29 in all. * Report a value only a refused call showed as not reached, and score psql on tool output alone - Under a read-only configuration the reference server, always writable, reached the files in an image through container_exec, which the redacted server refuses or does not offer. The PEM key and both file secrets were then reported as caught although redaction never saw them. A value that surfaced only through calls the redacted server refused is now NOT REACHED; re-run on (ro,redact), all three show that way. - The psql judgement searched the whole transcript, so the agent's own SELECT, or a mention in its answer, could pass it. It now searches only error-free tool results. Re-scored from the saved transcripts, the writable run still listed the roles and the read-only one did not. - A hung run is recorded as timed out, with its partial transcript, instead of raising and losing the runs already paid for; each run is reported as it finishes, and the transcript directory up front. - The docstring describes the two-process sweep and the agents mode; --only rejects an unknown scenario; the section headers are in place. architecture/redaction.md no longer copies the configuration list or the number of requests, which the script holds, and says which modes to run after a change.
Claude review: changes requestedSummaryThis range adds credential redaction ( Findings1. Bug: a build argument with a space is cut to its first word, so most of it is left in clear
The assignment rule does not help either: 2. Bug (guard too broad): every Compose write walks the whole working directory, up to 50,000 files or 200 MB per callIn Failure scenario: a host marked 3. Bug (dev tooling):
|
… when the daemon changes A build argument's value can hold spaces, and an image's history records it unquoted: `RUN |2 PASSPHRASE=correct horse battery staple OTHER=a=b c /bin/sh -c ...`, checked against a real BuildKit build. The parser split on whitespace, so it stored `correct` and left three quarters of the passphrase in image_history. It now reads an image's whole history: every value but the last ends where the next `NAME=` begins, and the last, which runs into the command, comes from the image's own `ARG` entry (`ARG PASSPHRASE=correct horse battery staple`), ending where another argument begins. Checked on Docker Desktop: no word of a spaced value is left in a redacted image_history. A changed snapshot used to re-read every container and image, about 12.5 s on a daemon of 2,000 containers, so every container_run there paid it. An environment cannot change under the same ID and a service's entry carries its version, so the snapshot difference already says what to read; only those objects are read now. On a throwaway daemon of 2,000 containers, a new container then cost 0.12 s.
Every Compose write searched the whole project directory, or the server's working directory when none was given, for up to 50,000 files or 200 MB a call; compose_down could be refused for a large unrelated directory although it reads only the compose file. compose_up, compose_build and compose_run, which can put any file in the project into a container or image, still search it whole; the other Compose writes search only the compose files and `.env` they read, and compose_cp its local source.
…y 1 a marker `*PASS` matched CACHE_BYPASS and COMPASS, despite the comment saying PASS was matched only as a whole word; a harvested `1` from CACHE_BYPASS=1 would then be replaced wherever it stood alone. The patterns are now `PASS`, `*_PASS` and `*_PASS_*`, and the leave-alone cases include CACHE_BYPASS and COMPASS.
…ccurate docs, safer script startup - A marker in a tool that reaches no daemon is refused for having no host before any guardrail reason, so context_create's refusal no longer points to `env` and `vars`, which it does not have. - The `updates` test now passes `updates`, asserting a label is swapped back and a name refused there; it fails if `updates` is dropped from the nested table. - A test holds that only the client builders construct a docker-py client, which is what keeps the SSH adapter swap safe, in place of a sentence saying so. - A test holds that a flag-name exclusion reaches the flag rule, which REDACTION.md now gives as the remedy for a remembered non-credential such as `--token-ttl 3600`; REDACTION.md also says a rule's find is replaced wherever it appears afterwards, not just in its encoded forms. - measure-redaction.py removes its throwaway daemon when startup fails partway, and names `DECOYS` rather than counting them. - docker-sdk.md states the reach-in decision with a pointer to where it is recorded; cli-shell-out.md says how a remote shell such as FreeBSD's is checked; REDACTION.md's cost table agrees on the image count.
|
Addressed in 44086fa, 41b9a55, e8013e2 and 101a890. Each finding was checked against the code and, where possible, a real daemon first.
Unit: 2,213 passed. |
Claude review: changes requestedResolved
Still open
DeclinedNone. New
What I checked
What I did not check
delta review of |
…nd read override files - A service or config read that failed with anything but NotFound was logged and swallowed, and the snapshot then marked read, so a transient daemon error left that object unharvested for the life of the process. It now propagates like a container's, so the call is refused and the next one reads it again. A node that is not a Swarm manager lists no services or configs in the snapshot, so there is no refusal left to tolerate there. - The last build argument is taken from the image's ARG entry only where that entry begins with the same first word as the RUN entry. BuildKit records the value passed in both, checked against a real build with and without --build-arg; a builder recording the Dockerfile's declaration instead falls back to the first word rather than storing a default. - The non-creating Compose writes also search the override files Compose reads by default (compose.override.yaml and the rest). - REDACTION.md lists names `PASS` no longer reaches, such as DBPASS, under what is missed, with the names setting as the remedy.
|
Addressed in 3f8221c. Each point was checked against the code, and New 1 against a real daemon. New 1: checked, and BuildKit records the value passed; guarded anyway. On Docker Desktop, with
So the New 2: fixed. A Swarm read that fails with anything but New 3: no change, because an unknown host never reaches the swapper. New 4: fixed. New 5: fixed. The default list now includes the override files Compose reads. Still open 9 and 8: declined, for the reasons already given.
Unit: 2,215 passed. |
Claude review: approveResolved
Still open
Declined
New
What I checked
What I did not check
delta review of |
…d state the fail-closed trade The last build argument's ARG entry was trusted where its first word matched the RUN entry's, so a builder recording a declaration such as `real thing` against a passed `real secret` would have stored the declaration. It is now trusted only where the RUN entry's text begins with the whole value; failing that, the first word is kept. The code comment keeps the rule and its reason, without the record of how it was checked, which is in the PR. architecture/redaction.md now says a harvest read that keeps failing refuses every call to that host until the object is fixed or removed, accepted as the fail-closed choice.
|
Taken in b0dc3d1:
Unit: 2,216 passed. |
Claude review: approveResolved
Still open
Declined
NewNone.
What I checked
What I did not check
delta review of |
This adds an opt-in mode that keeps credentials out of everything the server returns, while still letting an agent use them in writes. It follows from #300, which reported that
container_listhanded an agent every container's environment. #301 already made list output compact by default; this is the masking half of that request.This mode reduces accidental exposure. It is not access control. An agent that can run commands in a container can still read a credential. Run it with
DOCKER_MCP_SERVER_READONLY, or mark a redacted host(ro,redact).REDACTION.mddocuments what the mode does, what it misses, what it costs and the boundary it protects.Turning it on
DOCKER_MCP_SERVER_REDACT=1(redact)on a host inDOCKER_MCP_SERVER_HOSTS, such asprod=ssh://ops@prod(ro,redact)!to exclude oneDOCKER_MCP_SERVER_REDACT_NAMESThe
.mcpbbundle and the Claude Code plugin offer the same settings.host_listandtool_listreport the effective settings, and the server warns at startup about a redacted host that is not read-only.What it does
.envfiles and credential-named Swarm configs. These are matched raw and in their encoded forms.--password, and long random runs.[REDACTED:<token>]. No two markers can be linked, and a marker reveals nothing about the value it replaces.envorvars).varsargument, andenvandbuild_argsvalues reach the CLI through its environment, delivered on stdin when the SSH fallback runs the CLI on the remote host. This holds whether or not redaction is on.container_archive_get, and the in-band forms ofcontainer_exportandimage_save, are withdrawn under the global switch and refused on a redacted host.Also in this PR
known_hostsby that address. So a host whose first address times out failed against a stale entry, whilesshconnected. The fix reaches past docker-py's public API, approved and recorded in Measure redaction on real daemons, offer it in the install dialogs, and cut its false replacements #309 and inarchitecture/docker-sdk.md.MCP_VS_SKILLS.mdis regenerated.scripts/measure-comparison-figures.pynow prints every figure the document quotes, including the summary ranges that were previously worked out by hand.image_push,compose_exec), four recorded SDK choices, and_wait_stackreading one service's tasks throughService.tasks.How it was built
vars)Testing
ruff,pyrightandpydoclintare clean.scripts/measure-redaction.py sweep --configuration all), on a throwaway Docker daemon with Swarm. It covers per-host and global redaction, each writable and read-only. In all four:host_listnotes, and the tools withdrawn.REDACTION.mddocuments.scripts/measure-redaction.py agents): a headless Claude Code with only this server's tools ran eight everyday requests, read-only and writable.stack_deployon Swarm, with a marker passed invars.varsdelivery on a FreeBSD 15 host'ssh: values with newlines, quotes and shell metacharacters arrived intact, and appeared in no process's command line.Accepted limitations
These are stated in
REDACTION.md:scripts/measure-redaction.py costregenerates these figures.Size
About 3,300 lines of new package code, 3,800 of tests, 1,100 of measurement scripts and 800 of docs. Around a third of the package (swap-back, the refusals and the file search) serves a redacted host that accepts writes. The docs advise against that setup, but without it an agent could not recreate a container or run a write that needs a credential it has only seen as a marker.