fix: validate plugin names in tailwind config generator to prevent RCE#275
Open
TemaDeveloper wants to merge 1 commit intonextlevelbuilder:mainfrom
Open
fix: validate plugin names in tailwind config generator to prevent RCE#275TemaDeveloper wants to merge 1 commit intonextlevelbuilder:mainfrom
TemaDeveloper wants to merge 1 commit intonextlevelbuilder:mainfrom
Conversation
…de injection The _format_plugins() method interpolated plugin names directly into require() statements without sanitization. A plugin name containing a single quote could break out of require() and inject arbitrary JavaScript that executes when Node.js loads the generated config. Add a strict regex allowlist matching valid npm package name patterns (optional @scope, alphanumeric/hyphen/underscore, optional subpath). Reject any plugin name that doesn't match before generating output. Closes nextlevelbuilder#246
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the Code Injection → RCE vulnerability (CVSS 9.3, Critical) in
tailwind_config_gen.pyreported in #246.The
_format_plugins()method interpolated plugin names directly into JavaScriptrequire('...')statements without any sanitization. A plugin name containing a single quote (e.g.fs').writeFileSync(...)) could break out of therequire()call and inject arbitrary JavaScript that executes when Node.js loads the generatedtailwind.config.js.Fix
^(@[a-zA-Z0-9_-]+/)?[a-zA-Z0-9_-]+(/[a-zA-Z0-9_.-]+)*$) that matches valid npm package name patternsValueErrorwith a descriptive messageTesting
@tailwindcss/typographytailwindcss-animatesome-plugin/sub-pathfs').writeFileSync('/tmp/rce','PWNED'),require('fslegit'); process.exit(1); //Normal config generation with valid plugins produces identical output — no regressions.
Closes #246