国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

mod_security保障Web Services的安全一(圖)

2019-11-18 12:26:54
字體:
來源:轉載
供稿:網友

  Web服務正在變為下一代web應用的一個完整部分。但是它也較輕易被攻擊。這些攻擊的種類與傳統的web應用所受到的攻擊是相同的,但是形式上發生了變化。這些攻擊會導致信息泄漏;另外,這些攻擊有助于執行遠程命令。通過使用WSDL,一個攻擊者能夠確定web服務的入口和可用的接口。這些接口或方法使用SOAP協議通過HTTP/HTTPS方式得到輸入。假如在源代碼層沒有好的保護,您的應用就會處于危險。mod_security作為一個Apache web服務器模塊,是一種保護web服務免受惡意攻擊(包括封裝在SOAP封套內的惡意數據)的理想解決方案。
  
  問題域
  
  Web服務所遭到的四種主要攻擊:
  變量長度緩沖區(Variable-length buffer)注入
  元字符注入
  SQL注入
  SOAP錯誤代碼信息暴露(譯者注:是指返回的Exception信息的暴露)
  
  通常防火墻配置會答應HTTP/HTTPS傳輸無礙的進入。通常對web服務的攻擊會偽裝成合法的HTTP/HTTPS傳輸,從而蒙騙了防火墻。這篇文章將告訴您如何區分合法的HTTP/HTTPS傳輸和惡意的HTTP/HTTPS傳輸,并截獲惡意傳輸。這樣將能夠在很大程度上減輕對80/443端口的攻擊。
  
  解決方案是什么?
  
  有很多解決方案,從安全代碼到輸入驗證。一個途徑是通過對每一個請求的內容用事先定義好的規則進行驗證。這種途徑在源代碼層上阻止了惡意SOAP請求滲透入web服務。如您為web服務正確部署并配置了mod_security,它將能夠阻止所有上述的攻擊。這篇文章將具體的討論mod_security如何能成為web 服務有效的防范工具。
  
  當部署完web服務后,提供一個防御手段來防范不同類型的攻擊是很重要的。每一種攻擊都需要不同的防范策略。假設有這么一個銀行—這個銀行僅僅是一個作為例子的假想銀行。
  
  Blue 銀行(www.bluebank.example.com)最近剛剛部署了web服務,并使用mod_security對web服務進行保護。該銀行通過internet向它的金融合作伙伴和客戶提供銀行服務。它的web服務提供在線的客戶服務,比如帳目結算,資金周轉和更改用戶信息。圖1解釋了在Blue Bank部署的web服務的架構。
  
 mod_security保障Web Services的安全一(圖)(圖一)

  
圖 1. Blue銀行的部署

  
  有許多部署web服務的方法。在這個例子中,web服務運行在Tomcat/Axis上。banking web服務應用以java編碼(以.jws作為擴展名)。
  
  相關的Apache和Axis配置文件片斷包含用來加載Tomcat的Apache httpd.conf:
  
  LoadModule jk2_module modules/mod_jk2.soJkSet config.file /usr/local/apache2/conf/workers2.PRoperties
  
  讓web服務支持AxisServlet 的Axis web.xml文件:
  
  <servlet-mapping>
  <servlet-name>AxisServlet</servlet-name>
  <url-pattern>*.jws</url-pattern>
  </servlet-mapping>
  
  像如上配置之后,您將可以在該服務器上部署任何web服務。假如您注重到該服務器發回的如下的頭信息,您能夠識別如下這一行:
  
  Server: Apache/2.0.50 (Unix) mod_ssl/2.0.50 OpenSSL/0.9.7d mod_jk2/2.0.4
  
  以上的消息頭說明服務器是運行于Tomcat模塊mod_jk2/2.0.4之上的Apache/2.0.50 (Unix)。Axis作為Tomcat web應用的一部分并且已經可以部署web服務。為了給web服務層提供保護,Blue銀行已經加載了有application級過濾能力的mod_security模塊。下面一行在httpd.conf中的信息加載安全模塊:
  
  LoadModule security_module modules/mod_security.so
  
  當部署好mod_security后,Blue銀行可以在httpd.conf里添加過濾規則:
  
  <IfModule mod_security.c>
  # Turn the filtering engine On or Off
  SecFilterEngine On
  SecFilterDefaultAction "deny,log,status:500"
  SecFilterScanPOST On
  . . .
  # Other rules
  . . .
  </IfModule>
  
  通過上面的配置,Blue Bank已經為治理員和開發人員預備好創建web服務,并利用mod_security的有效的內容過濾能力來防范惡意HTTP/HTTPS請求。
  
  考慮一個web服務例子
  
  如:www.bluebank.example.com/axis/getBalance.jws.
  這個web服務的WSDL請求來自:www.bluebank.example.com/axis/getBalance.jws?wsdl.
  說明:www.bluebank.example.com是一個虛擬的域名,僅僅作為例子。
  
  從WSDL得到 方法/接口 數據來顯示帳目結算信息
  
  仔細觀察HTTP請求獲得的WSDL應答結果。這里重點觀察一個調用方法,該方法輸入bank id 然后返回相關賬目結算信息并通過Http傳遞給客戶端。Operation標簽指定web服務能夠調用的方法。相關的wsdl代碼片斷如下:
  
  <wsdl:operation name="getInput">
  <wsdlsoap:operation soapAction=""/>
  <wsdl:input name="getInputRequest">
  <wsdlsoap:body encodingStyle=http://schemas.xmlsoap.org/soap/encoding/namespace="http://DefaultNamespace"use="encoded"/>
  </wsdl:input>
  <wsdl:output name="getInputResponse">
  <wsdlsoap:body encodingStyle=http://schemas.xmlsoap.org/soap/encoding/namespace="http://www.bluebank.example.com/axis/getBalance.jws"use="encoded"/>
  </wsdl:output>
  <wsdl:message name="getInputResponse">
  <wsdl:part name="getInputReturn" type="xsd:string"/>
  </wsdl:message><wsdl:message name="getInputRequest">
  <wsdl:part name="id" type="xsd:string"/></wsdl:message>
  
  如上面代碼所示,當向該方法傳入一個id將得到一個字符串類型的輸出。當你向該方法傳入一個account id,你將回得到該account id的賬目結算。
  
  通過HTTP方式調用web服務
  
  Blue銀行的客戶或者合作伙伴可以通過向banking web服務發送正確格式的SOAP封套來得到要求的信息。圖2展示了一個通過向服務發送account id 12123 來獲取相應賬目結算的HTTP請求。
  
