-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Added HtmlPurifier to improve MaliciousCode filtering #3606
Conversation
Thank you for your contribution. I have improved the PR as suggested. |
seems like this version of htmlpurify is php8.0+ so we can't use it in
|
Good point. Which one do you suggest? I am down to downgrading htmlpurify as its mostly syntax changes php7 -> php8 |
well, I'm biased towards releasing the |
There are two errors reported by PHPStans. the latest changes are not compatible with lower versions of PHP8. I would leave it as it was initially so as not to create a BC of all the beauty. It is a good an important addition that I would leave in the main branch. |
Everything seems to be correct now? Is it possible to squash commits while merging or should I do that? |
yep
we always do that when merging, don't worry :-) |
do you know how to trigger the filter() method in order to test this? |
If you have n98-magerun try this:
Different attacks and correct results can be found here: http://htmlpurifier.org/live/smoketests/xssAttacks.php |
We might want to publish security advisory for this too if we want people to update fast. |
thanks @Judx, I was wondering where (in the adminhtml) is called that filter method, but anyway I like this PR a lot |
Great! I can find total 7 usages, in adminhtml i.e.
|
Think doc block |
If there is any interest, we have some functionality added on top of HtmlPurifier internally which enhances security by preventing javascript from being inserted into areas such as system config, categories, CMS, etc. If there is any interest I could prepare a branched PR (or separate issue). I do assume there are some legitimate use cases for JS in these areas though, so if there is any interest we could put it behind a configuration flag (e.g. "Allow JS in text inputs"). |
Waiting for merge! And superthanks to @mattdavenport would be great if you could improve this too! :) |
lgtm |
@Judx Apologies for the delay here. After further inspection it appears that our improvements have been made redundant by later versions of HTMLPurifier. Nonetheless, thank you for the this PR! |
Description (*)
Add HtmlPurifier for improved MaliciousCode filtering. Found when researching https://helpx.adobe.com/security/products/magento/apsb23-50.html
Magento Open Source > 2.4.5 added HtmlPurifier library to improve the MaliciousCode filter.
#3600
Related Pull Requests
GHSA-3p73-mm7v-4f6m
Fixed Issues (if relevant)
Manual testing scenarios (*)
Mage_Core_Model_Input_Filter_MaliciousCode::filter()
with dirty htmlQuestions or comments
Could someone run
n98-magerun.phar dev:ide:phpstorm:meta
for the new helper meta?Contribution checklist (*)