Skip to content

Conversation

@benjamreis
Copy link
Contributor

@benjamreis benjamreis commented May 2, 2024

New XAPI conf option: disable-webserver (default: false)
If true, all requests for the fileserver will get a 403 response.

@benjamreis
Copy link
Contributor Author

We get this feature request from a lot of users that wan't to completely disable the webserver for security reason.

else (
Buf_io.assert_buffer_empty bio ;
let is_external_http = is_external_http req s in
if is_external_http && !Xapi_globs.website_https_only then
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this expression not be extended to get the desired outcome? I don't like the deeper and deeper nesting if it could be avoided.

Copy link
Contributor

Choose a reason for hiding this comment

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

As a configuration option, this is fine with me.

Copy link
Member

@psafont psafont May 3, 2024

Choose a reason for hiding this comment

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

I've tried using options, along with bind, to indicate whether a single reply has been sent back to the client, but it ends up more verbose, and not quite as clean as I would like:

let reply_maybe condition reply =
  if condition () then
    Some (reply ())
  else
    None

...

  let ( let* ) = Option.bind in
  let reply () =
    let* () =
      reply_maybe
      (fun () -> !Xapi_globs.disable_webserver)
      (fun () -> Http_svr.response_forbidden ~req s)
    in
    let* () =
      reply_maybe
        (fun () -> is_external_http && !Xapi_globs.website_https_only)
        (fun () -> Http_svr.response_forbidden ~req s)
    in

...

  in
  match reply () with
  | Some () ->
      ()
  | None ->
      Http_svr.response_missing s (missing uri)

@psafont
Copy link
Member

psafont commented May 3, 2024

What is it exactly that users complain about? We already allow a setting to disable port 80, to appease the port scanners

@stormi
Copy link
Contributor

stormi commented May 6, 2024

In XCP-ng 8.3, we provide a full client (XO Lite) directly available in HTTPS. Some users are afraid of it, despite it's just a client that ultimately runs in their browser. So we want to offer them the choice to disable it completely.

In addition to this, scanners may detect CVEs in JS dependencies of XO lite from time to time, which we will fix, but users may need to disable the web server temporarily to comply with security rules about detected CVEs in software until we publish the fix and they can schedule applying it.

@psafont
Copy link
Member

psafont commented May 7, 2024

My preference would be to filter the common http handler's list by name to not load the get_root handler on startup in ocaml/xapi/xapi.ml line 1106, depending on the conf, and see how it explodes when doing the request. This seems like the correct layer to handle the matter, rather than inside the fileserver

@benjamreis benjamreis force-pushed the disable-fileserver-option branch from e1befc6 to 8f059a8 Compare May 15, 2024 13:19
@benjamreis benjamreis requested a review from psafont May 15, 2024 13:20
@benjamreis
Copy link
Contributor Author

My preference would be to filter the common http handler's list by name to not load the get_root handler on startup in ocaml/xapi/xapi.ml line 1106, depending on the conf, and see how it explodes when doing the request. This seems like the correct layer to handle the matter, rather than inside the fileserver

Done! :)

@benjamreis
Copy link
Contributor Author

Re-tested and validated.

New XAPI conf option: `disable-webserver` (default: false)
If true, all requests for the fileserver will get a 403 response.

Signed-off-by: Benjamin Reis <benjamin.reis@vates.tech>
@benjamreis benjamreis force-pushed the disable-fileserver-option branch from 73a4c06 to 26712bb Compare May 15, 2024 14:17
Copy link
Member

@psafont psafont left a comment

Choose a reason for hiding this comment

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

Hiding the whitespace in the diff it's very easy to see that the change is correct

@psafont psafont merged commit c6ec81b into xapi-project:master May 16, 2024
@psafont psafont deleted the disable-fileserver-option branch May 16, 2024 12:38
benjamreis added a commit to xcp-ng-rpms/xapi that referenced this pull request May 16, 2024
See: xapi-project/xen-api#5608

Signed-off-by: Benjamin Reis <benjamin.reis@vates.tech>
benjamreis added a commit to xcp-ng-rpms/xapi that referenced this pull request May 16, 2024
See: xapi-project/xen-api#5608

Signed-off-by: Benjamin Reis <benjamin.reis@vates.tech>
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.

4 participants