-
Notifications
You must be signed in to change notification settings - Fork 32
apply deterministic refactor of regex patterns to counter ReDoS #1671
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
base: 2.0.x
Are you sure you want to change the base?
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>
skenow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we turn this into a common callable method to reduce the number of duplicate instances of this method?
|
you mean put it in a trait for re-use? That might be a good idea. And better than shove it into common.php or functions.php :-) |
Can we postpone this (but create a ticket for it so we don't forget) until after we have composer-based autoloading? That will allow for a cleaner solution with either a trait, or a utility class. In the meantime, let's integrate this fix already in the 2.0.3 and get that version going again. |
User description
Similar to what is in the syntax highlighter. In the future we might put this somewhere in an IPF class
PR Type
Bug fix, Enhancement
Description
Replace vulnerable regex patterns with deterministic string-based parsing
Mitigate ReDoS (Regular Expression Denial of Service) attacks
Implement
replaceTagDeterministic()method for safe tag replacementApply refactor to adsense and customtag preload plugins
Diagram Walkthrough
File Walkthrough
adsense.php
Replace regex with deterministic tag replacementhtdocs/plugins/preloads/adsense.php
preg_replace_callback()calls withreplaceTagDeterministic()method ineventAfterPreviewTarea()andeventAfterDisplayTarea()replaceTagDeterministic()that usesstring functions (
strpos,substr) instead of regex[adsense]...[/adsense]tags byinvoking callback with matches array
customtag.php
Replace regex with deterministic tag replacementhtdocs/plugins/preloads/customtag.php
preg_replace_callback()calls withreplaceTagDeterministic()method ineventBeforePreviewTarea()andeventBeforeDisplayTarea()replaceTagDeterministic()using stringfunctions for safe tag parsing
[customtag]...[/customtag]tags with callbackinvocation matching preg_replace_callback behavior