1. 22 Nov, 2021 1 commit
  2. 21 Nov, 2021 2 commits
  3. 18 Oct, 2021 2 commits
  4. 04 Oct, 2021 4 commits
  5. 03 Sep, 2021 4 commits
    • Eric Blake's avatar
      spec: Relax NBD_OPT_LIST_META_CONTEXTS · 13a4e33a
      Eric Blake authored
      Using OPT_SET_META_CONTEXTS is stateful (it is documented to wipe out
      any previously-requested contexts, and we just tightened the spec to
      clarify that starting TLS also wipes it out).  But
      OPT_LIST_META_CONTEXTS is not stateful; and in fact, with a
      SELECTIVETLS server, it can be handy to list the meta contexts
      available on an unencrypted export, then enable encryption, and then
      further list what contexts are available on encrypted exports (as the
      server is permitted to let those lists differ).  Although such a
      client must negotiate structured replies after starttls if it is going
      to actually connect to an export, this change permits the client to
      shorten the handshake by two commands if it is only being used to list
      available exports and their meta contexts before disconnecting.
      13a4e33a
    • Eric Blake's avatar
      client: Don't confuse Unix socket with TLS hostname · d8a6d0b0
      Eric Blake authored
      When using -u but not -H, we were ending up calling
      gnutls_session_set_verify_cert() with the Unix socket's path name,
      which is bound to fail (hostnames don't start with /).  Saner is to
      only default tlshostname when using TCP sockets.
      
      See also https://gitlab.com/nbdkit/nbdkit/-/issues/1
      
      , as this was
      detected during an attempt to prove TLS interoperability between
      nbd-client and nbdkit.  Pre-patch, I have to add '-H localhost' to the
      nbd-client command line when using nbdkit with a Unix socket, but not
      when using a TCP socket; post-patch, I can omit -H and still connect
      /dev/nbd0 over TLS using either TCP or Unix.
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      d8a6d0b0
    • Eric Blake's avatar
      server: Avoid deprecated g_memdup · ecada459
      Eric Blake authored
      glib now recommends that we use g_memdup2() to avoid accidental 32-bit
      truncation bugs on platforms where g_size is larger than guint:
      
      https://discourse.gnome.org/t/port-your-module-from-g-memdup-to-g-memdup2-now/5538
      
      and failure to do so causes noisy compilation due to deprecation
      warnings with glib 2.68:
      
      nbd-server.c: In function ‘parse_cfile’:
      nbd-server.c:1010:25: warning: ‘g_memdup’ is deprecated: Use 'g_memdup2' instead [-Wdeprecated-declarations]
       1010 |                         SERVER *srv = serve_inc_ref(g_memdup(&s, sizeof(SERVER)));
            |                         ^~~~~~
      In file included from /usr/include/glib-2.0/glib.h:82,
                       from nbd-server.c:117:
      /usr/include/glib-2.0/glib/gstrfuncs.h:257:23: note: declared here
        257 | gpointer              g_memdup         (gconstpointer mem,
            |                       ^~~~~~~~
      
      Of course, we still want to build on platforms with older glib that
      lack g_memdup2().  Thankfully, it's easy enough to audit that all our
      current uses of g_memdup() do not overflow 32 bits.
      ecada459
    • Wouter Verhelst's avatar
  6. 25 Aug, 2021 1 commit
    • Eric Blake's avatar
      spec: Clarify NBD_FLAG_ vs. MitM downgrade attack · ac88ec74
      Eric Blake authored
      Codify the fact that downgrade attacks are possible not only by
      manipulation of NBD_OPT_STARTTLS, but also by manipulation of the
      NBD_FLAG[_C]_* handshake flags.  To ensure we don't accidentally
      introduce a new MitM attack vector, we want the specification to
      clearly document that controlling any new protocol changes prior to
      TLS is unwise, and therefore we are unlikely to add any new handshake
      flags.
      
      Viewed from another perspective, the 16 bits for handshake flags
      control the protocol used during NBD_OPT_*, but what we have with
      NBD_FLAG_FIXED_NEWSTYLE is already fairly robust for future extension
      (since all but NBD_OPT_EXPORT_NAME encode a length, and we've gone to
      great lengths to document what servers and clients should do with
      unknown requests).  Meanwhile, any extension that wants to affect the
      protocol used by transmission phase, such as structured replies, is
      fine waiting until after TLS is started.
      
      The expense of an extra round trip or two during NBD_OPT_ haggling
      pales in comparison to the amount of data that will go over the wire
      during transmission phase; and if startup efficiency really matters,
      we could add a new NBD_OPT_ that does more things in one round trip
      (where the fallback is still the older one-at-a-time approach).
      ac88ec74
  7. 16 Aug, 2021 1 commit
    • Eric Blake's avatar
      spec: Clarify STARTTLS vs. STRUCTURED_REPLY · 77e55378
      Eric Blake authored
      Consider a SELECTIVETLS server and a MitM attacker, under the
      following NBD_OPT_ handshake scenario:
      
       client:                  mitm:                    server:
       > _STARTTLS
                                > _STRUCTURED_REPLY
                                                         < _REP_ACK
                                > _STARTTLS
                                                         < _REP_ACK
                                < _REP_ACK
       > _GO
                                > _GO
                                                         < _REP_ACK
                                < _REP_ACK
       > NBD_CMD_READ
      
      In this scenario, the client is NOT expecting structured replies from
      the server, but if the server feels obligated to send them based on
      the plaintext negotiation, it may confuse the client.  The MitM
      attacker was thus able to corrupt the connection, even without having
      any encryption keys.  The only sane approach is to forbid ALL stateful
      negotiations from having any effect post-encryption (the MitM's
      injected packet is effectively ignored, and the client proceeds
      without structured replies).
      
      Unfortunately, nbdkit 1.26.0 is buggy in this regards - a CVE will be
      opened against that product.  nbd-server does not yet understand
      NBD_OPT_STRUCTURED_REPLY, and qemu as server does not use SELECTIVETLS
      mode, so they are immune.
      77e55378
  8. 12 Aug, 2021 1 commit
    • Eric Blake's avatar
      spec: Clarify STARTTLS vs. SET_META_CONTEXT interaction · b7cb250c
      Eric Blake authored
      Consider a SELECTIVETLS server and a MitM attacker, under the
      following NBD_OPT_ handshake scenario:
      
       client:                  mitm:                    server:
       > _STARTTLS
                                > _SET_META_CONTEXT("A")
                                                         < _REP_META_CONTEXT
                                                         < _REP_ACK
                                > _STARTTLS
                                                         < _REP_ACK
                                < _REP_ACK
       > _SET_META_CONTEXT("B")
                                < _REP_META_CONTEXT
                                < _REP_ACK
       > _GO
                                > _GO
                                                         < _REP_ACK
                                < _REP_ACK
       > NBD_CMD_BLOCK_STATUS
      
      While this scenario requires the MitM to be able to use encryption to
      speak to the client (and thus a less likely scenario than a true
      protocol downgrade or plaintext buffering attack), it results in a
      situation where the client is asking for information on context "B",
      but where the server only saw a request for context "A", which may
      result in the client interpreting the results of BLOCK_STATUS
      incorrectly even though it is coming over an encrypted connection.
      
      The safest fix to this is to require that a server cannot use any meta
      context requests from prior to enabling encryption with any successful
      NBD_OPT_GO after encryption.  At this point, the spec already states
      that the server should then return an error (the client is asking for
      block status without proper negotiation), which is better than letting
      the client blindly misinterpret a response sent for a different meta
      context.
      
      To date, the only known server that has implemented TLS with
      SELECTIVETLS mode as well as support for NBD_OPT_SET_META_CONTEXT is
      nbdkit (qemu-nbd only has FORCEDTLS mode, and nbd-server lacks meta
      context support); thankfully, that implementation is in already line
      with this stricter requirement.
      b7cb250c
  9. 11 Aug, 2021 1 commit
    • Eric Blake's avatar
      docs: Link to protocol security considerations in uri docs · f44065cf
      Eric Blake authored
      Especially useful in light of the recent publishing of
      https://nostarttls.secvuln.info/, which documents a variety of
      implementations vulnerable to downgrade attacks in SMTP and IMAP, as
      well as its caution that that any protocol with a STARTTLS operation
      (which includes NBD) needs to be aware of the potential for downgrade
      attacks.
      
      The NBD protocol documentation already covers what is necessary to
      avoid the effects of a downgrade attack, and all known implementations
      of NBD servers and clients with working NBD_OPT_STARTTLS have at least
      one mode where TLS is mandatory rather than opportunistic.  So I don't
      see this as a CVE against the NBD protocol itself, so much as a worry
      about the potential for future poor implementations that disregard the
      documentation.
      f44065cf
  10. 10 Aug, 2021 1 commit
  11. 08 Aug, 2021 1 commit
  12. 05 Aug, 2021 1 commit
  13. 30 Jul, 2021 3 commits
  14. 01 Jun, 2021 1 commit
  15. 26 May, 2021 1 commit
  16. 10 May, 2021 1 commit
  17. 24 Feb, 2021 1 commit
  18. 18 Jan, 2021 2 commits
  19. 17 Jan, 2021 1 commit
  20. 06 Oct, 2020 2 commits
  21. 05 Oct, 2020 1 commit
  22. 17 Mar, 2020 1 commit
  23. 07 Feb, 2020 2 commits
    • Wouter Verhelst's avatar
      NBD_REP_ERR_PLATFORM: make useful · cb20c163
      Wouter Verhelst authored
      "not available on this platform" is rather weird, and probably too narrow a
      choice. "not enabled at compile time" might be slightly more useful, and
      nbd-server uses that for STARTTLS when it was disabled currently.
      
      This might be a good idea, so explicitly allow for it.
      cb20c163
    • Vladimir Sementsov-Ogievskiy's avatar
      doc/proto: drop max-block restriction for data-less commands · 9f30fedb
      Vladimir Sementsov-Ogievskiy authored and Wouter Verhelst's avatar Wouter Verhelst committed
      
      
      max-block restriction make sense for NBD_CMD_WRITE and NBD_CMD_READ to
      avoid big data transfer and long io operations at server side.
      NBD_CMD_WRITE_ZEROES still may be realized on server through direct
      writing zeroes, which may lead to long operation and huge allocation
      and should be restricted by max-block.
      Same for NBD_CMD_CACHE: long operation / big allocation.
      
      Still, NBD_CMD_TRIM, NBD_CMD_BLOCK_STATUS and NBD_CMD_WRITE_ZEROES with
      NBD_CMD_FLAG_FAST_ZERO set are over-restricted by it. So, for better
      performance, drop these restrictions.
      
      Note, that Qemu nbd server already works accordingly to this patch: it
      doesn't check the restriction for NBD_CMD_TRIM, NBD_CMD_BLOCK_STATUS
      and NBD_CMD_WRITE_ZEROES.
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      9f30fedb
  24. 02 Jan, 2020 1 commit
  25. 01 Jan, 2020 3 commits