Skip to content

Commit

Permalink
ws: Conditionally block channel requests to remote hosts
Browse files Browse the repository at this point in the history
When AllowMultiHost is false, cockpit-ws will reject all GET requests
that would load from a non-localhost bridge.
  • Loading branch information
mvollmer committed Sep 13, 2024
1 parent 6592eda commit eed5f67
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ws/cockpitchannelresponse.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ cockpit_channel_response_serve (CockpitWebService *service,
gchar *channel = NULL;
gpointer key;
gpointer value;
gboolean allow_multihost;

g_return_if_fail (COCKPIT_IS_WEB_SERVICE (service));
g_return_if_fail (in_headers != NULL);
Expand All @@ -614,6 +615,14 @@ cockpit_channel_response_serve (CockpitWebService *service,
goto out;
}

allow_multihost = cockpit_conf_bool ("WebService", "AllowMultiHost", ALLOW_MULTIHOST_DEFAULT);
if (!allow_multihost && g_strcmp0 (host, "localhost") != 0)
{
cockpit_web_response_error (response, 403, NULL, NULL);
handled = TRUE;
goto out;
}

if (quoted_etag)
{
cache_type = COCKPIT_WEB_RESPONSE_CACHE;
Expand Down

0 comments on commit eed5f67

Please sign in to comment.