Hacking APIs: Difference between revisions

From Enlace Hacktivista
Jump to navigation Jump to search
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
Web Application Programming Interfaces (APIs) make up [https://www.akamai.com/blog/security/api-discovery-and-profiling-visibility-to-protection 83% of all web traffic] and [https://www.ibm.com/downloads/cas/WMDZOWK6 two thirds of all cloud breaches are due to misconfigured APIs] with developers hard coding credentials and exposing API keys. Organizations are using them more and more to deliver content, handle and transfer data and to implement more functionality into their services and web applications, not to mention APIs have direct back-end database access. Knights [https://web.archive.org/web/20230713230449if_/https://cdn-153.anonfiles.com/a5Q8c02azf/b80f3b8b-1689290042/Scorched-Earth-Whitepaper.pdf white paper] show cases how web APIs can be exploited via [https://owasp.org/www-project-api-security API1:2023 - Broken Object Level Authorization (BOLA)] vulnerability to transfer money in and out of bank accounts and change Visa ATM debit PIN codes. Exploiting web APIs has also been a vector for a lot of [https://www.linkedin.com/pulse/api-exploitation-leading-cause-modern-day-data-gameli-mawudor-phd data breaches].
Web Application Programming Interfaces (APIs) make up [https://www.akamai.com/blog/security/api-discovery-and-profiling-visibility-to-protection 83% of all web traffic] and [https://www.ibm.com/downloads/cas/WMDZOWK6 two thirds of all cloud breaches are due to misconfigured APIs] with developers hard coding credentials and exposing API keys. Organizations are using them more and more to deliver content, handle and transfer data and to implement more functionality into their services and web applications, not to mention APIs have direct back-end database access. Knights [https://web.archive.org/web/20230713230449if_/https://cdn-153.anonfiles.com/a5Q8c02azf/b80f3b8b-1689290042/Scorched-Earth-Whitepaper.pdf white paper] show cases how web APIs can be exploited via [https://owasp.org/www-project-api-security API1:2023 - Broken Object Level Authorization (BOLA)] vulnerability to transfer money in and out of bank accounts and change Visa ATM debit PIN codes. Exploiting web APIs has also been a vector for a lot of [https://www.linkedin.com/pulse/api-exploitation-leading-cause-modern-day-data-gameli-mawudor-phd data breaches].


Currently there is a severe lack of security testing against APIs (mobile APIs especially) from the white hats, not a lot of efforts in testing and protecting APIs and typically organizations "protect" their APIs using WAFs which are ineffective at defending APIs as they are designed to protect web applications.  
Currently there is a severe lack of security testing against APIs (mobile APIs especially) from the white hats, not a lot of efforts in testing and protecting APIs and typically organizations "protect" their APIs using WAFs which are ineffective at defending APIs as they are designed to protect web applications and not logic-based exploits.  


The top 3 most commonly used web APIs used today (2023) are: Rest, GraphQL and SOAP. Common API formats are: Json, Xml and Yaml for data transfer. It's an easier attack vector (for now). Learn how to hack web APIs to facilitate your targeted attacks!
The top 3 most commonly used web APIs used today (2023) are: Rest, GraphQL and SOAP. Common API data transfer formats are: JSON, XML and YAML. It's an easier attack vector (for now). Learn how to hack web APIs to facilitate your targeted attacks!


See [https://enlacehacktivista.org/index.php?title=Scanning_and_Recon Scanning and Recon], [https://enlacehacktivista.org/index.php?title=Search_Engines_Resources Search Engines],  [https://enlacehacktivista.org/index.php?title=Initial_Access_Tactics,_techniques_and_procedures Initial Access Tactics, techniques and procedures] and a [https://youtu.be/FqnSAa2KmBI hackers methodology] and [https://youtu.be/p4JgIu1mceI recon] as prerequisite's to hacking APIs.
See [https://enlacehacktivista.org/index.php?title=Scanning_and_Recon Scanning and Recon], [https://enlacehacktivista.org/index.php?title=Search_Engines_Resources Search Engines],  [https://enlacehacktivista.org/index.php?title=Initial_Access_Tactics,_techniques_and_procedures Initial Access Tactics, techniques and procedures] and a [https://youtu.be/FqnSAa2KmBI hackers methodology] and [https://youtu.be/p4JgIu1mceI recon] as prerequisite's to hacking APIs.
Line 9: Line 9:
== Prerequisite reading ==
== Prerequisite reading ==
* OWASP API Security Top 10: https://owasp.org/www-project-api-security | https://apisecurity.io/encyclopedia/content/owasp-api-security-top-10-cheat-sheet-a4.pdf
* OWASP API Security Top 10: https://owasp.org/www-project-api-security | https://apisecurity.io/encyclopedia/content/owasp-api-security-top-10-cheat-sheet-a4.pdf
* (Book) Hacking APIs: Breaking Web Application Programming Interfaces (2022)
* (Book) Hacking APIs: Breaking Web Application Programming Interfaces
* (Book) Black Hat GraphQL: Attacking Next Generation APIs (2023)
* (Book) Black Hat GraphQL: Attacking Next Generation APIs
* (Book) Bug Bounty Bootcamp: The Guide to Finding and Reporting Web Vulnerabilities (Chapter 24 - API Hacking) (2021)
* API Whitepapers and reports: https://salt.security/resources
* SCORCHED EARTH: [https://web.archive.org/web/20230713230449if_/https://cdn-153.anonfiles.com/a5Q8c02azf/b80f3b8b-1689290042/Scorched-Earth-Whitepaper.pdf HACKING BANKS AND CRYPTOCURRENCY EXCHANGES THROUGH THEIR APIS] (2020)
* (Book) Bug Bounty Bootcamp: The Guide to Finding and Reporting Web Vulnerabilities (Chapter 24 - API Hacking)
* [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/GraphQL%20Injection GraphQL Injection]
* SCORCHED EARTH: [https://web.archive.org/web/20230713230449if_/https://cdn-153.anonfiles.com/a5Q8c02azf/b80f3b8b-1689290042/Scorched-Earth-Whitepaper.pdf HACKING BANKS AND CRYPTOCURRENCY EXCHANGES THROUGH THEIR APIS]
* Exploiting GraphQL: https://blog.assetnote.io/2021/08/29/exploiting-graphql
* HackTricks - GraphQL: https://book.hacktricks.xyz/network-services-pentesting/pentesting-web/graphql


== Testing environments ==
== Testing environments ==
Line 37: Line 39:
* NSE Script for GraphQL Introspection Check: https://github.com/dolevf/nmap-graphql-introspection-nse
* NSE Script for GraphQL Introspection Check: https://github.com/dolevf/nmap-graphql-introspection-nse
* graphw00f is GraphQL Server Engine Fingerprinting utility: https://github.com/dolevf/graphw00f
* graphw00f is GraphQL Server Engine Fingerprinting utility: https://github.com/dolevf/graphw00f
* [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/GraphQL%20Injection GraphQL Injection]
* GraphQL Introspection analyzer: https://github.com/gwen001/graphql-introspection-analyzer
* If you have found API keys perhaps in a JavaScript file but are not sure how to test their validity use keyhacks: https://github.com/streaak/keyhacks
=== Intercepting proxies ===
=== Intercepting proxies ===
These let you view, edit, and replay requests, and are extremely useful for finding vulnerabilities in web applications, mobile and APIs.
These let you view, edit, and replay requests, and are extremely useful for finding vulnerabilities in web applications, mobile and APIs.
* https://www.postman.com (API focused)
* https://www.postman.com (API focused)
* https://portswigger.net/burp (If a WAF is blocking Burpsuite then [https://stackoverflow.com/questions/70129432/how-to-bypass-cloudflare-protection-with-burp try editing your user-agent string])
* https://portswigger.net/burp (If a WAF is blocking Burpsuite then [https://stackoverflow.com/questions/70129432/how-to-bypass-cloudflare-protection-with-burp try editing your user-agent string])
* https://www.zaproxy.org | [https://www.zaproxy.org/blog/2020-08-28-introducing-the-graphql-add-on-for-zap GraphQL Add-on for ZAP] to enumerate GraphQL Introspection.
* https://www.zaproxy.org | [https://www.zaproxy.org/blog/2020-08-28-introducing-the-graphql-add-on-for-zap GraphQL Add-on for ZAP] to exploit GraphQL Introspection.


=== Fuzzing ===
=== Fuzzing ===
[https://blog.intigriti.com/2021/09/07/hacker-tools-kiterunner/ KiteRunner], [https://enlacehacktivista.org/index.php?title=Scanning_and_Recon#Content_discovery web API content discovery] tool:
* https://github.com/assetnote/kiterunner (API focused)
* https://github.com/assetnote/kiterunner
* https://github.com/ffuf/ffuf
* https://github.com/ffuf/ffuf
* https://www.kali.org/tools/wfuzz
* https://www.kali.org/tools/wfuzz
Line 64: Line 69:


== Exploitation ==
== Exploitation ==
Although API specific exploitation may require scripting or custom payloads to mass scrape data or exploit vulnerabilities it's still worth knowing common payloads and exploit tools for web applications: https://enlacehacktivista.org/index.php?title=Exploitation
Although API specific exploitation may require scripting or custom payloads to mass scrape data or exploit logic based vulnerabilities it's still worth knowing common payloads and exploit tools for web applications: https://enlacehacktivista.org/index.php?title=Exploitation

Revision as of 10:38, 31 March 2024

Web Application Programming Interfaces (APIs) make up 83% of all web traffic and two thirds of all cloud breaches are due to misconfigured APIs with developers hard coding credentials and exposing API keys. Organizations are using them more and more to deliver content, handle and transfer data and to implement more functionality into their services and web applications, not to mention APIs have direct back-end database access. Knights white paper show cases how web APIs can be exploited via API1:2023 - Broken Object Level Authorization (BOLA) vulnerability to transfer money in and out of bank accounts and change Visa ATM debit PIN codes. Exploiting web APIs has also been a vector for a lot of data breaches.

Currently there is a severe lack of security testing against APIs (mobile APIs especially) from the white hats, not a lot of efforts in testing and protecting APIs and typically organizations "protect" their APIs using WAFs which are ineffective at defending APIs as they are designed to protect web applications and not logic-based exploits.

The top 3 most commonly used web APIs used today (2023) are: Rest, GraphQL and SOAP. Common API data transfer formats are: JSON, XML and YAML. It's an easier attack vector (for now). Learn how to hack web APIs to facilitate your targeted attacks!

See Scanning and Recon, Search Engines, Initial Access Tactics, techniques and procedures and a hackers methodology and recon as prerequisite's to hacking APIs.

Prerequisite reading

Testing environments

Labs

Tools

Intercepting proxies

These let you view, edit, and replay requests, and are extremely useful for finding vulnerabilities in web applications, mobile and APIs.

Fuzzing

Wordlists

Kiterunner word lists:

  1. https://wordlists-cdn.assetnote.io/rawdata/kiterunner/routes-large.json.tar.gz
  2. https://wordlists-cdn.assetnote.io/data/kiterunner/routes-large.kite.tar.gz
  3. https://wordlists-cdn.assetnote.io/rawdata/kiterunner/routes-small.json.tar.gz
  4. https://wordlists-cdn.assetnote.io/data/kiterunner/routes-small.kite.tar.gz
  5. https://wordlists-cdn.assetnote.io/rawdata/kiterunner/swagger-files.tar
  6. https://wordlists-cdn.assetnote.io/data/kiterunner/swagger-wordlist.txt

Web API specific word lists:

Exploitation

Although API specific exploitation may require scripting or custom payloads to mass scrape data or exploit logic based vulnerabilities it's still worth knowing common payloads and exploit tools for web applications: https://enlacehacktivista.org/index.php?title=Exploitation