server: restrict container egress CONNECT listener to the managed container#6204
Open
server: restrict container egress CONNECT listener to the managed container#6204
Conversation
|
The generated output of Full Type Diff |
Contributor
|
@dknecht Bonk workflow was cancelled. View workflow run · To retry, trigger Bonk again. |
Contributor
|
Hello, this is not going to work in MacOS as these container addresses are not assigned to a real device in the host. Personally I dont think I'd be concerned of local dev containers proxying to be exploited to access local dev WorkerEntrypoint, anybody can just run |
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.
Motivation
Description
ipAddresstoInspectResponsereturned byContainerClient::inspectContainer()so the container's IP is available for authorization (src/workerd/server/container-client.h,src/workerd/server/container-client.c++).ContainerClient::isEgressPeerAuthorized(kj::AsyncIoStream&)which callsinspectContainer(), obtains the container IP, retrieves the peer socket address viagetpeername(), and compares addresses for IPv4/IPv6; it returnstrueonly when the peer matches the managed container IP (src/workerd/server/container-client.c++).EgressHttpService::connect()to callisEgressPeerAuthorized()and reject unauthorized peers with403 Forbiddenand immediately close the connection before accepting/forwarding (src/workerd/server/container-client.c++).inspectContainer()results to match the extended result tuple (src/workerd/server/container-client.c++).Testing
bazel test //src/workerd/server/tests/container-client:container-client@, which failed in this environment due to inability to download the Bazel binary (HTTP 403), so automated tests could not complete.InspectResponseshape is handled at modified callsites and that the CONNECT path now performs authorization; no runtime test harness could be executed in this environment.Codex Task