Container create: default-deny HostConfig, validate Mounts and the bind read-only mode
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #92 của @abienkowski — đã merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 15/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- docker, go, rust, typescript
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Rust
- Star
- 2
- Fork
- 0
- Merge trung bình
- 12 giờ 11 phút
- Pull request đã merge (30 ngày)
- 30
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ChainSafe/docker-socket-policy
-
Type: Feature
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
ChainSafe/docker-socket-policy#65 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Type: Enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
ChainSafe/docker-socket-policy#46 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ChainSafe/docker-socket-policy
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:cli bug good first issue priority:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
rtk-ai/rtk#4589 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
dependencies effort:low flow:chore rust
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
jaroslawherod/micold-ai-ide#875 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
storytold/photocraft#6286 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày