Skip to content

Bug: Listing shares with smb-cli fails on Windows Server 2016 #153

@thatliuser

Description

@thatliuser

Describe the bug

Expected cargo run -- --username <user> --password <password> info '\\\\<ip>' to return the shares available on the SMB server. Instead, the CLI times out while waiting for a response from the server, and debug logs show that the library is failing to parse a server response. The corresponding command with samba (smbclient -L '<ip>' -U '<user>%<password>') works fine.

To Reproduce

Create a Windows Server 2016 VM and use smb-cli with the pattern specified above.

Environment details

  • If this is a runtime failure, please provide:

    • SMB server version - Windows Server 2016, Version 1607 (OS Build 14393.1884)
    • Default client config specified in the smb-cli tool
  • Crate version: 0.10.3 (latest on crates.io)

  • OS, architecture & version: NixOS Linux 25.11 (Xantusia), rustc 1.92.0-nightly (844264add 2025-10-14), x86_64-unknown-linux-gnu

Logs

Please provide a detailed log of the issue.

Preferably, run with RUST_LOG=DEBUG.

[2025-11-12T10:43:41Z DEBUG smb_cli] Starting smb-cli 0.10.3
[2025-11-12T10:43:41Z INFO  smb_cli] Getting info for UncPath { server: "10.218.0.142", share: Some(""), path: None }
[2025-11-12T10:43:41Z DEBUG smb::client::smb_client] Creating new connection to 10.218.0.142
[2025-11-12T10:43:41Z INFO  smb::connection] Connecting to 10.218.0.142 (at 10.218.0.142:445)...
[2025-11-12T10:43:41Z DEBUG smb_transport::tcp::transport] Connecting to 10.218.0.142:445 with timeout 10s.
[2025-11-12T10:43:41Z INFO  smb::connection] Connected to 10.218.0.142. Negotiating.
[2025-11-12T10:43:41Z DEBUG smb::connection] Negotiating multi-protocol: Sending SMB1
[2025-11-12T10:43:41Z DEBUG smb::connection] Sent SMB1 negotiate request, Receieving SMB2 response
[2025-11-12T10:43:41Z DEBUG smb::connection] Negotiating SMB2
[2025-11-12T10:43:41Z DEBUG smb::connection::worker::parallel::async_backend] Starting worker loop.
[2025-11-12T10:43:41Z DEBUG smb::connection::worker::parallel::async_backend] Starting worker loop.
[2025-11-12T10:43:41Z DEBUG smb::connection] Negotiation successful
[2025-11-12T10:43:41Z DEBUG smb::client::smb_client] Successfully connected to 10.218.0.142
[2025-11-12T10:43:41Z DEBUG smb::session::setup] Setting up session for user Administrator (@).
[2025-11-12T10:43:41Z DEBUG smb::connection::transformer] Message #3 verified (signature=56682749491353692311637677970846781042).
[2025-11-12T10:43:41Z DEBUG smb::session::state] Session 61574261768193 flags set: SessionFlags { is_guest: false, is_null_session: false, encrypt_data: false }
[2025-11-12T10:43:41Z DEBUG smb::session] Session setup complete.
[2025-11-12T10:43:41Z DEBUG smb::client::smb_client] Successfully authenticated to 10.218.0.142 as Administrator
[2025-11-12T10:43:41Z DEBUG smb::connection::transformer] Message #4 signed (signature=122588465504349257840614382606255635630).
[2025-11-12T10:43:42Z DEBUG smb::connection::transformer] Message #4 verified (signature=170081860818782524782827460295829966597).
[2025-11-12T10:43:42Z INFO  smb::tree] Connected to tree \\10.218.0.142\IPC$ (#1)
[2025-11-12T10:43:42Z DEBUG smb::client::smb_client] Successfully connected to share: IPC$
[2025-11-12T10:43:42Z DEBUG smb::connection::transformer] Message #5 signed (signature=222158658012019594102351112869751799697).
[2025-11-12T10:43:42Z ERROR smb::connection::worker::parallel::base] Failed to transform message: BinRWError(no variants matched at 0x0:
      Plain:
     ╺━━━━━━━━━━━━━━━━━━━━┅ Backtrace ┅━━━━━━━━━━━━━━━━━━━━╸

     0: Error: no variants matched at 0x40...
       ╭───────────────────────┄ Negotiate ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Negotiate)` at 0x40
       ╰────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ SessionSetup ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: SessionSetup)` at 0x40
       ╰───────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Logoff ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Logoff)` at 0x40
       ╰─────────────────────────────────────────────────────┄
       ╭───────────────────────┄ TreeConnect ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: TreeConnect)` at 0x40
       ╰──────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ TreeDisconnect ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: TreeDisconnect)` at 0x40
       ╰─────────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Create ┄────────────────────┄
       ┆
       ┆ 0: Error: assertion failed: `_reserved2 == 0` at 0x40
       ┆           While parsing field 'self_0' in ResponseContent::Create
       ┆     at crates/smb-msg/src/plain.rs:216
       ┆  ┄───╮
       ┆   78 ⎬               $struct_pfx::[<$cmd Request>]),
       ┆   79 |      )*
       ┆   80 |
       ┆   81 |      // cancel request
       ┆   82 |      #[br(pre_assert(matches!(command, Command::Cancel)))]
       ┆   83 |      Cancel(cancel::CancelRequest),
       ┆   84 |
       ┆   85 |      // oplock
       ┆   86 |      #[br(pre_assert(matches!(command, Command::OplockBreak)))]
       ┆   87 |      OplockBreakAck(oplock::OplockBreakAck),
       ┆   88 |      #[br(pre_assert(matches!(command, Command::OplockBreak)))]
       ┆   89 |      LeaseBreakAck(oplock::LeaseBreakAck),
       ┆   90 |  }
       ┆   91 |
       ┆   92 |  #[derive(BinRead, BinWrite, Debug)]
       ┆   93 |  #[brw(import(command: &Command))]
       ┆   94 |  #[brw(little)]
       ┆   95 |  pub enum ResponseContent {
       ┆   96 |      $(
       ┆   97 |          #[br(pre_assert(matches!(command, Command::$cmd)))]
       ┆   98 |          $cmd($struct_pfx::[<$cmd Response>]
       ┆  ┄───╯
       ┆
       ╰─────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Close ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Close)` at 0x40
       ╰────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Flush ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Flush)` at 0x40
       ╰────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Read ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Read)` at 0x40
       ╰───────────────────────────────────────────────────┄
       ╭───────────────────────┄ Write ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Write)` at 0x40
       ╰────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Lock ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Lock)` at 0x40
       ╰───────────────────────────────────────────────────┄
       ╭───────────────────────┄ Ioctl ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Ioctl)` at 0x40
       ╰────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Echo ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Echo)` at 0x40
       ╰───────────────────────────────────────────────────┄
       ╭───────────────────────┄ QueryDirectory ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: QueryDirectory)` at 0x40
       ╰─────────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ ChangeNotify ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: ChangeNotify)` at 0x40
       ╰───────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ QueryInfo ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: QueryInfo)` at 0x40
       ╰────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ SetInfo ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: SetInfo)` at 0x40
       ╰──────────────────────────────────────────────────────┄
       ╭───────────────────────┄ OplockBreakNotify ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: OplockBreak)` at 0x40
       ╰────────────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ LeaseBreakNotify ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: OplockBreak)` at 0x40
       ╰───────────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ OplockBreak ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: OplockBreak)` at 0x40
       ╰──────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ LeaseBreak ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: OplockBreak)` at 0x40
       ╰─────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ ServerToClientNotification ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: ServerToClientNotification)` at 0x40
       ╰─────────────────────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Error ┄────────────────────┄
       ┆
       ┆ 0: Error: assertion failed: `_structure_size == 9` at 0x40
       ┆           While parsing field 'self_0' in ResponseContent::Error
       ┆     at crates/smb-msg/src/plain.rs:216
       ┆  ┄────╮
       ┆   115 ⎬  error::ErrorResponse
       ┆  ┄────╯
       ┆
       ╰────────────────────────────────────────────────────┄
        ...While parsing field 'content' in PlainResponse
         at crates/smb-msg/src/plain.rs:324
      ┄────╮
       280 |  #[brw(args(&header.command))]
       281 ⎬  pub content: [<$suffix Content>]
      ┄────╯
     1: While parsing field 'self_0' in Response::Plain
         at crates/smb-msg/src/message.rs:24
      ┄──╮
       9 ⎬  $plain_type
      ┄──╯

     ╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸


      Encrypted:
     ╺━━━━━━━━━━━━━━━━━━━━┅ Backtrace ┅━━━━━━━━━━━━━━━━━━━━╸

     0: Error: bad magic at 0x0: [254, 83, 77, 66]
               While parsing field 'header' in EncryptedMessage
         at crates/smb-msg/src/encrypted.rs:56
      ┄───╮
       56 ⎬  pub header: EncryptedHeader
      ┄───╯
     1: While parsing field 'self_0' in Response::Encrypted
         at crates/smb-msg/src/message.rs:24
      ┄───╮
       10 ⎬  $crate::EncryptedMessage
      ┄───╯

     ╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸


      Compressed:
     ╺━━━━━━━━━━━━━━━━━━━━┅ Backtrace ┅━━━━━━━━━━━━━━━━━━━━╸

     0: Error: no variants matched at 0x0...
       ╭───────────────────────┄ Unchained ┄────────────────────┄
       ┆
       ┆ 0: Error: bad magic at 0x0: [254, 83, 77, 66]
       ┆           While parsing field 'self_0' in CompressedMessage::Unchained
       ┆     at crates/smb-msg/src/compressed.rs:11
       ┆  ┄───╮
       ┆   15 ⎬  CompressedUnchainedMessage
       ┆  ┄───╯
       ┆
       ╰────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Chained ┄────────────────────┄
       ┆
       ┆ 0: Error: bad magic at 0x0: [254, 83, 77, 66]
       ┆           While parsing field 'self_0' in CompressedMessage::Chained
       ┆     at crates/smb-msg/src/compressed.rs:11
       ┆  ┄───╮
       ┆   16 ⎬  CompressedChainedMessage
       ┆  ┄───╯
       ┆
       ╰──────────────────────────────────────────────────────┄
        ...While parsing field 'self_0' in Response::Compressed
         at crates/smb-msg/src/message.rs:24
      ┄───╮
       11 ⎬  $crate::CompressedMessage
      ┄───╯

     ╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸

    )
[2025-11-12T10:43:42Z ERROR smb::connection::worker::parallel::async_backend] Error in worker loop: Binrw Error: no variants matched at 0x0:
      Plain:
     ╺━━━━━━━━━━━━━━━━━━━━┅ Backtrace ┅━━━━━━━━━━━━━━━━━━━━╸

     0: Error: no variants matched at 0x40...
       ╭───────────────────────┄ Negotiate ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Negotiate)` at 0x40
       ╰────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ SessionSetup ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: SessionSetup)` at 0x40
       ╰───────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Logoff ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Logoff)` at 0x40
       ╰─────────────────────────────────────────────────────┄
       ╭───────────────────────┄ TreeConnect ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: TreeConnect)` at 0x40
       ╰──────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ TreeDisconnect ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: TreeDisconnect)` at 0x40
       ╰─────────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Create ┄────────────────────┄
       ┆
       ┆ 0: Error: assertion failed: `_reserved2 == 0` at 0x40
       ┆           While parsing field 'self_0' in ResponseContent::Create
       ┆     at crates/smb-msg/src/plain.rs:216
       ┆  ┄───╮
       ┆   78 ⎬               $struct_pfx::[<$cmd Request>]),
       ┆   79 |      )*
       ┆   80 |
       ┆   81 |      // cancel request
       ┆   82 |      #[br(pre_assert(matches!(command, Command::Cancel)))]
       ┆   83 |      Cancel(cancel::CancelRequest),
       ┆   84 |
       ┆   85 |      // oplock
       ┆   86 |      #[br(pre_assert(matches!(command, Command::OplockBreak)))]
       ┆   87 |      OplockBreakAck(oplock::OplockBreakAck),
       ┆   88 |      #[br(pre_assert(matches!(command, Command::OplockBreak)))]
       ┆   89 |      LeaseBreakAck(oplock::LeaseBreakAck),
       ┆   90 |  }
       ┆   91 |
       ┆   92 |  #[derive(BinRead, BinWrite, Debug)]
       ┆   93 |  #[brw(import(command: &Command))]
       ┆   94 |  #[brw(little)]
       ┆   95 |  pub enum ResponseContent {
       ┆   96 |      $(
       ┆   97 |          #[br(pre_assert(matches!(command, Command::$cmd)))]
       ┆   98 |          $cmd($struct_pfx::[<$cmd Response>]
       ┆  ┄───╯
       ┆
       ╰─────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Close ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Close)` at 0x40
       ╰────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Flush ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Flush)` at 0x40
       ╰────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Read ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Read)` at 0x40
       ╰───────────────────────────────────────────────────┄
       ╭───────────────────────┄ Write ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Write)` at 0x40
       ╰────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Lock ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Lock)` at 0x40
       ╰───────────────────────────────────────────────────┄
       ╭───────────────────────┄ Ioctl ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Ioctl)` at 0x40
       ╰────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Echo ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: Echo)` at 0x40
       ╰───────────────────────────────────────────────────┄
       ╭───────────────────────┄ QueryDirectory ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: QueryDirectory)` at 0x40
       ╰─────────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ ChangeNotify ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: ChangeNotify)` at 0x40
       ╰───────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ QueryInfo ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: QueryInfo)` at 0x40
       ╰────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ SetInfo ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: SetInfo)` at 0x40
       ╰──────────────────────────────────────────────────────┄
       ╭───────────────────────┄ OplockBreakNotify ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: OplockBreak)` at 0x40
       ╰────────────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ LeaseBreakNotify ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: OplockBreak)` at 0x40
       ╰───────────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ OplockBreak ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: OplockBreak)` at 0x40
       ╰──────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ LeaseBreak ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: OplockBreak)` at 0x40
       ╰─────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ ServerToClientNotification ┄────────────────────┄
       ┆
       ┆assertion failed: `matches! (command, Command :: ServerToClientNotification)` at 0x40
       ╰─────────────────────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Error ┄────────────────────┄
       ┆
       ┆ 0: Error: assertion failed: `_structure_size == 9` at 0x40
       ┆           While parsing field 'self_0' in ResponseContent::Error
       ┆     at crates/smb-msg/src/plain.rs:216
       ┆  ┄────╮
       ┆   115 ⎬  error::ErrorResponse
       ┆  ┄────╯
       ┆
       ╰────────────────────────────────────────────────────┄
        ...While parsing field 'content' in PlainResponse
         at crates/smb-msg/src/plain.rs:324
      ┄────╮
       280 |  #[brw(args(&header.command))]
       281 ⎬  pub content: [<$suffix Content>]
      ┄────╯
     1: While parsing field 'self_0' in Response::Plain
         at crates/smb-msg/src/message.rs:24
      ┄──╮
       9 ⎬  $plain_type
      ┄──╯

     ╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸


      Encrypted:
     ╺━━━━━━━━━━━━━━━━━━━━┅ Backtrace ┅━━━━━━━━━━━━━━━━━━━━╸

     0: Error: bad magic at 0x0: [254, 83, 77, 66]
               While parsing field 'header' in EncryptedMessage
         at crates/smb-msg/src/encrypted.rs:56
      ┄───╮
       56 ⎬  pub header: EncryptedHeader
      ┄───╯
     1: While parsing field 'self_0' in Response::Encrypted
         at crates/smb-msg/src/message.rs:24
      ┄───╮
       10 ⎬  $crate::EncryptedMessage
      ┄───╯

     ╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸


      Compressed:
     ╺━━━━━━━━━━━━━━━━━━━━┅ Backtrace ┅━━━━━━━━━━━━━━━━━━━━╸

     0: Error: no variants matched at 0x0...
       ╭───────────────────────┄ Unchained ┄────────────────────┄
       ┆
       ┆ 0: Error: bad magic at 0x0: [254, 83, 77, 66]
       ┆           While parsing field 'self_0' in CompressedMessage::Unchained
       ┆     at crates/smb-msg/src/compressed.rs:11
       ┆  ┄───╮
       ┆   15 ⎬  CompressedUnchainedMessage
       ┆  ┄───╯
       ┆
       ╰────────────────────────────────────────────────────────┄
       ╭───────────────────────┄ Chained ┄────────────────────┄
       ┆
       ┆ 0: Error: bad magic at 0x0: [254, 83, 77, 66]
       ┆           While parsing field 'self_0' in CompressedMessage::Chained
       ┆     at crates/smb-msg/src/compressed.rs:11
       ┆  ┄───╮
       ┆   16 ⎬  CompressedChainedMessage
       ┆  ┄───╯
       ┆
       ╰──────────────────────────────────────────────────────┄
        ...While parsing field 'self_0' in Response::Compressed
         at crates/smb-msg/src/message.rs:24
      ┄───╮
       11 ⎬  $crate::CompressedMessage
      ┄───╯

     ╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸


[2025-11-12T10:43:52Z ERROR smb_cli] Error: Operation timed out: ReceiveNextMessage, took >10s
[2025-11-12T10:43:52Z DEBUG smb::connection::transformer] Message #6 signed (signature=331079551414859576596053049786495956981).
[2025-11-12T10:43:52Z INFO  smb::connection] Notification handler stopped.
[2025-11-12T10:43:52Z ERROR smb::tree] Failed to disconnect from tree \\10.218.0.142\IPC$: Message processing failed. Failed to send message to worker!
Error: OperationTimeout(ReceiveNextMessage, 10s)

I'm choosing to keep the IP and username of the connection as it's non-sensitive (this is a test VM running on a private network on Proxmox)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions