Authentication: This is the process of verifying a client's identity.
Authorization: This process determines what actions and data a client is allowed to access after their identity is verified.
GraphQL's Role: GraphQL itself doesn't have built-in authentication or authorization mechanisms; these are left to the developers to implement. This variability in implementation introduces potential vulnerabilities.
In-Band vs. Out-of-Band Controls
In-band Authentication and Authorization: These controls are implemented directly within the GraphQL API.
This approach increases the attack surface, making the API more vulnerable to direct attacks.
When authentication and authorization mechanisms are part of the GraphQL schema, they are more likely to be targeted and potentially bypassed.
Out-of-band Authentication and Authorization: These delegate the security functions to external systems, which can be a more secure approach.
Common Authentication Approaches
HTTP Basic Authentication: This method sends credentials in the header of a client request.
It is straightforward but can be insecure if not implemented over HTTPS.
Bypassing Allow-Listed Operation Names: Attackers can bypass allow lists of operation names by spoofing or changing the operation name.
# The following is an example of an unauthenticated mutation. As you can see, it would allow a user to register a new user account:mutationRegisterAccount { register(username: "operator", password: "password"){ user_id }}-----------------------------------# An example operation that could bypass authentication by using an allow-listed operation nameWe used the allowed operation name to withdraw money with a withdrawal mutation.mutationRegisterAccount { withdrawal(amount: 100.00, from: "ACT001", dest: "ACT002"){ confirmationCode }}
JWT Forgery: If JWT signatures are not correctly verified, attackers can forge valid tokens.
It's essential to identify all possible paths to a given object type, using tools like graphql-path-enum. This allows an attacker to understand the relationships within the schema and find authorization vulnerabilities.
Inconsistent Protection: Developers might protect some queries but not others, offering different paths to the same data. For example, pastes might be protected, but not paste or readAndBurn.