Adminhtml sales view - Escape remoteIp #5200
Merged
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.
It is quite trivial to make the remoteIp field map to something other than the
REMOTE_ADDR
header. Adding the following toapp/etc/di.xml
will allow you to useHTTP_X_FORWARDED_FOR
as the header you're interested in. With this change a customer can spoof their x forwarded header and inject javascript which will run when an admin views the order in the admin panel.A developer may decide to make this change at some point when they want to force all calls to
RemoteAddress::getRemoteAddress()
to use theX_FORWARDED_FOR
instead. Maybe they're working on a plugin that requires it, and have many proxies between the customer and the Magento server. Maybe they just want to hook into some useful related functionality. ¯_(ツ)_/¯This vulnerability isn't in the wild for M2 as it requires specific developer changes but I know the plugin ecosystem for M1 had many strange modules, this small change should help protect us from future laziness/craziness.
Either way, this is easily preventable. Simply escaping the output with $block->escapeHtml() will do the trick.