Mod-Security

mod_security 從不告訴問題是什麼

  • January 26, 2015

通常我只會糾纏我的提供商禁用該規則。雖然他當然值得糾纏,但由於服務價格低,我已經經常這樣做了。

(就像往常一樣,這是關於 mod_security 規則,它只是 5 年前 Wordpress 或 Drupal 中一些晦澀的錯誤的黑名單條目。雖然我沒有使用它,但我仍然為其他人程式碼中的錯誤付出代價……)

反正。通常 mod_security 在這種情況下很容易被挫敗。我一直在嘗試重命名我的表單欄位以解決它。但這一次似乎沒有幫助。這是違規規則(我無法理解):

# Rule 340147: Generic XSS filter
SecRule REQUEST_URI "!(/mt\.cgi|^/node/[0-9]+/webform/components/|/node/[0-9]+/edit|/wizard/edit/html|^/\?q=node/[0-9]+/edit/|/node/add/main|sitebuilder/createproject|/admin/\?page=spageedit)" \
        "t:none,t:urlDecodeUni,t:replaceComments,t:replaceNulls,t:htmlEntityDecode,t:lowercase,t:compressWhitespace,capture,id:340147,rev:81,severity:2,msg:'Atomicorp.com - FREE UNSUPPORTED DELAYED FEED - WAF Rules: Generic XSS filter',chain,logdata:'%{TX.0}'"
SecRule REQUEST_URI|ARGS|ARGS_NAMES|!ARGS:arg2|!ARGS:resumoDetalhe|!ARGS:Right_photo_1|!ARGS:/^K2ExtraField/|!ARGS:/submitcode/|!ARGS:beschrijving|!ARGS:custombannercode|!ARGS:bannercode|!ARGS:privatecapacity|!ARGS:diz|!ARGS:FormLayout|!ARGS:/^fck/|!ARGS:parent_name|!ARGS:/^code_tscript/|!ARGS:_qf_Group_next|!ARGS:project_company|!ARGS:categories_title|!ARGS:antwoord|!ARGS:project_company|!ARGS:signature|!ARGS:paepdc|!ARGS:tpl_source|!ARGS:teaser_js|!ARGS:/^autoDS/|!ARGS:FrmSide|!ARGS:mainKeywords|!ARGS:/VB_announce/|!ARGS:guardar|!ARGS:/serendipity/|!ARGS:omschrijving|!ARGS:resolution|!ARGS:newyddionc|!ARGS:bericht|!ARGS:property_copy|!ARGS:/^outpay/|!ARGS:bedrijfsprofiel|!ARGS:s_query|!ARGS:finish_survey|!ARGS:photolater|!ARGS:ticket_response|!ARGS:/element/|!ARGS:option[vbpclosedreason]|!ARGS:/introduction/|!ARGS:/contenido/|!ARGS:/sql/|!ARGS:query|!ARGS:c_features|!ARGS:/tekst/|!ARGS:embeddump|!ARGS:other_clubs|!ARGS:/^elm/|!ARGS:/^saes/|!ARGS:dlv_instructions|!ARGS:/^cymr/|!ARGS:_qf_Register_upload|!ARGS:/^elm/|!ARGS:verbiage|!ARGS:news|!ARGS:/^wz/|!ARGS:tiny_vals|!ARGS:sSave|!ARGS:/article/|!ARGS:/about/|!ARGS:/Summarize/|!ARGS:/^product_options/|!ARGS:/SiteStructure/|!ARGS:/anmerkung/|!ARGS:/summary/|!ARGS:/edit/|!ARGS:reply|!ARGS:/story/|!ARGS:resource_box|!ARGS:navig|!ARGS:preview__hidden|!ARGS:/page/|!ARGS:order|!ARGS:/post/|!ARGS:youtube|!ARGS:reply|!ARGS:business|!ARGS:/homePage/|!ARGS:pagimenu_inhoud|!ARGS:/note/|!ARGS:Post|!ARGS:/^field_id/|!ARGS:area|!ARGS:/detail/|!ARGS:/comment/|!ARGS:LongDesc|!ARGS:/desc/|!ARGS:ta|!ARGS:/data/|!ARGS:Returnid|!ARGS:busymess|!ARGS_NAMES:/^V\*/|!ARGS_NAMES:/^S\*/|!ARGS:/^quickrise_advertise/|!ARGS:rt_xformat|!ARGS:/wysiwyg/|!ARGS:contingut|!ARGS:/^werg/|!ARGS:/body/|!ARGS:/css/|!ARGS:/^section/|!ARGS:/msg/|!ARGS:t_cont|!ARGS:/^doc/|!ARGS:/xml/|!ARGS:tekst|!ARGS:formsubmit|!ARGS:invoice_snapshot|!ARGS:submit|!ARGS:/message/|!ARGS:/html/|!ARGS:/content/|!ARGS:/footer/|!ARGS:/header/|!ARGS:/link/|!ARGS:/text/|!ARGS:/txt/|!ARGS:/refer/|!ARGS:/referrer/|!ARGS:/template/|!ARGS:/ajax/ "(< ?(?:(?:java|vb)?script|about|applet|activex|chrome) ?>|> ?< ?(img ?src|a ?href) ?= ?(ht|f)tps?:/|\" ?> ?<|\" ?[a-z]+ ?<.*>|> ?\"? ?(>|<)|< ?/?i?frame|\%env)"

