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

Security: gatsby-plugin-mdx is dependand on old version of trim, which has Regular Expression Denial of Service #33049

Closed
2 tasks done
darkmatter18 opened this issue Sep 4, 2021 · 3 comments

Comments

@darkmatter18
Copy link

Preliminary Checks

Summary

`-- gatsby-plugin-mdx@2.13.0
  `-- remark@10.0.1
    `-- remark-parse@6.0.3
      `-- trim@0.0.1 

gatsby-plugin-mdx is dependant upon remark, which has a dependency of trim@0.0.1. Trim0.0.1 has a High level vulnerability, as mentioned in https://www.npmjs.com/advisories/1700.

Steps to Resolve this Issue

So the update of remark is needed in dependency, to make sure that the plugin stays vulnerability free

@darkmatter18 darkmatter18 added the type: documentation An issue or pull request for improving or updating Gatsby's documentation label Sep 4, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Sep 4, 2021
@LekoArts LekoArts removed type: documentation An issue or pull request for improving or updating Gatsby's documentation status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Sep 6, 2021
@LekoArts
Copy link
Contributor

LekoArts commented Sep 6, 2021

Hi, thanks for the issue!

While those audit messages might seem scary they are almost always irrelevant in the context of Gatsby as it's a build tool. So there is nothing to "fix" as the warning is not relevant.

Gatsby creates static assets and runs everything at build time and not during runtime. npm audit is designed for runtime / Node apps so it flags issues that can occur there. This means that almost every "vulnerability" report we receive are false positives. While in principle Gatsby can also have vulnerabilities you need to make sure that it's relevant to Gatsby before reporting it. For example a "Regex DDOS attack" can never be a real vulnerability for a development-time tool. If you want to override/update a transitive dependency you can use yarn resolutions.

If you know that a vulnerability affects Gatsby because you understand what the vulnerability is, please report it here. Thanks!

@LekoArts LekoArts closed this as completed Sep 6, 2021
@wesrice
Copy link
Contributor

wesrice commented Sep 17, 2021

@LekoArts I get what you're saying, but I think it might be beneficial to look at this particular issue a bit closer.

Consider the details of this issue.

The entire process of testing (the regex) against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

remark-parse is using trim() in a process that:

// Removes the minimum indent from every line in value. Supports both tab,
// spaced, and mixed indentation (as well as possible).

Given the nature of how many times trim() might be executed with a false result in this process, on the surface it seems that this issue could potentially impact performance during build time, potentially with gatsby unwittingly acting as the attacker of the build machine.

Perhaps I'm misunderstanding the issue at hand. Regardless, I think it's worth a look by the Gatsby team just to be safe.

@MangelMaxime
Copy link

MangelMaxime commented Sep 30, 2021

I would also like to have the security warning fixed, some of my library users raised concern about this situation too.

When installing your dependencies this is never a good sign to see warning and some company can refuse to use a library because of that...

Edit:

It is also worth noting that if we move to yarn to benefit from "yarn resolutions" feature as proposed then we don't get a warning about the vulnerability just by switching to yarn itself.

image

In the screenshot above, you can see that npm audit report several vulnerabilities while running yarn audit returns none...

This means that it would not be easy to know if we have a vulnerability or not in the dependencies.

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.

4 participants