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

ws: Conditionally block channel requests to remote hosts #21003

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mvollmer
Copy link
Member

When AllowMultiHost is false, cockpit-ws will reject all GET requests that would load from a non-localhost bridge.

@jelly
Copy link
Member

jelly commented Sep 16, 2024

From a quick look this looks correct, but we probably want to have a test for this? Do we also show a proper error then if a user navigates to an old bookmark?

The only question I have about the code is, what is filled in host_by_checksum as that is the only path I can't really follow.

@mvollmer
Copy link
Member Author

The only question I have about the code is, what is filled in host_by_checksum as that is the only path I can't really follow.

Good point, I didn't consider checksums urls... I'll check.

(In practice, checksums are only known the the shell once a manifest has been loaded from a host, but this is of course about closing all the doors and not rely on what the shell is doing.)

@mvollmer
Copy link
Member Author

From a quick look this looks correct, but we probably want to have a test for this?

Yeah, via curl.

Do we also show a proper error then if a user navigates to an old bookmark?

They get redirected by the shell. This change here should have no effect with our current shell. It should never construct URLs for remote hosts when AllowMultiHost is false. But the shell is a lot of code, and there might be bugs, so we should also block the requests we don't want to happen in cockpit-ws.

@mvollmer mvollmer marked this pull request as draft September 17, 2024 06:23
@mvollmer
Copy link
Member Author

The only question I have about the code is, what is filled in host_by_checksum as that is the only path I can't really follow.

Good point, I didn't consider checksums urls... I'll check.

They are handled by parse_host_and_etag and thus a checksum url will also be handled by cockpit_channel_response_serve and is also subject to the new "remote host" check.

@mvollmer
Copy link
Member Author

From a quick look this looks correct, but we probably want to have a test for this?

Yeah, via curl.

Done.

@mvollmer mvollmer marked this pull request as ready for review September 17, 2024 08:35
Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

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

Thanks!

test/verify/check-connection Outdated Show resolved Hide resolved
When AllowMultiHost is false, cockpit-ws will reject all GET requests
that would load from a non-localhost bridge.
martinpitt
martinpitt previously approved these changes Sep 20, 2024
Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

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

Thanks! If you have to push again, please remove the redundancy, but not that important.

Comment on lines +378 to +379
self.enable_multihost(m)
self.setup_ssh_auth()
Copy link
Member

Choose a reason for hiding this comment

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

Both of these are already done in setUp(). Should hopefully not hurt, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, setup_ssh_auth was necessary, for some reason.

@martinpitt
Copy link
Member

testUrlRoot is unhappy 😢

@martinpitt martinpitt dismissed their stale review September 20, 2024 10:04

test failures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants