top
Loading...
BEAWebLogic暴露源代碼漏洞
涉及程序:
BEA WebLogic Server and Express 5.1.x/4.5x/4.0x/3.1.8

描述:
BEA WebLogic 暴露源代碼漏洞

詳細:
受影響版本
所有系統上的
BEA WebLogic Enterprise 5.1.x
BEA WebLogic Server and Express 5.1.x
BEA WebLogic Server and Express 4.5.x
BEA WebLogic Server and Express 4.0.x
BEA WebLogic Server and Express 3.1.8

這個漏洞使攻擊者能讀取 Web 目錄下所有文件的源代碼。
WebLogic 依賴四個主要 Java Servlets to 服務不同類型的文件。這些 servlets 是:

FileServlet - for 簡單 HTML 頁面
SSIServlet - for Server Side Includes 頁面
PageCompileServlet - for JHTML 頁面
JSPServlet - for Java Server 頁面

看著weblogic.properties 文件, 這兒是各個 servlets 的注冊值 :

weblogic.httpd.register.file=weblogic.servlet.FileServlet
weblogic.httpd.register.*.shtml=weblogic.servlet.ServerSideIncludeServlet
weblogic.httpd.register.*.jhtml=weblogic.servlet.jhtmlc.PageCompileServlet
weblogic.httpd.register.*.jsp=weblogic.servlet.JSPServlet

更多的 weblogic.properties 文件, 如果一個請求文件是沒有注冊管理的,那么就會調用一個默認的 servlet 。以下是展示默認的 servlet 是如何注冊的。

# Default servlet registration
# ------------------------------------------------
# Virtual name of the default servlet if no matching servlet
# is found weblogic.httpd.defaultServlet=file

因此如果 URL 中的文件路徑開頭為 "/file/" , 將會引致 WebLogic 調用默認的 servlet, 那將會使網頁未加分析和編譯而直接顯示。

論證:
只要在想看的文件原來的 URL 路徑之前加入 "/file/" 就會讓文件未經分析和編譯,直接暴露源代碼。如:

http://site.running.weblogic/login.jsp

那么只要訪問

http://site.running.weblogic/file/login.jsp

就會在 WEB 瀏覽器里看到文件的內容。

以下是使用方法:
1. 通過強制使用 SSIServlet 查看未分析的頁面 :
----------------------------------------------------------
服務器站點通過 WebLogic 中的 SSIServlet 處理頁面,它在 weblogic.properties 文件中注冊以下信息:

weblogic.httpd.register.*.shtml=
weblogic.servlet.ServerSideIncludeServlet

通過 URL 使用 SSIServlet 自動處理通配符 (*) 。因此 如果文件路徑開頭為 /*.shtml/,將強制文件由 SSIServlet 處理。如果使用其它文件類型如 .jsp 和 .jhtml, 就能查看未分析的 jsp 和 jhtml 代碼。舉例:
http://www.xxx.com/*.shtml/login.jsp

2. 通過強制使用 FileServlet 查看未分析的頁面 :
-----------------------------------------------------------
WebLogic 使用 FileServlet 配置 ConsoleHelp servlet ,在 weblogic.properties 文件的以下內容可得知:

# For Console help. Do not modify.
weblogic.httpd.register.ConsoleHelp=
weblogic.servlet.FileServlet
weblogic.httpd.initArgs.ConsoleHelp=
defaultFilename=/weblogic/admin/help/NoContent.html
weblogic.allow.execute.weblogic.servlet.ConsoleHelp=everyone

因此如果文件路徑以 /ConsoleHelp/ 開頭將導致 WebLogic 使用 FileServlet,使未分析或編譯的文件作頁面顯示出來,舉例:
http://www.xxx.com/ConsoleHelp/login.jsp

解決方案:
不要使用示例中的設置方法設置 FileServlet 。這可能會讓你的 JSP/JHTML 文件的源代碼暴露出來。請查看在線文檔:

http://www.weblogic.com/docs51/admindocs/http.html#file

示例的 registrations 如下:

weblogic.httpd.register.file=weblogic.servlet.FileServlet
weblogic.httpd.initArgs.file=defaultFilename=index.html
weblogic.httpd.defaultServlet=file

有兩種方法可以避免這個問題:

* 注冊那些文件 servlet 使用隨機用戶名,加大猜測難度。例如使用象這樣注冊文件 servlet 為 12foo34:

weblogic.httpd.register.12foo34=weblogic.servlet.FileServlet
weblogic.httpd.initArgs.12foo34=defaultFilename=index.html
weblogic.httpd.defaultServlet=12foo34

* 注冊文件 servlet 使用 wild cards 聲明你將使用所有這些文件擴展名作服務。舉例注冊文件 servlet 為 .html 文件服務:

weblogic.httpd.register.*.html=weblogic.servlet.FileServlet
weblogic.httpd.initArgs.*.html=defaultFilename=index.html
weblogic.httpd.defaultServlet=*.html

使用上面的方法重復加入以下類型的文件 *.gif, *.jpg, *.pdf, *.txt, etc.

注意:這些信息是備有證明在 BEA WebLogic Server and Express 說明檔的:

http://www.weblogic.com/docs51/admindocs/lockdown.html

另:請留意新版本并升級吧。

北斗有巢氏 有巢氏北斗