# Portswigger Information Disclosure 🤪 <style>body {text-align: justify}</style> Hi, dưới đây là writeup của 5/5 bài lab về lỗ hổng [Information Disclosure](https://portswigger.net/web-security/information-disclosure) mình đã solve trong quá trình ôn tập thi chứng chỉ của Portswigger. ### 1. Information disclosure in error messages ##### Description > This lab's verbose error messages reveal that it is using a vulnerable version of a third-party framework. To solve the lab, obtain and submit the version number of this framework. ##### Writeup Mục tiêu của bài lab này là trigger được lỗi của ứng dụng và trích xuất thông tin version của framework được sử dụng. ![](https://i.imgur.com/8TPqZoF.png) Khi truy cập sản phẩm theo `productId`, giá trị `productId` phải là một số nguyên int. ![](https://i.imgur.com/yzSZqO0.png) Khi truy xuất sản phẩm với `productId` không phải dạng int thì nó sẽ báo lỗi debug. Đọc lỗi cho biết ứng dụng được dev bằng Java và framework được sử dụng là `Apache Struts 2 2.3.31`. ![](https://i.imgur.com/sPrWWRJ.png) Lấy version trên và submit, ta solve được challenge. ![](https://i.imgur.com/j9xmxY0.png) ### 2. Information disclosure on debug page ##### Description > This lab contains a debug page that discloses sensitive information about the application. To solve the lab, obtain and submit the `SECRET_KEY` environment variable. ##### Writeup Khi xem source trang chủ, ta thấy xuất hiện 1 comment chứa đường link dẫn tới trang `Debug` tại `/cgi-bin/phpinfo.php`. ![](https://i.imgur.com/RpwI5ot.png) Truy cập `/cgi-bin/phpinfo.php`, ta thấy đây là trang phpinfo mặc định chứa các thông tin của server. Trong đó có trường `SECRET_KEY` cần tìm. ![](https://i.imgur.com/20Hkqhl.png) Lấy giá trị `SECRET_KEY` tìm được và submit, ta sẽ solve được challenge. ![](https://i.imgur.com/9I3TloQ.png) ### 3. Source code disclosure via backup files ##### Description > This lab leaks its source code via backup files in a hidden directory. To solve the lab, identify and submit the database password, which is hard-coded in the leaked source code. ##### Writeup Truy cập trang `robots.txt`, ta thấy ứng dụng có để lộ ra một thư mục `/backup`. ![](https://i.imgur.com/wvHHwgX.png) Tại thư mục `/backup`, xuất hiện một file backup mã nguồn java. ![](https://i.imgur.com/zzOmbYi.png) Truy cập file backup trên theo đường dẫn `/backup/ProductTemplate.java.bak`, ta đọc được mã nguồn. Cụ thể, file này có chứa một hàm kết nối database và có để lộ config về database. Trong đó, `password` chính là thứ ta cần tìm (được gạch đỏ). ![](https://i.imgur.com/Fsi6J6n.png) Submit password trên và ta solve được challenge. ![](https://i.imgur.com/Lo33l7J.png) ### 4. Authentication bypass via information disclosure ##### Description > This lab's administration interface has an authentication bypass vulnerability, but it is impractical to exploit without knowledge of a custom HTTP header used by the front-end. > > To solve the lab, obtain the header name then use it to bypass the lab's authentication. Access the admin interface and delete Carlos's account. > > You can log in to your own account using the following credentials: `wiener:peter` ##### Writeup Ứng dụng web của lab này cho phép user thực hiện được `TRACE` method ở tất cả các request. Khi đó, user có thể đọc được request thực sự mà server nhận được &rarr; Điều này dẫn đến có thể để lộ một số trường header nhạy cảm. Cụ thể ở đây là `X-Custom-IP-Authorization`. Đây là header có chức năng xác định IP nguồn của request để từ đó authorize theo. Như vậy, nếu `X-Custom-IP-Authorization: 127.0.0.1` thì chứng tỏ request được gửi từ localhost và có thể được authorize làm admin. ![](https://i.imgur.com/pd5CQ9p.png) Với user thường, truy cập `/admin` sẽ bị cấm. ![](https://i.imgur.com/2nfDKch.png) Tuy nhiên, khi thêm `X-Custom-IP-Authorization: 127.0.0.1`, ta đã vào được và có đủ chức năng của admin. ![](https://i.imgur.com/8xRFup6.png) Thực hiện xóa user carlos. ![](https://i.imgur.com/pAsaPxN.png) Sau đó, ta đã solve được challenge. ![](https://i.imgur.com/hol0vd4.png) ### 5. Information disclosure in version control history ##### Description > This lab discloses sensitive information via its version control history. To solve the lab, obtain the `password` for the `administrator` user then log in and delete Carlos's account. ##### Writeup Đối với bài lab này, thư mục `/.git` bị public &rarr; các thông tin log về các commit sẽ bị lộ. ![](https://i.imgur.com/J72DH7L.png) Sử dụng câu lệnh sau để download thư mục `.git` về để phân tích. ```bash wget -r https://0a8c00ff04fcc303c15b210300c600c1.web-security-academy.net/.git/ --no-check-certificate ``` Sử dụng câu lệnh `git log` ta xem được các commit mà các developers đã thực hiện. Có xuất hiện commit `ef5...` chứa thông tin về admin password. ![](https://i.imgur.com/DP2jrI1.png) Dùng `git show <commit id>`, ta sẽ xem được chi tiết thay đổi của commit đó. Cụ thể, nó xóa admin password đi tại file admin.conf và thành bằng `env('ADMIN_PASSWORD')`. Tuy nhiên, ta đã leak được password của admin là `2237xgsyi4lba8qqcrwt`. ![](https://i.imgur.com/ejAvljR.png) Lúc này ta đăng nhập bằng tài khoản `administrator:2237xgsyi4lba8qqcrwt` và xóa user `carlos` đi. Như vậy, ta đã solve challenge thành công. ![](https://i.imgur.com/PRbMJCO.png) ###### tags: `portswigger`, `information-disclosure`