Re: [PATCH 2/2] qemu-img: CVE-XXX Sanitize untrusted output from NBD server

2024-08-07 Thread Stefan Hajnoczi
On Fri, Aug 02, 2024 at 11:41:35PM +0200, Philippe Mathieu-Daudé wrote: > On 2/8/24 21:26, Eric Blake wrote: > > Error messages from an NBD server must be treated as untrusted; a > > malicious server can inject escape sequences to try and trigger RCE > > flaws via escape sequences to whatever termi

[PATCH v4 2/7] nbd/server: Plumb in new args to nbd_client_add()

2024-08-07 Thread Eric Blake
Upcoming patches to fix a CVE need to track an opaque pointer passed in by the owner of a client object, as well as reequest for a time limit on how fast negotiation must complete. Prepare for that by changing the signature of nbd_client_new() and adding an accessor to get at the opaque pointer, a

[PATCH v4 7/7] nbd/server: Allow users to adjust handshake limit in QMP

2024-08-07 Thread Eric Blake
Although defaulting the handshake limit to 10 seconds was a nice QoI change to weed out intentionally slow clients, it can interfere with integration testing done with manual NBD_OPT commands over 'nbdsh --opt-mode'. Expose a QMP knob to allow the user to alter the timeout away from the default.

[PATCH v4 4/7] nbd/server: CVE-2024-7409: Drop non-negotiating clients

2024-08-07 Thread Eric Blake
A client that opens a socket but does not negotiate is merely hogging qemu's resources (an open fd and a small amount of memory); and a malicious client that can access the port where NBD is listening can attempt a denial of service attack by intentionally opening and abandoning lots of unfinished

[PATCH v4 3/7] nbd/server: CVE-2024-7409: Change default max-connections to 100

2024-08-07 Thread Eric Blake
Allowing an unlimited number of clients to any web service is a recipe for a rudimentary denial of service attack: the client merely needs to open lots of sockets without closing them, until qemu no longer has any more fds available to allocate. For qemu-nbd, we default to allowing only 1 connecti

[PATCH v4 6/7] qemu-nbd: Allow users to adjust handshake limit

2024-08-07 Thread Eric Blake
Although defaulting the handshake limit to 10 seconds was a nice QoI change to weed out intentionally slow clients, it can interfere with integration testing done with manual NBD_OPT commands over 'nbdsh --opt-mode'. Expose a command line option to allow the user to alter the timeout away from the

[PATCH for-9.1 v4 0/7] CVE-2024-7409

2024-08-07 Thread Eric Blake
v3 was here: https://lists.gnu.org/archive/html/qemu-devel/2024-08/msg00818.html since then: - re-add a minor patch from v2 (now patch 1) - refactor how the client opaque pointer is handled (patch 2) - add two new patches to prevent malicious clients from consuming inordinate resources: chan

[PATCH v4 5/7] nbd/server: CVE-2024-7409: Close stray client sockets at shutdown

2024-08-07 Thread Eric Blake
A malicious client can attempt to connect to an NBD server, and then intentionally delay progress in the handshake, including if it does not know the TLS secrets. Although this behavior can be bounded by the max-connections parameter, the QMP nbd-server-start currently defaults to unlimited incomi

[PATCH v4 1/7] nbd: Minor style fixes

2024-08-07 Thread Eric Blake
Touch up a comment with the wrong type name, and an over-long line, both noticed while working on upcoming patches. Signed-off-by: Eric Blake --- nbd/server.c | 2 +- qemu-nbd.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index 892797bb11

Re: [PATCH for-9.1 0/2] NBD: don't print raw server error text to terminal

2024-08-07 Thread Eric Blake
On Mon, Aug 05, 2024 at 08:11:31PM GMT, Richard W.M. Jones wrote: > On Mon, Aug 05, 2024 at 01:48:12PM -0500, Eric Blake wrote: > > On Fri, Aug 02, 2024 at 02:26:04PM GMT, Eric Blake wrote: > > > I've requested a CVE from Red Hat, and hope to have an assigned number > > > soon. Meanwhile, we can g

Re: [PATCH v4 1/7] nbd: Minor style fixes

2024-08-07 Thread Daniel P . Berrangé
in $subject s/style/style & typo/ On Wed, Aug 07, 2024 at 12:43:27PM -0500, Eric Blake wrote: > Touch up a comment with the wrong type name, and an over-long line, > both noticed while working on upcoming patches. > > Signed-off-by: Eric Blake > --- > nbd/server.c | 2 +- > qemu-nbd.c | 3 ++

