The vulnerability exists in the error handling of go-viper/mapstructure's decoding functions. When the library attempts to convert a string from user-supplied data into a more specific type (e.g., integer, time, IP address, boolean), and fails due to malformed input, it generates an error message that includes the original, potentially sensitive, input string. If an application logs these errors, it can inadvertently leak sensitive information into its logs.
The security patch addresses this by introducing custom error wrappers. These wrappers intercept the original errors from Go's standard library parsing functions (like strconv.ParseInt, time.Parse, net.ParseIP, etc.) and generate a new, sanitized error message that omits the problematic input value. The patch modifies numerous DecodeHookFunc functions in decode_hooks.go and internal decode* methods in mapstructure.go to use these new error wrappers.
Any application using mapstructure to decode untrusted data into structs containing types like int, float, bool, time.Duration, net.IP, etc., is affected. An attacker can trigger the vulnerability by providing a malformed string for one of these fields, causing the application to log an error containing the attacker-controlled (and potentially sensitive) string.