implement per-container allowlists specified by Docker container labels#69
Merged
wollomatic merged 29 commits intoNov 29, 2025
Conversation
… container name is provided
Owner
|
Thanks @amanda-wee for this amazing work! I'll try to get the review done as soon as possible. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements per-container allowlists that can be specified using Docker container labels, enabling fine-grained access control for each container accessing the Docker socket through the proxy. The feature is opt-in via the -proxycontainername parameter and maintains backward compatibility.
Key Changes:
- Adds an embedded Docker API client (extracted from Moby) to monitor container events and manage per-container allowlists
- Refactors configuration to use an
AllowListRegistrythat maintains both default and per-container allowlists mapped by IP address - Implements real-time allowlist updates through Docker event stream monitoring for container start/restart/die events
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/go-connections/sockets/sockets.go | Adds socket configuration utilities extracted from docker/go-connections for the Docker client |
| internal/docker/client/*.go | Implements Docker Engine API client with version negotiation, event streaming, and container listing |
| internal/docker/api/types/*.go | Defines Docker API types for events, containers, filters, and responses |
| internal/config/config.go | Refactors config to support allowlist registry with per-container allowlists, adds Docker event monitoring |
| cmd/socket-proxy/main.go | Launches goroutine for allowlist updates when per-container feature is enabled |
| cmd/socket-proxy/handlehttprequest.go | Updates request handling to determine and use appropriate allowlist based on client IP |
| cmd/socket-proxy/bindmount.go | Refactors bind mount validation to accept allowedBindMounts parameter instead of using global config |
| cmd/socket-proxy/bindmount_test.go | Updates tests to pass allowedBindMounts parameter directly |
| README.md | Documents per-container allowlist feature setup and configuration |
| LICENSE | Updates attribution for Apache 2.0 licensed code in new internal packages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Wolfgang Ellsässer <67168186+wollomatic@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Wolfgang Ellsässer <67168186+wollomatic@users.noreply.github.com>
To fix number of retries when querying Docker Engine API for proxy container summary. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Amanda Wee <amanda@aranel.net>
To fix formatting of SP_PROXYCONTAINERNAME Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Amanda Wee <amanda@aranel.net>
599e190
into
wollomatic:28-fr-support-granular-api-permissions-on-a-per-host-basis-via-allowfrom
1 check passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request implements per-container allowlists that are specified using Docker container labels.
Summary
Backwards Compatibility
To enable per-container allowlists, either the
-proxycontainernameparameter must be passed to the command, or theSP_PROXYCONTAINERNAMEenvironment variable must be set. Otherwise, the functionality is skipped entirely, hence only the default allowlist will be used. If the proxy socket endpoint is provided, then likewise the functionality is skipped. Therefore, socket-proxy can still be used to proxy socket connections that are not for the Docker socket.Security
Container labels can be set when a container is created through the Docker Engine API. This means that if a container has a per-container allowed request regex for POST requests that allows
/containers/create, then an attacker that gains access to the container can perform privilege escalation that would not be possible with the default allowlist (without also being able to create an image). Since the usual use of socket-proxy is for read-only access and container creation access should be relatively rare, this risk should be worth the ease of use of Docker container labels to specify allowlists.Docker Engine API Client
For development, the Docker SDK for Go (as in the low-level Moby) was used for API calls. Once a proof-of-concept was working, the part of the client that ended up being used was then extracted into packages under the
internalfolder so that socket-proxy will not need any external dependencies.This client uses the socket path specified by the
-socketpathparameter or theSP_SOCKETPATHenvironment variable, defaulting to the socket-proxy'sdefaultSocketPath. It also does Docker Engine API version negotiation for maximum compatibility.