Re: [PATCH v4 2/7] nbd/server: Plumb in new args to nbd_client_add()

2024-08-07 Thread Daniel P . Berrangé
On Wed, Aug 07, 2024 at 12:43:28PM -0500, Eric Blake wrote: > Upcoming patches to fix a CVE need to track an opaque pointer passed > in by the owner of a client object, as well as reequest for a time > limit on how fast negotiation must complete. Prepare for that by > changing the signature of nbd

Re: [PATCH v4 3/7] nbd/server: CVE-2024-7409: Change default max-connections to 100

2024-08-07 Thread Daniel P . Berrangé
On Wed, Aug 07, 2024 at 12:43:29PM -0500, Eric Blake wrote: > Allowing an unlimited number of clients to any web service is a recipe > for a rudimentary denial of service attack: the client merely needs to > open lots of sockets without closing them, until qemu no longer has > any more fds availabl

Re: [PATCH v4 4/7] nbd/server: CVE-2024-7409: Drop non-negotiating clients

2024-08-07 Thread Daniel P . Berrangé
On Wed, Aug 07, 2024 at 12:43:30PM -0500, Eric Blake wrote: > A client that opens a socket but does not negotiate is merely hogging > qemu's resources (an open fd and a small amount of memory); and a > malicious client that can access the port where NBD is listening can > attempt a denial of servic

Re: [PATCH v4 5/7] nbd/server: CVE-2024-7409: Close stray client sockets at shutdown

2024-08-07 Thread Daniel P . Berrangé
On Wed, Aug 07, 2024 at 12:43:31PM -0500, Eric Blake wrote: > A malicious client can attempt to connect to an NBD server, and then > intentionally delay progress in the handshake, including if it does > not know the TLS secrets. Although this behavior can be bounded by > the max-connections parame

Re: [PATCH 2/2] qemu-img: CVE-XXX Sanitize untrusted output from NBD server

2024-08-07 Thread Daniel P . Berrangé
On Fri, Aug 02, 2024 at 10:03:05PM +0100, Richard W.M. Jones wrote: > On Fri, Aug 02, 2024 at 02:26:06PM -0500, Eric Blake wrote: > > Error messages from an NBD server must be treated as untrusted; a > > malicious server can inject escape sequences to try and trigger RCE > > flaws via escape sequen

Re: [PATCH 1/2] util: Refactor json-writer's string sanitizer to be public

2024-08-07 Thread Daniel P . Berrangé
On Fri, Aug 02, 2024 at 02:26:05PM -0500, Eric Blake wrote: > My next patch needs to convert text from an untrusted input into an > output representation that is suitable for display on a terminal is > useful to more than just the json-writer; the text should normally be > UTF-8, but blindly allowi

Re: [PATCH v4 2/7] nbd/server: Plumb in new args to nbd_client_add()

2024-08-07 Thread Eric Blake
On Wed, Aug 07, 2024 at 06:58:36PM GMT, Daniel P. Berrangé wrote: > On Wed, Aug 07, 2024 at 12:43:28PM -0500, Eric Blake wrote: > > Upcoming patches to fix a CVE need to track an opaque pointer passed > > in by the owner of a client object, as well as reequest for a time s/reequest/request/ > > l

Re: [PATCH v4 3/7] nbd/server: CVE-2024-7409: Change default max-connections to 100

2024-08-07 Thread Eric Blake
On Wed, Aug 07, 2024 at 07:24:56PM GMT, Daniel P. Berrangé wrote: > On Wed, Aug 07, 2024 at 12:43:29PM -0500, Eric Blake wrote: > > Allowing an unlimited number of clients to any web service is a recipe > > for a rudimentary denial of service attack: the client merely needs to > > open lots of sock

Re: [PATCH v4 5/7] nbd/server: CVE-2024-7409: Close stray client sockets at shutdown

2024-08-07 Thread Eric Blake
On Wed, Aug 07, 2024 at 07:29:25PM GMT, Daniel P. Berrangé wrote: > On Wed, Aug 07, 2024 at 12:43:31PM -0500, Eric Blake wrote: > > A malicious client can attempt to connect to an NBD server, and then > > intentionally delay progress in the handshake, including if it does > > not know the TLS secre