mod_security保障Web Services的安全一(圖)(圖二)

  
圖 2.通過HTTP方式調用web服務

  
  有很多種方法來產生有正確格式的SOAP請求的SOAP客戶。這里有一個用Perl SOAP::Lite實現的SOAP客戶。下面的簡單代碼將生成一個SOAP請求。
  
  #!perl -wuse SOAP::Lite;print SOAP::Lite -> service('http://www.bluebank.example.com/axis/getBalance.jws?wsdl') -> getInput('12123');
  
  在網絡上探測到HTTP請求和應答是可能的,比如用ethereal。一個發送到www.bluebank.example.com 的包含id 信息為12123的HTTP/SOAP請求將產生如下信息:
  
  POST /axis/getBalance.jws HTTP/1.0Content-Type: text/xml; charset=utf-8SOAPAction: ""Content-Length: 576EXPect: 100-continueHost: www.bluebank.example.com<?xml version="1.0" encoding="utf-8"?>
  <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"xmlns:tns="http://www.bluebank.example.com/axis/getBalance.jws" xmlns:types="http://www.bluebank.example.com/axis/getBalance.jws/encodedTypes"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Bodysoap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <q1:getInput xmlns:q1="http://DefaultNamespace">
  <id xsi:type="xsd:string">12123</id>
  </q1:getInput>
  </soap:Body>
  </soap:Envelope>
  ...HTTP/1.1 200 OKDate: Mon, 03 Jan 2005 19:24:10 GMTServer: Apache/2.0.50 (Unix) mod_ssl/2.0.50 OpenSSL/0.9.7d mod_jk2/2.0.4Set-Cookie: JSESSIONID=69C6540CC427A8B064C0795ADDFC20EA; Path=/axisContent-Type: text/xml;charset=utf-8Connection: close<?xml version="1.0" encoding="UTF-8"?>
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
  <ns1:getInputResponsesoapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:ns1="http://DefaultNamespace">
  <ns1:getInputReturnxsi:type="xsd:string">$2500</ns1:getInputReturn>
  </ns1:getInputResponse>
  </soapenv:Body></soapenv:Envelope>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 探索| 石阡县| 海兴县| 韩城市| 和政县| 溧水县| 保山市| 乳源| 广饶县| 千阳县| 贡嘎县| 三原县| 长岛县| 玉树县| 辉南县| 府谷县| 灌南县| 曲阳县| 方山县| 屏南县| 太仆寺旗| 当雄县| 桦甸市| 汉中市| 新竹市| 闽清县| 东明县| 临沭县| 鹤峰县| 綦江县| 敦煌市| 长顺县| 蓬莱市| 本溪市| 辽阳市| 巴彦县| 丹凤县| 绵竹市| 蒙阴县| 睢宁县| 黄大仙区|