The vulnerability lies in how the go-ntlmssp library parses NTLM challenge messages. An integer overflow vulnerability exists in the varField.ReadFrom function located in varfield.go. When parsing a field from the challenge, the code calculates the field's size by adding an offset and a length. Both are 32-bit integers. A remote attacker can craft a malicious challenge message with a large length value that, when added to the offset, overflows and wraps around to a small number. This bypasses the buffer size check. However, the subsequent memory slice operation uses the original, non-overflowed length, leading to a 'slice bounds out of range' panic and crashing the application, resulting in a denial of service.
The patch, identified in commit bd8579c18d41bf5d91a5f74b1117c958f635b866, fixes this by promoting the offset and length to 64-bit integers before addition and explicitly checking for a wraparound condition. The analysis identified two key functions:
varField.ReadFrom: This is the low-level function where the flawed integer arithmetic and subsequent panic occur. The patch directly modifies this function to add security checks.
NewAuthenticateMessage: This higher-level function is responsible for orchestrating the parsing of the challenge message. The new test case added in the patch directly calls this function to validate the fix, confirming it's a primary entry point for the vulnerable code path.