# CVE-2024-40725 漏洞復現 ## 漏洞說明 以 Apache 的 AddType 指令來說應該是用來設定文件的附檔名應該被以何種方式處理,但在 2.4.61(包含)以下,它會因為 Apache 本身在處裡這個指令的時候有問題,所以造成洩漏原始碼的狀況 以本次復現來說,我們使用的方法是在 httpd.conf 中加上 `AddType application/x-httpd-php .php ` 來設定 .php 檔案會被當作 PHP 的腳本來執行,但在實際執行後會發現我們後來加上去的 .php 檔案都會被丟出實際的程式內容  ## 環境 Kali Linux 2024.2 VMware ## 安裝存在漏洞版本 1. 安裝依賴套件 ``` sudo apt update sudo apt install build-essential libpcre3 libpcre3-dev libssl-dev wget autoconf libtool ``` - 備註: libtool 直接 apt 安裝疑似會無法安裝,可以直接輸入 libtool 讓它自行跑安裝 2. 安裝 ARP & ARP-Util - ARP ``` wget https://archive.apache.org/dist/apr/apr-1.7.0.tar.gz tar -xvzf apr-1.7.0.tar.gz cd apr-1.7.0 ./configure make sudo make install cd .. ``` - ARP-Util ``` wget https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz tar -xvzf apr-util-1.6.1.tar.gz cd apr-util-1.6.1 ./configure --with-apr=/usr/local/apr make sudo make install cd .. ``` 3. 安裝 Apache HTTP Server 2.4.61 ``` wget https://archive.apache.org/dist/httpd/httpd-2.4.61.tar.gz tar -xvzf httpd-2.4.61.tar.gz cd httpd-2.4.61 ``` 4. 編譯 - `./buildconf` - `./configure --with-included-apr` - `make` - `sudo make install` ## 嘗試復現漏洞 1. 修改設定檔 `sudo vim /usr/local/apache2/conf/httpd.conf` 2. 在內容中添加 AddType `AddType application/x-httpd-php .php`  3. 開啟 Apache `sudo /usr/local/apache2/bin/apachectl start`  - 這裡可能會跳出錯誤 ``` AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message httpd (pid 1578131) already running ``` - 可以在檔案中加上 ServerName 解決 -  4. 在 /usr/local/apache2/htdocs/ 增加 test.php ``` <?php echo "This is a test script."; ?> ``` 5. 重新調整文件的權限 ``` sudo chmod 644 /usr/local/apache2/htdocs/test.php sudo chown www-data:www-data /usr/local/apache2/htdocs/test.php ``` ## 嘗試實現漏洞結果 1. 使用 curl 訪問文件 `curl http://127.0.0.1/test.php ` 2. 結果 - 正常狀況應該回傳 This is a test script - 目前回傳為:  - 確實將原始碼整個打印出來 - 漏洞確實存在 ## 實際利用 - 目前經過一段時間的測試,對於外部攻擊似乎沒有實際可利用手段來透過這個 CVE 對未更新版本進行攻擊或原始碼洩漏,更多是網站建立時沒有經過正確檢查而產生本身的原始碼洩漏問題。 ## 修補辦法 1. 更新 Apache 版本至 2.4.62 以上版本(官方已進行修補)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up