Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rootless port forwarding with network dis-/connect #11091

Merged
merged 1 commit into from
Aug 3, 2021

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented Aug 2, 2021

The rootlessport forwarder requires a child IP to be set. This must be a
valid ip in the container network namespace. The problem is that after a
network disconnect and connect the eth0 ip changed. Therefore the
packages are dropped since the source ip does no longer exists in the
netns.
One solution is to set the child IP to 127.0.0.1, however this is a
security problem. [1]

To fix this we have to recreate the ports after network connect and
disconnect. To make this work the rootlessport process exposes a socket
where podman network connect/disconnect connect to and send to new child
IP to rootlessport. The rootlessport process will remove all ports and
recreate them with the new correct child IP.

Fixes #10052

[1] https://nvd.nist.gov/vuln/detail/CVE-2021-20199

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 2, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 2, 2021
@Luap99
Copy link
Member Author

Luap99 commented Aug 2, 2021

@AkihiroSuda PTAL
@edsantiago PTAL at the test.

Copy link
Member

@edsantiago edsantiago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice test. A few suggestions and nits.

test/system/500-networking.bats Outdated Show resolved Hide resolved
test/system/500-networking.bats Outdated Show resolved Hide resolved
test/system/500-networking.bats Outdated Show resolved Hide resolved
test/system/500-networking.bats Show resolved Hide resolved
@Luap99 Luap99 force-pushed the connect-disconnect branch 2 times, most recently from e934bf9 to 7cffbc5 Compare August 3, 2021 11:08
@Luap99
Copy link
Member Author

Luap99 commented Aug 3, 2021

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 3, 2021
The rootlessport forwarder requires a child IP to be set. This must be a
valid ip in the container network namespace. The problem is that after a
network disconnect and connect the eth0 ip changed. Therefore the
packages are dropped since the source ip does no longer exists in the
netns.
One solution is to set the child IP to 127.0.0.1, however this is a
security problem. [1]

To fix this we have to recreate the ports after network connect and
disconnect. To make this work the rootlessport process exposes a socket
where podman network connect/disconnect connect to and send to new child
IP to rootlessport. The rootlessport process will remove all ports and
recreate them with the new correct child IP.

Also bump rootlesskit to v0.14.3 to fix a race with RemovePort().

Fixes containers#10052

[1] https://nvd.nist.gov/vuln/detail/CVE-2021-20199

Signed-off-by: Paul Holzinger <[email protected]>
@Luap99
Copy link
Member Author

Luap99 commented Aug 3, 2021

/hold cancel
Tests are green. I added a retry for the socket connection which flaked in the last run. I think this version will fix it but I am not 100% sure.

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 3, 2021
@edsantiago
Copy link
Member

LGTM. I'm eager to look at flakes a week or two from when this merges.

@rhatdan
Copy link
Member

rhatdan commented Aug 3, 2021

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2021
@openshift-ci openshift-ci bot merged commit cbad561 into containers:main Aug 3, 2021
@Luap99 Luap99 deleted the connect-disconnect branch September 1, 2021 11:28
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compose flake: rootlesskit port forwarder not setup correctly
5 participants