2016-11-04 44 views
1

我從過去的5-8個小時努力沒有得到解決的XSS防止在Magento XSS,如何防止在Magento

我已經安裝在我的Magento所有最新補丁。

我正在使用目錄搜索輸入框

"><img src=x onerror=prompt(1);> 

這個劇本,我得到這個輸出: -

XSS導致

enter image description here

我有也嘗試了一些像HTML一樣的驗證逃脫,strip_tags但沒有爲我工作。

有人可以幫我嗎?

回答

1

我在magneto 1.9中製作了很多主題,並測試了很多xss腳本,但腳本沒有被觸發。

1. <script>alert('hello')</script> even 
2. In url www.yourwebsite.com?query=<script>alert('hello')</script> or 
3. <img src=x onerror="alert('Pop-up window XSS infected');" in search box but every string is by default escaped by Magneto itself. 

這可以,如果你做你自己的自定義搜索,並沒有跟着Magento的標準數據傳遞到控制器和回主音要發生。

您可以使用value="<?php echo $this->htmlEscape(input_values_here) ?>"

例子:信貸 Magento Xss Prevention

<li class="wide"> 
    <label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label> 
    <div class="input-box"> 
     <input type="text" name="street[]" value="<?php echo $this->htmlEscape($this->getAddress()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text required-entry" /> 
    </div> 
</li> 

只是知識:

您可以瞭解更多關於XSS從 XSS Tutorial

你甚至可以在你的管理面板或任何補丁中檢查是否有來自Magento的消息。與您的自定義窗體/搜索框

  1. 交互:

    您的應用程序執行這些基本的測試。將包含HTML和JavaScript匹配字符的字符串插入到所有應用程序輸入中,例如表單,URL參數,隱藏字段(!)或cookie值。

  2. 如果您的表單沒有正確地轉義此字符串,您將看到一個警告,並會知道出現問題。
  3. 無論您的自定義表單處理用戶提供的URL,請輸入javascript:alert(0)或data:text/html,alert(0)。 使用與上述測試字符串類似的數據創建測試用戶配置文件。使用該配置文件與您的應用程序交互。這可以幫助識別存儲的XSS錯誤。