2011-03-25 32 views
4

RemoteServiceServlet.checkPermutationStrongName()未能在HttpServletRequest中找到X-GWT-Permutation HTTP標頭時,我的應用程序偶爾會收到由GWT引發的XSRF攻擊錯誤。當錯誤發生時,下面一行出現在日誌文件:GWT:XSRF:零星丟失X-GWT-Permutation標頭

WARNING: doUnexpectedFailure was invoked. 
java.lang.SecurityException: Blocked request without GWT permutation header (XSRF attack?) 

該問題已經在這兩個託管模式和Web模式已經經歷了在Firefox 3.x和4.0。

我跑過Live Headers,並且HTTP頭確實缺失。

該應用程序是香草GWT RPC。

任何想法?

失敗頭

http://127.0.0.1:8888/org.drools.guvnor.Guvnor/guvnorService 

POST /org.drools.guvnor.Guvnor/guvnorService HTTP/1.1 
Host: 127.0.0.1:8888 
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.2.15) Gecko/20110303 Ubuntu/10.10 (maverick) Firefox/3.6.15 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-gb,en;q=0.5 
Accept-Encoding: gzip,deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Keep-Alive: 115 
Connection: keep-alive 
Content-Length: 154 
Content-Type: text/x-gwt-rpc; charset=utf-8 
Referer: http://127.0.0.1:8888/org.drools.guvnor.Guvnor/Guvnor.html?gwt.codesv... 
Cookie: standalone_usage=true 
Pragma: no-cache 
Cache-Control: no-cache 


7|0|4|http://127.0.0.1:8888/org.drools.guvnor.Guvnor/| 
6808FDC8A4FA3491026441B59E4DB72A| 
org.drools.guvnor.client.rpc.RepositoryService|subscribe|1|2|3|4|0| 

HTTP/1.1 400 Bad Request 
Content-Type: text/plain;charset=ISO-8859-1 
Transfer-Encoding: chunked 
Date: Wed, 23 Mar 2011 20:11:04 GMT 
Server: Apache-Coyote/1.1 
Connection: close 

成功頭

http://127.0.0.1:8888/org.drools.guvnor.Guvnor/guvnorService 

POST /org.drools.guvnor.Guvnor/guvnorService HTTP/1.1 
Host: 127.0.0.1:8888 
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.2.15) Gecko/20110303 Ubuntu/10.10 (maverick) Firefox/3.6.15 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-gb,en;q=0.5 
Accept-Encoding: gzip,deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Keep-Alive: 115 
Connection: keep-alive 
X-GWT-Permutation: HostedMode 
X-GWT-Module-Base: http://127.0.0.1:8888/org.drools.guvnor.Guvnor/ 
Content-Type: text/x-gwt-rpc; charset=utf-8 
Referer: http://127.0.0.1:8888/org.drools.guvnor.Guvnor/Guvnor.html?gwt.codesv... 
Content-Length: 154 
Cookie: standalone_usage=true 
Pragma: no-cache 
Cache-Control: no-cache 


7|0|4|http://127.0.0.1:8888/org.drools.guvnor.Guvnor/| 
41FA1D8B82DBBBC875605A4A29670D99| 
org.drools.guvnor.client.rpc.RepositoryService|subscribe|1|2|3|4|0| 

HTTP/1.1 200 OK 
Content-Disposition: attachment 
Content-Type: application/json;charset=utf-8 
Content-Length: 48 
Date: Wed, 23 Mar 2011 20:15:38 GMT 
Server: Apache-Coyote/1.1 
+0

這是發生在每一個請求,還是隻有一些?它是隨機的,還是有一種模式? – Rich 2011-03-31 05:08:09

回答

5

我面對我的申請同樣的問題。看起來像FireFox 3.x在XmlHttpRequest對象中設置時不會發送額外的請求標頭!

對此的快速修復是在服務器端的RPC實現覆蓋方法checkPermutationStrongName()的空實現。

@Override 
protected void checkPermutationStrongName() throws SecurityException { 
    return; 
} 

我認爲我們需要將這個問題報告給FireFox以獲得正確的修復。

+1

在firefox幫助論壇報告了這個問題。鏈接:https://support.mozilla.com/en-US/questions/802724?new=1 – Jayeshecs 2011-03-29 09:02:56

+0

謝謝,我也在這裏提交bug:https://bugzilla.mozilla.org/show_bug.cgi?id = 646378 – manstis 2011-03-30 08:51:33

1

根據我的經驗,FF有時候會丟掉任何以「X-」開頭的標題。

0

這個錯誤在我們的日誌中第一次出現在3月30日,因此它可能與FF 4.0有關,我認爲(FF4在22.03發貨)。在我們還從GWT 2.0.4遷移到2.1.1之前的幾天。這也可以是一個提示。我們的應用程序經過7個月的生產環境嚴格測試。也許這些信息會幫助某人。我正在尋找在瀏覽器緩存中檢測過時gwt應用程序的方法。當應用程序部署在服務器上時,我檢查使用當前版本生成的排列名稱並將其存儲到列表中。檢查每個RPC請求是否存在由它發送的gwt排列。有了這個錯誤,我的機制被炸燬了。