Skip to content

Conversation

@theofidry
Copy link
Contributor

This PR is a fix for GHSA-9965-vmph-33xx.

Cherry-picked the change from #2603 but a test first to capture the vulnerability was created first. It also modifies the original patch as it was making any URL with authentication information no longer valid.

Closes #2603 and #2600.

@WikiRik
Copy link
Member

WikiRik commented Oct 15, 2025

Thanks for working on this! I was also looking into this, and I came up with this set of invalid URLs that we probably should test for with the default settings. (Disclaimer; these were partially generated by AI.)

        // the following tests are because of CVE-2025-56200
        /* eslint-disable no-script-url */
        "javascript:alert(1);a=';@example.com/alert(1)'",
        'JaVaScRiPt:alert(1)@example.com',
        'javascript:%61%6c%65%72%74%28%31%[email protected]',
        'javascript:/* comment */alert(1)@example.com',
        'javascript:var a=1; alert(a);@example.com',
        'javascript:alert(1)@[email protected]',
        'javascript:alert(1)@example.com?q=safe',
        'data:text/html,<script>alert(1)</script>@example.com',
        'vbscript:msgbox("XSS")@example.com',
        '//evil-site.com/[email protected]',
        'http://[email protected]/',
        'javascript:alert(1)@example.com',
        /* eslint-enable no-script-url */

Could you add these (or a variation of these) to this PR?

@theofidry
Copy link
Contributor Author

@WikiRik from what I can see the following are marked as valid:

javascript:%61%6c%65%72%74%28%31%[email protected]
//evil-site.com/[email protected]
http://[email protected]/
javascript:alert(1)@example.com

I do not know if it's correct or not

@WikiRik
Copy link
Member

WikiRik commented Oct 15, 2025

Thanks for checking that!

Why is javascript:%61%6c%65%72%74%28%31%[email protected] passing? That's strange to me.
The three others can be removed for now. We'll look into those (or variations of those) in future rework.

To get your CI passing; you can remove Node 6 from the versions we test on, as I did in #2609

@theofidry
Copy link
Contributor Author

theofidry commented Oct 15, 2025

The flow of the current for javascript:%61%6c%65%72%74%28%31%[email protected] is:

  • detects javascript as a potential protocol
  • checks what is after the colon, which is %61%6c%65%72%74%28%31%[email protected]
  • checks what is before the @, which is %61%6c%65%72%74%28%31%29
  • %61%6c%65%72%74%28%31%29 is a valid authentication (it only contains alphanumeric and %)
  • Because the above is valid authentication, it does not treat javascript: as a protocol but instead treats it as if it was username:[email protected]

Not sure what is the best way to fix this.

@WikiRik
Copy link
Member

WikiRik commented Oct 15, 2025

Let's skip that one as well for now. Running the original CVE in a browser console gives me the alert and this one doesn't.

We don't do XSS sanitization in this library, so that shouldn't be a big issue

