You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c874aad
Browse filesBrowse the repository at this point in the historyBrowse files
fix: deny attach and refuse protocol upgrades in all three (#76) (#79)
* spec: deny attach in the router model (#76)
* test: pin the attach deny and the upgrade refusal (#76)
* fix: deny attach and refuse protocol upgrades in all three (#76)
- Integration, per implementation: 50 tests via deploy/test.sh and 15 socket tests via deploy/test-sock.sh (docker-compose)
46
-
- Quint: `make test-spec` runs the `spec/listener.qnt``run` tests (instances `listener_locked`, `listener_unlocked`) and the `spec/router.qnt``run` tests (instances `router`, `router_pre48`, `router_pre53`, `router_pre55`, and `router_readonly`, whose `readonly*` tests run with `--match`)
- Integration, per implementation: 53 tests via deploy/test.sh and 15 socket tests via deploy/test-sock.sh (docker-compose)
46
+
- Quint: `make test-spec` runs the `spec/listener.qnt``run` tests (instances `listener_locked`, `listener_unlocked`) and the `spec/router.qnt``run` tests (instances `router`, `router_pre48`, `router_pre53`, `router_pre55`, `router_readonly`, whose `readonly*` tests run with `--match`, and `router_pre76`)
Copy file name to clipboardExpand all lines: README.md
+11-7Lines changed: 11 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Key features:
12
12
-**Policy-driven**: Per-service YAML policies, selected by image name, control images, volumes, flags, and env vars. The listening socket is the trust boundary: every caller of a socket can use every policy behind it (see [Trust model](#trust-model))
@@ -198,20 +198,22 @@ docker pull attacker/malware:latest # denied: image not in allowlist
198
198
| EnvFileGate | Gate | Strips `Env` field from create body; env must come from locked `env_file`|
199
199
| CmdGate | Gate | Validates each CLI flag in `Cmd` array against allowlist + denylist |
200
200
201
-
The chain runs only on container create. `--readonly` is not a gate: the router denies every request that is not `GET` or `HEAD`, on every path, before any other check ([#75](https://github.com/ChainSafe/docker-socket-policy/issues/75)). A websocket attach (`GET /containers/{name}/attach/ws` with `Upgrade`) is a `GET` and is not denied yet; the Go proxy lets it write to a container's stdin ([#76](https://github.com/ChainSafe/docker-socket-policy/issues/76)).
201
+
The chain runs only on container create. `--readonly` is not a gate: the router denies every request that is not `GET` or `HEAD`, on every path, before any other check ([#75](https://github.com/ChainSafe/docker-socket-policy/issues/75)). Attach is denied by the router for every method, so a websocket attach (`GET /containers/{name}/attach/ws`) cannot reach a container's stdin, with or without `--readonly` ([#76](https://github.com/ChainSafe/docker-socket-policy/issues/76)).
202
202
203
203
## Endpoint Access
204
204
205
205
| HTTP Method | Path | Action |
206
206
|-------------|------|--------|
207
-
| Not GET/HEAD | Any (with `--readonly`) |**DENIED** (checked first) |
207
+
| Any | Request with an `Upgrade` header, or `Connection: upgrade`|**DENIED** (checked before routing) |
208
+
| Not GET/HEAD | Any (with `--readonly`) |**DENIED** (checked first in the router) |
208
209
| Any | Path containing `%`|**DENIED** (see below) |
209
210
| Any | Path containing `//`|**DENIED**|
210
211
| POST |`/containers/create`| Validated by middleware chain |
211
212
| POST |`/containers/{name}/start\|stop\|restart\|kill\|wait\|pause\|unpause`| Allowed on known containers |
212
213
| DELETE |`/containers/{name}`| Allowed on known containers |
213
214
| Any |`/containers/…/exec` (an `exec` segment anywhere under `/containers`) |**DENIED**|
214
215
| Any |`/exec/*`|**DENIED**|
216
+
| Any |`/containers/{name}/attach…` (an `attach` segment anywhere under `/containers`) |**DENIED**|
215
217
| POST |`/containers/{name}/rename\|update`|**DENIED**|
216
218
| POST |`/images/create`| Validated by registry gate |
217
219
| POST |`/auth`|**DENIED**|
@@ -224,6 +226,8 @@ Any request whose path contains a percent-encoded byte (`%`) is denied with 403
224
226
225
227
Exec is matched on whole path segments, so containers named like `exec-runner` work normally, and exec inspect (`GET /exec/{id}/json`) is denied too. A path with an empty segment (`//`, as in `//exec/{id}/json`) is denied for every method, so an empty segment cannot hide the exec namespace; a single trailing slash is fine, and `//` in the query string is not inspected. Absolute-form request targets (`GET http://host/…`) never reach exec: Go and Rust route them on the parsed path, so exec is denied and other paths are routed as usual, while the TypeScript proxy sees the raw target and denies every absolute-form request (its `//` after the scheme is an empty segment). The Docker CLI never sends absolute form.
226
228
229
+
Attach is matched the same way: an `attach` segment under `/containers` is denied for every method, so `attach-runner` is an ordinary name, while a container literally named `attach` cannot be reached by name. Protocol upgrades are refused outright: any request with an `Upgrade` header, or a `Connection` header that lists `upgrade`, gets 403 `protocol upgrade not allowed` before it is routed, whatever its path ([#76](https://github.com/ChainSafe/docker-socket-policy/issues/76)). Forwarding one would hand the caller a raw stream to the daemon. Every Docker endpoint that upgrades (attach, exec start, the build session) is denied anyway; the refusal keeps any path the router allows from becoming one.
230
+
227
231
## Configuration
228
232
229
233
### CLI Flags
@@ -441,7 +445,7 @@ not at the socket.
441
445
442
446
## Formal Verification
443
447
444
-
This project includes a [Quint](https://quint-lang.org/) formal specification that models the security invariants as a state machine. Random-simulation verification runs 10,000 sampled traces of up to 100 steps each, checking all 9 invariants on every state transition. A second module, `spec/listener.qnt`, models listening-socket startup (group selection, existing-path checks, the single-instance lock) with 6 more invariants. A third module, `spec/router.qnt`, models the router's denies for writes under `--readonly` ([#75](https://github.com/ChainSafe/docker-socket-policy/issues/75)), percent-encoded paths ([#53](https://github.com/ChainSafe/docker-socket-policy/issues/53)), empty interior segments ([#55](https://github.com/ChainSafe/docker-socket-policy/issues/55)) and exec ([#49](https://github.com/ChainSafe/docker-socket-policy/issues/49)), the `POST /containers/create` route, container-name extraction and the container-lifecycle branch, not the full routing table ([#24](https://github.com/ChainSafe/docker-socket-policy/issues/24), [#48](https://github.com/ChainSafe/docker-socket-policy/issues/48)). Its 8 properties are checked exhaustively over the methods `GET`, `HEAD`, `POST`, `DELETE` and every path of 1 to 3 segments over the model's word set; exec is denied by the router, not by a middleware gate.
448
+
This project includes a [Quint](https://quint-lang.org/) formal specification that models the security invariants as a state machine. Random-simulation verification runs 10,000 sampled traces of up to 100 steps each, checking all 9 invariants on every state transition. A second module, `spec/listener.qnt`, models listening-socket startup (group selection, existing-path checks, the single-instance lock) with 6 more invariants. A third module, `spec/router.qnt`, models the router's denies for writes under `--readonly` ([#75](https://github.com/ChainSafe/docker-socket-policy/issues/75)), percent-encoded paths ([#53](https://github.com/ChainSafe/docker-socket-policy/issues/53)), empty interior segments ([#55](https://github.com/ChainSafe/docker-socket-policy/issues/55)), exec ([#49](https://github.com/ChainSafe/docker-socket-policy/issues/49)) and attach ([#76](https://github.com/ChainSafe/docker-socket-policy/issues/76)), the `POST /containers/create` route, container-name extraction and the container-lifecycle branch, not the full routing table ([#24](https://github.com/ChainSafe/docker-socket-policy/issues/24), [#48](https://github.com/ChainSafe/docker-socket-policy/issues/48)). Its 9 properties are checked exhaustively over the methods `GET`, `HEAD`, `POST`, `DELETE` and every path of 1 to 3 segments over the model's word set; exec is denied by the router, not by a middleware gate.
445
449
446
450
The CI pipeline runs verification on every push and PR. A violation blocks the build.
0 commit comments