那是 error.log 條目:

[Tue Mar 29 14:28:52 2011] [error] [client 000.000.000.000] ModSecurity: Access denied with code 403 (phase 2). Match of "rx (^(submit\\\\+>>|>>)$)" against "ARGS:pub_lish2" required. [file "/etc/apache2/modsec2/10_asl_rules.conf"] [line "962"] [id "340147"] [rev "108"] [msg "Atomicorp.com WAF Rules: Generic XSS filter"] [data "848"] [severity "CRITICAL"] [hostname "hahaha.not-telling-you.org"] [uri "/index.php"] [unique_id "TZHQhE6KWTMAAFkDGf0AAAAG"]

這些是使用的表單域:

   <form action="index.php" method="POST" enctype="multipart/form-data" accept-encoding="UTF-8">
   <input type="hidden" name="pub_lish2" value="1">
   <input type="hidden" name="e" value="2">
   <textarea name="question">
      <tt>...</tt>
      <h2>...</h2>
      <p>...</p>
      <span class="tag">details</span>
   </textarea>
   <!--div id="captcha" class="captcha">
       <input type="hidden" id="__ec_i" name="__ec_i" value="ec.1301402534.e6dcf57012b4410395621d0b6851f0a2" />
       <input type="text" name="__ec_s" value="">
   </div-->
   <input type="submit" value="Post Your Thingy">
   </form>

這不是驗證碼欄位,所以我將它們註釋掉。textarea 包含 html,但沒有任何可疑之處。我已經多次重命名送出欄位,而 e= 只是一個 id 欄位。

任何人都可以理解 mod_security 消息嗎?我不明白它的愚蠢要求。

對我來說,當有人送出帶有小於號、大於號且中間沒有字元的表單時觸發此規則,因此:’><'

看起來您的表單是內置於表單中的:

請注意,空格不能解決此問題。

該規則在 index.php 接收 (RX) 時抱怨參數 ‘pub_lish2’ 不匹配特定的正則表達式 ((^(submit\+>>|>>)$))。

據我所知,他們已經為規則引入了一大堆單獨的例外,您可以利用這些例外進行測試,因此閱讀提供的規則,它們匹配每個不是特定表單端點的 URL,然後提供大量的例外情況。我建議他們嘗試刪除無關的基於表單的 XSS,但效果非常糟糕。

您可以通過將該特定欄位更改為排除項之一來生成一個相當簡單的測試,因此,隨機選擇一個;

忙碌的

然後看看送出時會發生什麼。如果他們允許,您可以要求將 pub_lish2“目標”添加到排除列表中。

引用自:https://serverfault.com/questions/253151