Skip to content

Raise if the root domain changed unexepectedly#321

Merged
amro merged 2 commits into
amro:masterfrom
Wardormeur:error-invalid-domain
Feb 18, 2022
Merged

Raise if the root domain changed unexepectedly#321
amro merged 2 commits into
amro:masterfrom
Wardormeur:error-invalid-domain

Conversation

@Wardormeur

Copy link
Copy Markdown

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

amro commented Feb 18, 2022 via email

Copy link
Copy Markdown
Owner

@phosphore

phosphore commented Feb 22, 2022

Copy link
Copy Markdown

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

amro commented Feb 23, 2022

Copy link
Copy Markdown
Owner

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

@amro

amro commented Feb 24, 2022

Copy link
Copy Markdown
Owner

I'm going to solve this a different way

@brendon

brendon commented Apr 27, 2022

Copy link
Copy Markdown

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

amro commented Apr 27, 2022

Copy link
Copy Markdown
Owner

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

brendon commented Apr 27, 2022

Copy link
Copy Markdown

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

amro commented Apr 27, 2022 via email

Copy link
Copy Markdown
Owner

@olliebennett

olliebennett commented Apr 29, 2022

Copy link
Copy Markdown

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

amro commented Apr 29, 2022

Copy link
Copy Markdown
Owner

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

@enthusiasmus

enthusiasmus commented May 2, 2022

Copy link
Copy Markdown

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

amro commented May 2, 2022

Copy link
Copy Markdown
Owner

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

Plsr commented May 3, 2022

Copy link
Copy Markdown

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

amro commented May 4, 2022 via email

Copy link
Copy Markdown
Owner

@claudiovf

claudiovf commented May 4, 2022

Copy link
Copy Markdown

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

amro commented May 4, 2022

Copy link
Copy Markdown
Owner

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