This blog talks about secure dialect negotiation, one of the new SMB3 security enhancements in Windows Server 2012.
Secure dialect negotiation is introduced in SMB3 to protect against man-in-the-middle attempt to downgrade dialect negotiation. The idea is to prevent an eavesdropper from downgrading the initially negotiated dialect and capabilities between the client and the server.
In a nutshell, upon reception of a Tree Connect response, an SMB3-capable client validates the original SMB2 Negotiate request by sending a signed IOCTL, called FSCTL_VALIDATE_NEGOTIATE_INFO as specified in [MS-SMB2]. The server needs to reply with a signed response, and this enables end-to-end validation of the Negotiate exchange.
The client sends the IOCTL only if it is implemented to request validation of an SMB2 Negotiate via the RequireSecureNegotiate abstract data element. Windows 8 clients configure this through the registry key RequireSecureNegotiate.
To change this setting, set the following LanmanWorkstation parameter using PowerShell cmdlet:
Set-SmbClientConfiguration - RequireSecureNegotiate <0|1|2>
0 – Disabled
1 – Required
2 – Enabled if needed
You can also edit the DWORD value through the registry editor. HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\RequireSecureNegotiate.
To change the default behavior, you need to define the registry key. If not present, its default value is “Required” in Windows 8 clients.
The “Enabled if needed” allows requesting secure negotiation when one of these conditions is met:
- Signing is required on the session (see MS-SMB2 and KB887429);
- Or encryption is required on the session or the share;
- Or SMB 2.24 dialect is negotiated (2.24 was the highest dialect revision in Windows 8 Beta).
The FSCTL_VALIDATE_NEGOTIATE_INFO operation allows the client and server to repeat the Negotiate process over a signed exchange. This exchange could also be sealed if encryption is enabled, i.e. Session.EncryptData or TreeConnect.EncryptData is TRUE.
The signed request allows the server to validate the client capabilities, Guid, SecurityMode, and Dialects which could be 0x0300, 0x0210, and 0x0202 (this list includes 0x0224 if you are testing Windows 8 Beta).
The signed response (success or error) enables the client to verify the outcome. On a signed success response, the client verifies that none of these attributes of the Negotiate response have been downgraded or manipulated: server capabilities, server Guid, server SecurityMode, and the connection Dialect.
If the client receives an error response, the transport connection is terminated if any of the following conditions is met:
- The response is not signed. This is applied regardless of whether signing is required or not on the connection or session.
- The status code is STATUS_ACCESS_DENIED, meaning the server could not validate the request.
- The response values (capabilities, Guid, SecurityMode, and Dialect) do not match the server values that the client originally stored on the connection object.
Note that the server would have also terminated the transport connection if it could not validate the client capabilities, Guid, SecurityMode, and Dialects.
Because the request is signed, the response must be signed as well, otherwise the client would terminate the connection. In case of 3.0 dialect, the sender computes the signature using AES_CMAC-128. For 2.002 or 2.1 dialect, the signature is derived from an HMAC-SHA256 hash.
If SMB 3.0 dialect is negotiated but the server does not support the “secure Negotiate” IOCTL, it should return a status error STATUS_NOT_SUPPORTED.
The protocol documents that a non-SMB3-capable (2.002 or 2.1) should respond to VALIDATE_NEGOTIATE_INFO request with a status error of STATUS_INVALID_DEVICE_REQUEST, the same error as for any unsupported FSCTL. Windows Server 2008 (SMB 2.002) and Windows Server 2008 R2 (SMB 2.1) return STATUS_FILE_CLOSED, instead.
As previously noted, the “secure Negotiate” relies on the correct signing of responses by all SMB 2/3 servers. This means the exchange can only occur under a user security context that is neither anonymous nor guest. Therefore, anonymous or guest sessions cannot use the secure negotiation. Keep in mind that if you enable null or guest sessions to access your shares, you leave the door open for this potential attack.
With “secure Negotiate”, it is not required that signing is active on the connection. It is inherently designed to work with servers that support unsolicited signed requests. Since Windows-based SMB1 servers do not support unsolicited signed requests, downgrading attacks from SMB 2/3 to SMB 1 cannot be detected in Windows 8. It is recommended that SMB1 is disabled if all clients in your environments are SMB2 capable (See blog post).
NOTE: At the time of writing this blog, Windows 8 and Windows Server 2012 are Release Preview (Release Candidate) in their release cycle.
Windows 8 Beta: SMB connections fail with error "Invalid Signature"
Overview of Server Message Block signing
SMB 3 Security Enhancements in Windows Server 2012