Container create: default-deny HostConfig, validate Mounts and the bind read-only mode
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #92 来自 @abienkowski —— 已合并
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 15/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- docker, go, rust, typescript
调研方向
Start with the POST /containers/create middleware in go/internal/middleware/mountsource.go and containerconfig.go, then the matching files in rs/src/middleware.rs and ts/src/middleware.ts. The issue asks for a default-deny allowlist on HostConfig, a Mounts check that matches the Binds whitelist, bind-mode parsing for read_write, and forcing Privileged to false even when container_config is empty. Done means the three repro creates return 403 in each implementation, and the policy tests cover the new rules. The issue is a breaking security change that needs maintainer agreement on the allowlist first.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
On POST /containers/create, the proxy checks only part of the request. Every other field goes to the daemon unchanged:
- The volume whitelist checks the host path of
HostConfig.Bindsand the legacy top-levelVolumes. It does not checkHostConfig.Mounts. - The bind mode is not checked.
read_write: falseis parsed in all three implementations, but no gate reads it. ContainerConfigMutatoroverwritesNetworkMode,RestartPolicy,SecurityOpt,Privileged,UserandLogConfig. Ifcontainer_configis empty, it returns early and does not even forcePrivileged: false.- Other
HostConfigfields pass through:Devices,DeviceRequests,DeviceCgroupRules,GroupAdd,CapAdd,VolumesFrom,Links,Sysctls,CgroupParent,Runtime, thehostvalues ofPidMode,IpcMode,UTSMode,UsernsModeandCgroupnsMode,MaskedPaths/ReadonlyPaths, andSecurityOptwhen the policy sets none.
So every policy-level restriction on mounts and privileges can be bypassed by a caller of the socket.
Affected implementation(s)
- Go
- Rust
- TypeScript
- All
Go go/internal/middleware/mountsource.go (Binds host path only), go/internal/middleware/containerconfig.go:13 (early return). Rust rs/src/middleware.rs and TypeScript ts/src/middleware.ts have the same gaps.
To Reproduce
Policy with volumes: [{host_path: /srv/ok, container_path: /ok, read_write: false}]. Through the proxy, each of these creates is accepted and the daemon receives the field unchanged:
docker create --mount type=bind,src=/,dst=/host alpine:3.20 truedocker create -v /srv/ok:/ok:rw alpine:3.20 true(also-v /srv/ok:/okwith no mode)docker create --cap-add SYS_ADMIN --pid host alpine:3.20 true
Expected behavior
Default-deny on HostConfig:
- A
HostConfigkey outside a fixed allowlist must be absent or hold its zero value. Otherwise the proxy returns403and names the field. A denylist would miss fields that the Engine API adds later. HostConfig.Mountsgets the same whitelist asBinds.bindmounts must match a policy volume, withReadOnly: trueif the volume is notread_write.volumemounts and all other types excepttmpfsare denied.- Each bind mode is parsed. A volume with
read_write: falserequiresro. - The mutator forces
Privileged: falseeven ifcontainer_configis empty.SecurityOptfrom the caller is denied unless the policy lists it, apart fromno-new-privileges.
Status: Break Change: creates that set these fields are now denied.
Additional context
Found while verifying the proxy for ChainSafe/lodestar-infrastructure#9.
- 主要语言
- Rust
- 星标
- 2
- 派生
- 0
- 平均合并
- 12 小时 11 分钟
- 30 天内合并 PR
- 30
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ChainSafe/docker-socket-policy 的其他 Issue
-
Type: Feature
难度 5/5 一周以上 新手友好度 12/100
ChainSafe/docker-socket-policy#96 ·
维护者通常 1 天内回复
-
Priority: P3 Type: Enhancement
难度 4/5 3-5 天 新手友好度 15/100
ChainSafe/docker-socket-policy#95 ·
维护者通常 1 天内回复
-
Type: Feature
难度 5/5 一周以上 新手友好度 25/100
ChainSafe/docker-socket-policy#65 ·
维护者通常 1 天内回复
-
Type: Enhancement
难度 5/5 一周以上 新手友好度 38/100
ChainSafe/docker-socket-policy#46 · 1 条评论 ·
维护者通常 1 天内回复
查看 ChainSafe/docker-socket-policy 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
EmbarkStudios/cargo-deny#910 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
tursodatabase/turso#10054 ·
维护者通常 1 天内回复
-
build: Update rust version可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭dependencies
难度 2/5 1-3 小时 新手友好度 67/100
ibm-granite-community/granite-cli#229 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
orottier/web-audio-api-rs#658 ·