Skip to content
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

Raise if the root domain changed unexepectedly #321

Merged
merged 2 commits into from
Feb 18, 2022

Conversation

Wardormeur
Copy link

Due to the concatenation of domains, it's possible to spoof the information into something unexpected, leading essentially to a Server Side Request Forgery.

Instead of validating the api-key format, which could change and could be escaped by playing cat/mouse game around allowed characters/encoding, I've preferred relying on the Ruby parsing of URL post-creation to ensure that the end result is what we expect.

The error itself is not very self-explanatory, happy to change it if you have a better idea :)
Cheers

@amro amro merged commit 6933225 into amro:master Feb 18, 2022
@amro
Copy link
Owner

amro commented Feb 18, 2022 via email

@phosphore
Copy link

phosphore commented Feb 22, 2022

I don’t believe the fix completely resolves the issue, since the use of include (api_request.rb) is not sufficient to prevent the injection of arbitrary hostnames. An attacker could still inject a FQDN containing api.mailchimp.com as a subdomain. The end_with? String class method should be used instead.

2.6.3 :001 > computed_api_endpoint = "https://foe.api.mailchimp.com.attacker.com/?api.mailchimp.com"
 => "https://foe.api.mailchimp.com.attacker.com/?api.mailchimp.com" 
2.6.3 :002 > URI(computed_api_endpoint).host
 => "foe.api.mailchimp.com.attacker.com" 
2.6.3 :003 > URI(computed_api_endpoint).host.include?("api.mailchimp.com")
 => true 

If possible, issue an advisory using the GitHub Security Advisories feature on the repository.

@amro
Copy link
Owner

amro commented Feb 23, 2022

Makes sense -- thanks @phosphore! Are you up for drafting a PR? If not I can get to it soon

@amro
Copy link
Owner

amro commented Feb 24, 2022

I'm going to solve this a different way

@brendon
Copy link

brendon commented Apr 27, 2022

Just wondering, how can we tell if we’re vulnerable to this? Is there a specific use of the gem to look out for?

@amro
Copy link
Owner

amro commented Apr 27, 2022

Latest version has a fix, but please note this would only be a problem if you accepted an API key via user input (eg via a web form)

@brendon
Copy link

brendon commented Apr 27, 2022

Ah righty, we just use it to populate our own mail chimp account with subscribers when new users are created so the API key is hard coded.

@amro
Copy link
Owner

amro commented Apr 27, 2022 via email

@olliebennett
Copy link

olliebennett commented Apr 29, 2022

Thanks for this. Glad to hear it's not a threat when the API key is static.

I agree the end_with? option suggested should work. @amro I see you've implemented a check on the input value in cade20c so it seems that 3.4.4 should be protected entirely; is that right?

The current GitHub advisory states;

A partial fix has been introduced in version 3.4.4, however a complete fix has not yet been created

Thanks for all your efforts maintaining this gem! 👍

For reference, this vulnerability is tracked as;

@amro
Copy link
Owner

amro commented Apr 29, 2022

That's correct, I implemented what I believe is a complete fix in 3.4.4.

@enthusiasmus
Copy link

enthusiasmus commented May 2, 2022

When the version 3.4.4. fixes the vulnerability, who is then closing the CVE? "bundler-audit" warns us still about this CVE
Thank you!

@amro
Copy link
Owner

amro commented May 2, 2022

Thanks, as I didn't open these CVEs I'm actually not sure how to close/resolve them. Forgive my ignorance there, but any pointers would be appreciated!

@Plsr
Copy link

Plsr commented May 3, 2022

Hi, at least for GHSA I was able to submit a PR so it now states 3.4.4 as the patched version GHSA-vx9g-377x-xwxq

Not sure what the process to get the same done for the CVE would be, unfortunately.

@amro
Copy link
Owner

amro commented May 4, 2022 via email

@claudiovf
Copy link

claudiovf commented May 4, 2022

Hi @amro I found this CVE form, that could maybe be a way to get the report updated.

also, thanks for all the work maintaining this 😎

@amro
Copy link
Owner

amro commented May 4, 2022

Thank you very much @claudiovf! I just filled out the form.

Again, for folks who run across this in the future and want to assess risk for their projects: the exploit would only be possible if you accepted unvalidated user-provided APIs (eg via form input)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants