Webx中的安全考慮

2021-09-22 04:29:27 字數 3267 閱讀 6297

1、預設***

即使你不加說明,basicrequestcontext也總是會啟用乙個預設的interceptor實

現:responseheadersecurityfilter。這個類實現了下列功能:

• 避免header name和value**現crlf字元 ── 在header中嵌入crlf(回車換行)字元

是一種常見的攻擊手段。攻擊者嵌入crlf以後,使伺服器對http請求發生錯誤判斷,從而執行攻擊者的惡意**。事實上,現在的servlet引擎如tomcat已經可以防禦這種攻擊。但作為框架,並不能依賴於特定的servlet引擎,所以加上這個額外的安全檢查,確保萬無一失。

• 將status message用html entity編碼重寫 ── 通常status message會被顯示在html頁面中。攻擊者可以利用這一點在頁面中嵌入惡意**。將status message以html entity編碼重寫以後,就可以避免這個問題。

• 限制cookie的總大小 ── 過大的cookie可能使web伺服器拒絕響應請求。攻擊者同樣可以利用這一點使使用者無法正常訪問**。限制cookie的總大小可以部分地解決這種危機。

如果需要,你可以對responseheadersecurityfilter指定一些引數。

例 7.2. 配置responseheadersecurityfilter(/web-inf/webx.xml)

xmlns="">

2、過濾引數

出於安全的考慮,還支援對輸入引數進行過濾。請看示例:

例 7.31. 配置過濾引數

上面的配置將會禁止檔名字尾不在列表中的檔案被上傳到伺服器上。如果做得更好一點,你甚至可以對上傳檔案進行病毒掃瞄。

目前,支援兩種過濾器介面:parametervaluefilter和uploadedfilefilter。前者用來對普通的引數值進行過濾(例如排除可能造成攻擊的html**);後者用來對上傳檔案的file item物件進行過濾,就像剛才的uploaded-file-whitelist的例子。

3、增加fasttext的巨集

在webx-component-and-root.xml中配置

<

services:template

xmlns

=""searchextensions

="true"

>

<

velocity-engine

templateencoding

="gbk"

strictreference

="false"

path

="/$/templates"

>

<

global-macros

>

<

name

>

global/*macros.vm

name

>

<

name

>

global/*macros.vm

name

>

<

name

>

classpath/unictemplate/macros.vm

name

>

global-macros

>

<

plugins

>

<

vm-plugins:escape-support

defaultescape

="html"

>

<

vm-plugins:noescape

>

<

vm-plugins:if-matches

pattern

="^control\."

/>

<

vm-plugins:if-matches

pattern

="^screen_placeholder"

/>

<

vm-plugins:if-matches

pattern

="^stringescapeutil\.escape"

/>

<

vm-plugins:if-matches

pattern

="^csrftoken\.(get)?hiddenfield"

/>

vm-plugins:noescape

>

vm-plugins:escape-support

>

-->

<

vm-plugins:fasttext-support

/>

<

vm-plugins:renderable-support

/>

plugins

>

velocity-engine

>

注意:(1)b2b使用的是fasttext解決方案,而不用eacape,所以新增<

vm-plugins:fasttext-support

/>

(2)為了解決二房庫的巨集引用問題,使用

<

name

>

classpath/unictemplate/macros.vm

name

>

進行配置

順便說說資源的load,在webx-component-and-root.xml中配置的資源,例如:

<

global-macros

>

<

name

>

global/*macros.vm

name

>

<

name

>

global/*macros.vm

name

>

<

name

>

classpath/unictemplate/macros.vm

name

>

global-macros

>

支付安全考慮

1.網銀類 像招行支付 工行支付 西聯快匯等 2.綜合電子錢包類 像支付寶 快錢 易寶 paypal moneybookers facebook credits等 3.虛實卡類 神州行 mycrad gash 駿網一 崑崙一 mol等 4.固話聲訊類 像杭州齊順 daopay等 5.手機簡訊類 像聯...

web安全考慮

1.sql注入攻擊 伺服器端程式有時希望接受客戶端輸入並且將他作為查詢的一部分 例如 乙個接收使用者名稱的登入介面可能執行以下 sql select from users where username 如果客戶端輸入以下字串作為使用者名稱 a delete from users sql select...

Open API安全考慮

很初級的簡單想法,先記下來。需要有個年輕聰明的青年才俊論證一下 1 是否用https,這些就沒有必要了。2 嚴謹性 是否有漏洞,這麼做安全性依賴哪些要素,能多大程度上保證。3 必要性 是否有冗餘環節。4 效能 壓一下,注意監控cpu。以下是正文。1 所有的秘鑰都由我們生成並頒發。2 我們需要儲存 1...