WEB06: XXE
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Lab: Exploiting XXE using external entities to retrieve files
Access vào bài lab, ở chức năng Check stock
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Một POST request được gửi lên server với nội dung định dạng xml
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Ta khai báo mới một external entity xxe
trỏ đến nội dung file passwd và đọc được nội dung của file này
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Gửi GET request đến server chạy EC2 metadata endpoint và đọc response thông qua XXE
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Tiếp tục gửi đến endpoint latest
của server này, ta được một endpoint khác là meta-data
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Dựa theo link này, ta tiếp tục SSRF để tìm đến endpoint chứa IAM secret access key
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-> Solve bài lab
Lab: Blind XXE with out-of-band interaction
Ở bài lab này yêu cầu detect XXE bằng kĩ thuật OOB nên ta sẽ tạo một burp collaborator server và solve bài lab với payload như sau
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Lab: Blind XXE with out-of-band interaction via XML parameter entities
Bài này khác so với các bài trước ở chỗ đó là server đã chặn và k parse external entity
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Nhưng ta có thể bypass bằng cách sử dụng parameter entity và gửi một DNS lookup query đến burp collab client
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-> Thành công solve bài lab
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Lab: Exploiting blind XXE to exfiltrate data using a malicious external DTD
Ở bài lab này, ta sẽ cần đọc nội dung file /etc/hostname
và gửi đến exploit server. Lí thuyết sẽ như sau
- Defines an XML parameter entity called
file
, containing the contents of the /etc/hostname
file.
- Defines an XML parameter entity called
eval
, containing a dynamic declaration of another XML parameter entity called exfiltrate
. The exfiltrate
entity will be evaluated by making an HTTP request to the attacker's web server containing the value of the file entity within the URL query string.
- Uses the
eval
entity, which causes the dynamic declaration of the exfiltrate
entity to be performed.
- Uses the exfiltrate
entity
, so that its value is evaluated by requesting the specified URL.
Setup up exploit server
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Gửi payload trigger XXE để vulnerable server fetch nội dung của file exploit.dtd và thực hiện parse file này
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Kết quả
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Submit solution và solve bài lab
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Lab: Exploiting blind XXE to retrieve data via error messages
Bài lab này, ta có sử dụng kĩ thuật đọc nội dung của một file bất kì thông qua error message, lí thuyết như sau:
- Defines an XML parameter entity called
file
, containing the contents of the /etc/passwd
file.
- Defines an XML parameter entity called
eval
, containing a dynamic declaration of another XML parameter entity called error
. The error
entity will be evaluated by loading a nonexistent file whose name contains the value of the file
entity.
- Uses the
eval
entity, which causes the dynamic declaration of the error
entity to be performed.
- Uses the
error
entity, so that its value is evaluated by attempting to load the nonexistent file, resulting in an error message containing the name of the nonexistent file, which is the contents of the /etc/passwd
file.
Setup exploit server
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Gửi payload trigger XXE và kết quả:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Lab: Exploiting XXE to retrieve data by repurposing a local DTD
Lợi dụng load một local dtd file và sau đó định nghĩa lại một entity trong file đó, sau đó sử dụng kĩ thuật error message như lab trước để đọc content của một file bất kì. Lí thuyết cụ thể:
- Defines an XML parameter entity called
local_dtd
, containing the contents of the external DTD file that exists on the server filesystem.
- Redefines the XML parameter entity called
custom_entity
, which is already defined in the external DTD file. The entity is redefined as containing the error-based XXE exploit that was already described, for triggering an error message containing the contents of the /etc/passwd file.
- Uses the
local_dtd
entity, so that the external DTD is interpreted, including the redefined value of the custom_entity entity. This results in the desired error message.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Lab: Exploiting XInclude to retrieve files
Ở bài này, server lấy input từ các trường productId và stockId để đưa vào một file XML và thực hiện parse file này. Ta không thể áp dụng kĩ thuật tấn công XXE bởi vì trong TH này không thể kiểm soát hoàn toàn nội dung của file XML. Vì thế có thể sử dụng một kĩ thuật khác để đọc nội dung file đó là XInclude, include một sub-document là file /etc/passwd:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Lab: Exploiting XXE via image file upload
XXE thông qua file upload, ở bài này server cho phép chúng ta chức năng upload avatar khi post comment, vì vậy ta có thể lợi dụng format của file svg để khai thác XXE. Tạo một file exploit.svg
với content như sau:

Sau đó upload file này

Reload lại trang và một GET request để fetch file avatar trả về nội dung của /etc/hostname

Submit solution và solve bài lab
