Depending on the app’s architecture, specific parts of a request may be processed in unsafe ways (applies to any web app whether it’s an API or older app) including:
Improper parameterization of requests within app logic
Are they just concatenating variables and input together and treating all input as trusted?
Lack of input sanitization / escaping unsafe characters
Improper handling of parameters
Insufficient controls for data types passed (File upload bugs, Unicode bugs)
Can you pass a PDF, a ZIP file or Unicode? And is that properly handled?
Example of input validation bug: German eID System #
Germany has an eID system for people to use their real-life identity online
Requests to the German eID System required to be signed to be valid
The app didn’t account for the same parameter occurring multiple times:
If an attacker supplies multiple parameters named SAMLResponse, the signature is verified against the last occurrence of the parameter, while the SAML response that is processed further, will be taken from the first occurrence
E.g.: &user=Andy&user=Sam => &user=Sam is used for signature but after that the app uses the first parameter &user=Andy
=> Attackers could change their identity entirely within the system
Encoding errors with Junl characters, control character, emoji, Unicode points that don’t have any data associated with them (another thing that apps sometimes forget to include processing for), etc
File upload vulnerabilities
SSRF
Tools you can use
Burp
Enumeration tools (Gobuster, Dirb…) and wordlists (Seclists & Github Awesome lists of fuzzing payloads and app parameters)
Custom scripts
Protip: Speed up your fuzzing by making HEAD requests to API endpoints
Make a bunch of requests and see what happens: Check response headers to see if you get back any responses that are rate limiting tokens
Make requests in varying states of authentication (because sometimes you’re only rate limited if you are at a certain access level):
as an unauthenticated user
as an authenticated user
as a developer
as a bot
with a deactivated account
with bogus credentials
=> an API with improperly implemented rate limiting can be used to make an abnormal amount of requests to enumerate the app & potentially cause other issues like DoS
APIs are built to support a lot of different HTTP methods for different purposes (like inserting client records and modifying things with PUT & DELETE requests)
Important to do when fuzzing an API: Determine what the app expects & what it supports
Some of these methods can be accessed unauthenticated & sometimes the scope of specific methods is too broad
=> user is able to PUT, DELETE, POST, etc parts of the API that it shouldn’t
Basically you would be able to find undocumented features of the API with this
So it’s good to look at the API spec/documentation, see which methods are requested & compare them to which ones are actually allowed based on what the server tells you
Even if these HTTP methods aren’t included in the app logic, if an app is lazy with this & has no logic to parse, weird things can happen
Request splitting: Making additional requests to 3rd party API through the target API
SSRF: APIs that can resolve URLs can be tricked into making requests in the context of the server itself. Can lead to enumeration of private internal network, or gaining access to server metadata in a cloud environment
Unhandled input from 3rd party: Can result in unexpected errors in the target app
Sometimes you might make a request to your 3rd party API that gives back data that was unexpected and causes unexpected outcomes withing the target API you’re testing
Requests to the Discord API were rate limited only if authenticated
The invite scheme for Direct Messages was the same as those for server invites. DM invite codes are only used internally and assume that a user is already authorized to be in a group DM if an invite is used
2 types of invite codes: invites for one-time use & invites that doesn’t expire
Invite codes are 6 characters for temporary invite codes
Two APIs available to test (old & new one)
Always ask yourself: Is there more than one API? (dev API, deprecated API that’s still available…)
The Duda Mobile website templating service takes existing websites & turn them into mobile-friendly templates
It has an API built in to process external links that are loaded & converted into a mobile safe format. It strips JavaScript & CSS and attempts to load the website into a preset theme
Andy was able to get past filtering mechanisms to bypass JavaScript filtering (with onload directive & image tags)
He could use a mobile site’s rendering API to load 3rd party APIs within the context of any website on their platform
I.e. it was possible to load arbitrary URLs into the template of the website
This allowed for SSRF attacks made on Duda’s infrastructure: mobile.dudasite.com/site/<sitename>/default?url=<externalUrl>