@codecov
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6f436be) to head (376c84f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2608   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2536      2562   +26     
  Branches       642       649    +7     
=========================================
+ Hits          2536      2562   +26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@theofidry
Copy link
Contributor Author

@WikiRik updated.

Also worth mentioning it is only a risk when the protocol is not required, as if it is then it is checked against the allowed protocols.

So may be worth adding a strong recommendation in the docs or making the protocol required the default

@WikiRik
Copy link
Member

WikiRik commented Oct 15, 2025

Yes, we will make the protocol required by default but that will be a breaking change so we do that in the next major release. A strong recommendation might be good. Is that something you can add to the README?

@benedery
Copy link

benedery commented Oct 16, 2025

Hey @theofidry @WikiRik , any ETA on when its going to be merged & released?

@WikiRik
Copy link
Member

WikiRik commented Oct 16, 2025

@theofidry codecov is complaining about some missing and partially covered lines. Can you check if those branches should be touched, and do one of the following;

  • add additional test cases
  • remove the branch of code

I hope to be able to review this PR properly this weekend, suggestions from the community are appreciated on this

Copy link
Contributor

@scottgigante-hubflow scottgigante-hubflow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggested test cases that might help with coverage

@theofidry
Copy link
Contributor Author

I can't check it out locally atm, but if you do a PR against my changes I can merge it

@scottgigante-hubflow
Copy link
Contributor

theofidry#2

@a-safadi
Copy link

any ETA on when its going to be merged & released?

@IdanAdar
Copy link

What else is this PR missing?

@heatxsink
Copy link

heatxsink commented Oct 20, 2025

Does this PR need a bit more test coverage to pass?

@WikiRik
Copy link
Member

WikiRik commented Oct 20, 2025

There is still 1 line partially covered, and I haven't had the time to properly review the proposed changes

@henri-extravagant
Copy link
Contributor

@theofidry Here's a PR to handle the partially covered line

@GodsonLeigh
Copy link

GodsonLeigh commented Oct 21, 2025

Thank you everyone for your work on getting this ready, I have been following the progress here since the vulnerability was found. Do we know how long this will now take to be released as this transient dependency is blocking a number of work items on our (admittedly rigid) pipeline.
@WikiRik @theofidry

Copy link
Member

@WikiRik WikiRik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two suggestions, apart from that I think this is fine to merge. After release we can look into incorporating the native URL interface, but that's more work than needs to be done to fix this CVE

WikiRik
WikiRik previously approved these changes Oct 21, 2025
@WikiRik WikiRik requested a review from rubiin October 21, 2025 09:46
@WikiRik WikiRik changed the title fix(isURL): Fixes GHSA-9965-vmph-33xx fix(isURL): improve protocol detection. Resolves CVE-2025-56200 Oct 21, 2025
@rubiin rubiin merged commit cbef508 into validatorjs:master Oct 21, 2025
12 checks passed
@WikiRik
Copy link
Member

WikiRik commented Oct 21, 2025

I'll prepare a release later today that includes this fix

@theofidry theofidry deleted the hotfix/cve-isurl branch October 22, 2025 06:27
@dmonserr
Copy link

@WikiRik any update on this? I see it was merged into the release branch but not yet approved by @profnandaa.

@profnandaa
Copy link
Member

@WikiRik any update on this? I see it was merged into the release branch but not yet approved by @profnandaa.

Sorry, this is implicitly approved, since we were on some email discussions about it.

@gboisvert-beyondtrust
Copy link

@WikiRik @profnandaa Is there an ETA for distribution of this security fix?

@Moumouls
Copy link

Hi all i sent the PR to mark the 13.15.20 as patched: github/advisory-database#6355 to update the GH advisory database

@typenoob
Copy link

typenoob commented Dec 4, 2025

Hi, could this security fix backport to v13.12.x?

@profnandaa
Copy link
Member

Hi, could this security fix backport to v13.12.x?

Any reasons you have locked on v13.12.x, where there any breaking changes after? /cc. @WikiRik

@typenoob
Copy link

typenoob commented Dec 5, 2025

#2421 This is the breaking change. @profnandaa

I know I could use loose mode to handle it but class-validator has not exposed the option yet.
typestack/class-validator#2648

@WikiRik
Copy link
Member

WikiRik commented Dec 6, 2025

@typenoob I still need to reply in depth to the issue that was created, but in short; it was not the best idea to publish that change in 13.x.x. I didn't know that you weren't able to use the loose mode in class-validator. I'll see if we want to make the loose mode the default setting so that people can update.

Security wise; if you require protocols and make them mandatory (possibly with preprocessing to add "https://" in the application if the user did not provide it), you are safe from this vulnerability.

1 similar comment
@WikiRik
Copy link
Member

WikiRik commented Dec 6, 2025

@typenoob I still need to reply in depth to the issue that was created, but in short; it was not the best idea to publish that change in 13.x.x. I didn't know that you weren't able to use the loose mode in class-validator. I'll see if we want to make the loose mode the default setting so that people can update.

Security wise; if you require protocols and make them mandatory (possibly with preprocessing to add "https://" in the application if the user did not provide it), you are safe from this vulnerability.

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.