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

May be vulnerable to npmjs.evil.com, evilpython.org, evilsourceforge.net and more #140

Open
ds-cbo opened this issue Jan 5, 2024 · 1 comment · May be fixed by #141
Open

May be vulnerable to npmjs.evil.com, evilpython.org, evilsourceforge.net and more #140

ds-cbo opened this issue Jan 5, 2024 · 1 comment · May be fixed by #141

Comments

@ds-cbo
Copy link

ds-cbo commented Jan 5, 2024

I don't have a Proof of Concept yet, but to me it seems that the following pieces of code:

    "https?://registry.npmjs.*/.*",
    "https?://(www\\.)?npmjs.*/package.*",
    "https?://.+python.+org/(packages|project)/.*",

nuget_www_pattern = r"^https?://.*nuget.org/(api/v2/)?packages?/(?P<name>.+)/(?P<version>.+)$"

@purl_router.route("https?://.*sourceforge.net/projects?/.*")

could accidentally match on domains like registry.npmjs.evil.com, malware.python.evil.org, evilnuget.org or evilsourceforge.net as well. If someone relies on this package to confirm whether a package URL is from a trusted source (doesn't sound like its intended purpose, but you never know what people do with your library), they could be fooled by malicious domains like these and download malware instead.

A bit harder would be to abuse regexes like

    r"https?://raw.githubusercontent.com/(?P<namespace>[^/]+)/(?P<name>[^/]+)/"

@purl_router.route("https?://api.github\\.com/repos/.*")

    r"^https?://hackage.haskell.org/package/"

    "https?://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/.*"

where an attacker only has a small amount of possible domains (eg. raw_githubusercontent.com, apixgithub.com, hackageehaskell.org, storageggoogleapis.com) which could also match (since the . isn't escaped and treated like a wildcard character)

My recommendation (even if it isn't a security issue right now, but to prevent one in the future) would be to escape these regexes more carefully. Something like (.+\\.)?python\\.org and hackage\\.haskell\\.org

@ds-cbo ds-cbo linked a pull request Jan 5, 2024 that will close this issue
@pombredanne
Copy link
Member

Thanks! I get we can make these patterns more selective, but I am not sure how an attacker could do anything, and what would be the process and proof of concept?

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 a pull request may close this issue.

2 participants