The vulnerability, identified as GHSA-hm5p-x4rq-38w4, is a Server-Side Request Forgery (SSRF) flaw in the httparty library. The root cause is the improper handling of absolute URLs when a base_uri is configured. The analysis of the fixing commit 0529bcd6309c9fd9bfdd50ae211843b10054c240 points to the HTTParty::Request.uri method as the source of the vulnerability.
When a developer sets a base_uri for an HTTParty client, the expectation is that all subsequent requests will be directed to that domain. However, the uri method in lib/httparty/request.rb failed to enforce this. If the path argument passed to a request method (like .get or .post) was a full, absolute URL (e.g., http://malicious-site.com), the library would ignore the base_uri and send the request to the attacker-controlled URL instead.
This is a security risk because if the path can be influenced by user input, an attacker can force the application to make requests to arbitrary servers. This can be used to exfiltrate sensitive data, such as API keys or authentication tokens, which are often sent as default headers. It also allows attackers to probe internal networks accessible from the application server.
The patch rectifies this by introducing a new validate_uri_safety! method that is called from within the uri method. This new function explicitly checks if the host of the requested URL matches the host of the configured base_uri. If there is a mismatch, it raises an UnsafeURIError, effectively stopping the malicious request. Therefore, the HTTParty::Request.uri function is identified as the vulnerable function because it lacked this critical validation.