Policy selection is nondeterministic when several policies allow one image; add container_names routing and deny on ambiguity
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #90 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
- 18/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 from GetByImage, which returns the first matching policy while iterating a map, and from the POST /containers/create handler that uses its result. Adding container_names routing and load-time ambiguity checks touches all three implementations and the Quint model. Pull request #90 is already open against this issue, so check it before starting. Done means the same image and name always select one policy, and ambiguous matches return 403.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When more than one loaded policy allows the same image, the policy applied to a create is effectively random. GetByImage returns the first policy whose prefixes match while iterating a map: Go map and Rust HashMap iteration order is randomized, so the choice can change from one request to the next; TypeScript's Map keeps load order, so the first-loaded policy always wins. The selected policy decides the forced container_config.user, the volume whitelist and the flag rules, so a container can be created with another service's settings.
This is a normal layout, not an edge case: services built from one image need different policies. Lodestar's beacon node and validator client both run chainsafe/lodestar with different users and data directories, so in a one-trust-domain deployment (README "Trust model") validator creates intermittently get the beacon policy — forced to the beacon user and refused their own data directory.
Affected implementation(s)
- Go
- Rust
- TypeScript
- All
To Reproduce
- Two policies in one
--config-dir:# a.yaml service_name: svc-a allowed_image_prefixes: [alpine] container_config: { user: "1111:1111" } # b.yaml service_name: svc-b allowed_image_prefixes: [alpine] container_config: { user: "2222:2222" } - Through the proxy,
docker create alpine:3.20 truesix times, restart the proxy, repeat (three runs). - Forced users observed (Go v0.3.11):
run 1: 1111 1111 1111 1111 1111 1111 run 2: 1111 2222 1111 1111 1111 1111 run 3: 1111 1111 1111 1111 1111 1111
Expected behavior
Policy selection is deterministic, and services that share an image can be told apart.
Proposed:
- Optional
container_namesin a policy (e.g.container_names: [beacon]). OnPOST /containers/create, select the policy whose image prefixes match and whosecontainer_namescontains the request's?name=. A policy withoutcontainer_namesmatches any name, as today. - Exactly one match, otherwise deny. Zero matches → 403 as today; more than one → 403 with an ambiguity error naming the matching policies. Validate at load time too: two policies that could both match the same image and name should fail startup.
The name is chosen by the caller, so this is routing, not access control — consistent with the trust model, where every caller of a socket already holds the union of its policies.
Environment
- OS: Ubuntu 22.04.5
- Docker version: Engine 29.9.0 (API 1.56)
- Implementation version/commit: v0.3.11 (
3130b0a), Go binary
Additional context
Needed by ChainSafe/lodestar-infrastructure's deployment of this proxy (beacon and validator from one image). The Quint model would need the container name as an input to state "the applied policy is the unique match for (image, name)".
- 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 12/100
ChainSafe/docker-socket-policy#96 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Priority: P3 Type: Enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
ChainSafe/docker-socket-policy#95 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
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: workspace access hint suggests a --subject command that fails for hyphen-leading OIDC subjectsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`last_error_thread_local_then_global` fails when it runs beside the `lumen_event_detail` testĐang mởA-FFI C-Testing D-Straightforward S-Ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
docs priority:P3 size:XS
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Appimage ConventionsĐang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày