-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
missing input validation leads to potential data exposure or unintended data manipulation #541
Comments
I believe the best solution would be to refactor the calls to RawRequest in a way that makes sure that path segments are safely escaped using url.PathEscape. This could be done by introducing a new function called SafeRawRequest with a different signature: // SafeRawRequest accepts a verb, URL, and RequestOptions struct and returns the
// constructed http.Request and any errors that occurred.
func (c *Client) SafeRawRequest(verb string, pathSegments []string, ro *RequestOptions) (*http.Request, error) {
// Ensure we have request options.
if ro == nil {
ro = new(RequestOptions)
}
safePaths := make([]string, len(pathSegments))
for i, pathSegment := range pathSegments {
safePaths[i] = url.PathEscape(pathSegment)
}
u := url.JoinPath(c.url.String(), safePaths...)
// Existing logic for building and returning the request
// ...
} |
We're struggling a bit to understand the nature of the potential exposure here. In the first sentence you've used the terms 'bad actor' and 'you', and based on my reading the 'bad actor' is someone who has received a Fastly API token and 'you' is the owner of that token. If that's the case, then the 'bad actor' already has access to all content that is available to that token, regardless of whether they use go-fastly properly or improperly. Can you describe a real-world attack that is possible using this mechanism, which exposes data that isn't already visible to the attacker? |
Thanks for your response. I understand that a valid API token already gives access to data, but the main concern is when inputs come from third-party sources or external systems. In such cases, untrusted inputs can be manipulated to change the API call, exposing more data than intended. For example, if a service ID comes from a third party, they could alter it to switch from I noticed that the library already uses I hope this explains the potential issue, otherwise please let me know. |
If the 'service ID comes from a third party' but the API token does not come from the same third party, then there is already a significant risk of information disclosure because the third party could provide any SID they wish and if the API token has access to that SID then the third party will be able to obtain information about it. The API library assumes that the user of the library either owns all of the data provided to it, or has done its own sanity checking before providing the data to the library. The uses of While we would certainly consider a PR to provide code that validates SIDs to be of the proper format, there's a bit of a 'slippery slope' issue, because as soon as we start down the road of input validation we're essentially committed to reviewing every code path and implementing validation everywhere. I think it's more prudent for us to just document (if necessary) that users of this API library, and all of our other API libraries, should not pass through untrusted input directly to the library. This is the same posture that SQL interface libraries generally take, and many other libraries as well: if the source of the data is not trusted, then the receiver of the data is obligated to validate it before passing it on. |
I understand your point, but I still think input validation in the library is important. Here's why:
I understand you might be worried about having to add checks everywhere. Maybe we could start with just handling what we know is better, e.g., ensuring SIDs are alphanumeric. |
Absolutely, it would be quite welcome. |
@kpfleming just a friendly ping that I've added pr #543 |
Yep, it's known... we've just been quite busy :-) |
There should be a go-fastly release tomorrow, and a CLI release tomorrow or Monday. |
After further discussion prompted by some additional API endpoints being added to the package, we've decided to revert #543 and implement a different solution in #544. That solution is not specific to service IDs and won't generate explicit errors when service IDs are not in a valid format. Instead, what will happen if "1234/details" is passed as a service ID is that the resulting URL will look like |
Yes I think this is better which is what I initially proposed ;) |
The go-fastly library doesn't validate most inputs, allowing a bad actor to misuse the library and potentially gain access to data that you do not want to expose.
This simple example demonstrates how the
GetService
call can be altered into aGetServiceDetails
call by manipulating the input.Note that the output of the code does indeed show that GetServiceDetails is called but errors on the JSON unmarshal. Still, the error does contain most of the service details.
This vulnerability could allow attackers to craft inputs that invoke unintended API calls, leading to potential data exposure or manipulation.
The text was updated successfully, but these errors were encountered: