-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Hello,
I've been using the crate for authenticating a client against a remote server. I have started using the Negotiate
SSP package, and I have noticed some issues with its implementations, which I'd like to resolve. Most of those issues are relevant for non-domain environments, and it might be a misconfiguration of the provider by me.
The initialization of the provided may be seen here in my crate's source code.
Kerberos is disabled in the options of the SSP
Providing a package_list
argument to NegotiateConfig
with the value "ntlm,!kerberos,!pku2u"
, I am still seeing logs of the crate that indicate 3 attempts to perform a KDC detection using DNS(?):
[2025-05-24T14:57:07Z DEBUG smb::session] Setting up session for user LocalAdmin.
[smb/src/session/authenticator.rs:41:18] Self::get_available_ssp_pkgs(&conn_info.config.auth_methods) = "ntlm,!kerberos,!pku2u"
[2025-05-24T14:57:07Z INFO sspi::negotiate] acquire_credentials_handle_impl; protocol="NTLM"
[2025-05-24T14:57:07Z INFO sspi::negotiate] negotiate_protocol; username="LocalAdmin" domain="" protocol="NTLM"
[2025-05-24T14:57:07Z INFO sspi::kdc] detect_kdc_hosts; domain=""
[2025-05-24T14:57:07Z DEBUG sspi::kdc] detect_kdc_hosts_from_system; domain=""
[2025-05-24T14:57:07Z DEBUG sspi::kdc] return=[]
[2025-05-24T14:57:07Z DEBUG sspi::dns] detect_kdc_hosts_from_dns; domain=""
[2025-05-24T14:57:08Z ERROR sspi::dns] Timeout when reading DNS query error=deadline has elapsed
[2025-05-24T14:57:09Z ERROR sspi::dns] Timeout when reading DNS query error=deadline has elapsed
[2025-05-24T14:57:09Z DEBUG sspi::dns] return=[]
[2025-05-24T14:57:09Z INFO sspi::kdc] return=[]
[2025-05-24T14:57:09Z INFO sspi::negotiate] return=Ok(())
[2025-05-24T14:57:09Z INFO sspi::negotiate] return=Ok(AcquireCredentialsHandleResult { credentials_handle: Some(AuthIdentity(AuthIdentityBuffers { user: 0x..., domain: 0x, password: Secret })), expiry: None })
[2025-05-24T14:57:09Z INFO sspi::negotiate] initialize_security_context_impl; protocol="NTLM"
[2025-05-24T14:57:09Z INFO sspi::negotiate] negotiate_protocol; username="LocalAdmin" domain="" protocol="NTLM"
[2025-05-24T14:57:09Z INFO sspi::kdc] detect_kdc_hosts; domain=""
[2025-05-24T14:57:09Z DEBUG sspi::kdc] detect_kdc_hosts_from_system; domain=""
[2025-05-24T14:57:09Z DEBUG sspi::kdc] return=[]
[2025-05-24T14:57:09Z DEBUG sspi::dns] detect_kdc_hosts_from_dns; domain=""
[2025-05-24T14:57:10Z ERROR sspi::dns] Timeout when reading DNS query error=deadline has elapsed
[2025-05-24T14:57:11Z ERROR sspi::dns] Timeout when reading DNS query error=deadline has elapsed
[2025-05-24T14:57:11Z DEBUG sspi::dns] return=[]
[2025-05-24T14:57:11Z INFO sspi::kdc] return=[]
[2025-05-24T14:57:11Z INFO sspi::negotiate] return=Ok(())
[2025-05-24T14:57:11Z INFO sspi::negotiate] return=Ok(InitializeSecurityContextResult { status: ContinueNeeded, flags: ClientResponseFlags(0x0), expiry: None })
[2025-05-24T14:57:11Z INFO sspi::negotiate] initialize_security_context_impl; protocol="NTLM"
[2025-05-24T14:57:11Z INFO sspi::negotiate] negotiate_protocol; username="LocalAdmin" domain="" protocol="NTLM"
[2025-05-24T14:57:11Z INFO sspi::kdc] detect_kdc_hosts; domain=""
[2025-05-24T14:57:11Z DEBUG sspi::kdc] detect_kdc_hosts_from_system; domain=""
[2025-05-24T14:57:11Z DEBUG sspi::kdc] return=[]
[2025-05-24T14:57:11Z DEBUG sspi::dns] detect_kdc_hosts_from_dns; domain=""
[2025-05-24T14:57:12Z ERROR sspi::dns] Timeout when reading DNS query error=deadline has elapsed
[2025-05-24T14:57:13Z ERROR sspi::dns] Timeout when reading DNS query error=deadline has elapsed
[2025-05-24T14:57:13Z DEBUG sspi::dns] return=[]
[2025-05-24T14:57:13Z INFO sspi::kdc] return=[]
[2025-05-24T14:57:13Z INFO sspi::negotiate] return=Ok(())
[2025-05-24T14:57:13Z INFO sspi::negotiate] return=Ok(InitializeSecurityContextResult { status: Ok, flags: ClientResponseFlags(0x0), expiry: None })
[2025-05-24T14:57:13Z INFO sspi::negotiate] query_context_session_key; protocol="NTLM"
[2025-05-24T14:57:13Z DEBUG sspi::ntlm] query_context_session_key; state=Final
[2025-05-24T14:57:13Z DEBUG smb::session::signer] Signature verification passed (signature=...).
[2025-05-24T14:57:13Z DEBUG smb::session::state] Session 30786392686641 flags set: SessionFlags { is_guest: false, is_null_session: false, encrypt_data: false }
[2025-05-24T14:57:13Z INFO smb::session] Session setup complete.
Since I have disabled kerberos & pku2u completely, I do not expect any kerberos-related logic to be triggered. The most important symptom of this behavior is a major delay in the Negotiation process - using the Ntlm
SSP it takes almost no-time, but using Negotiate
this time has increased.
Kerberos is not even supported by the client
The entire scenario above is even weirder, looking at the security blob processed by SSPI.
The very first buffer passed to SSPI, which is received in the SMB2 Negotiate Protocol, is as follows:
The buffer is immediately passed to my Authenticator
module, which calls SSPI, and it takes a little more than 4 seconds for the next buffer (that the client sends to the server) to be produced by SSPI, and between the next server and client buffers, there's another 2-second gap!
Perhaps I'm missing something, but to me, it seems like the correct behavior when the only supported package by the remote is NTLM, and the only enabled package is also NTLM, to avoid using kerberos all along!
I'd love to have your ideas regarding this issue, and again - as in my previous issues, I'd love to contribute to this crate and improve it's behavior, under your guidance, of course.
Thanks!