Skip to content

Commit 4feec4f

Browse files
committed
Adminhtml sales view - Escape remoteIp
It is quite trivial to make the remoteIp field map to something other than the REMOTE_ADDR header. Adding the following to `app/etc/di.xml` will allow you to use HTTP_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. ``` <type name="Magento\Framework\HTTP\PhpEnvironment\RemoteAddress"> <arguments> <argument name="alternativeHeaders" xsi:type="array"> <item name="http_x_forwarded_for" xsi:type="string">HTTP_X_FORWARDED_FOR</item> </argument> </arguments> </type> ``` A developer may decide to make this change at some point when they want to force all calls to RemoteAddress::getRemoteAddress() to use the X_FORWARDED_FOR instead. Maybe they're working on a plugin that requires it, and have many proxies between the customer and the Magento server. 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.
1 parent 7e9d181 commit 4feec4f

File tree

1 file changed

+1
-1
lines changed
  • app/code/Magento/Sales/view/adminhtml/templates/order/view

1 file changed

+1
-1
lines changed

app/code/Magento/Sales/view/adminhtml/templates/order/view/info.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ $orderStoreDate = $block->formatDate(
8989
<?php if ($_order->getRemoteIp() && $block->shouldDisplayCustomerIp()): ?>
9090
<tr>
9191
<th><?php /* @escapeNotVerified */ echo __('Placed from IP') ?></th>
92-
<td><?php /* @escapeNotVerified */ echo $_order->getRemoteIp(); echo($_order->getXForwardedFor()) ? ' (' . $block->escapeHtml($_order->getXForwardedFor()) . ')' : ''; ?></td>
92+
<td><?php /* @escapeNotVerified */ echo $block->escapeHtml($_order->getRemoteIp()); echo($_order->getXForwardedFor()) ? ' (' . $block->escapeHtml($_order->getXForwardedFor()) . ')' : ''; ?></td>
9393
</tr>
9494
<?php endif; ?>
9595
<?php if ($_order->getGlobalCurrencyCode() != $_order->getBaseCurrencyCode()): ?>

0 commit comments

Comments
 (0)