WP/EnqueuedResourceParameters: remove eval() from is_falsy() - #2771
Merged
Conversation
This PR is a fix for CVE-2026-45293 / [GHSA-3pwp-g2mj-5p3v](GHSA-3pwp-g2mj-5p3v). Replace the eval()-based logic with explicit token-level checks for a small set of literal falsy values: - Boolean false. - An integer or float equal to zero. - A text string with the content `'0'` or `''` (single or double-quoted, heredoc, or nowdoc). - An empty array. Other forms that the previous implementation recognised via eval() are no longer detected, such as a value wrapped in a type cast (e.g. `(int) 0`). Supporting them doesn't justify the risks of using eval(). This commit also clarifies test case comments as the previous version was inaccurate. "0, false or NULL" are not the only values that are not allowed. Also, NULL and missing $ver parameter generate a warning instead of an error.
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.
Description
This PR is a fix for CVE-2026-45293 / GHSA-3pwp-g2mj-5p3v.
Replace the eval()-based logic with explicit token-level checks for a small set of literal falsy values:
'0'or''(single or double-quoted, heredoc, or nowdoc).Other forms that the previous implementation recognised via eval() are no longer detected, such as a value wrapped in a type cast (e.g.
(int) 0). Supporting them doesn't justify the risks of using eval().This commit also clarifies test case comments as the previous version was inaccurate. "0, false or NULL" are not the only values that are not allowed. Also, NULL and missing $ver parameter generate a warning instead of an error.
Suggested changelog entry
WordPress.WP.EnqueuedResourceParameterssniff over untrusted PHP code, for example, in a CI pipeline that lints pull requests, or on a developer machine reviewing third-party code, could lead to arbitrary command execution on the scanning host. [#xx]This affects users of the
WordPressandWordPress-Extrarulesets. TheWordPress-Coreruleset and theWordPress-Docsruleset are not affected.For more details, see the security advisory.