The user field in the Ravens API takes an id and returns that user private data — email and stash code — without checking you own the record. It is IDOR through GraphQL.
A GraphQL explorer. The user(id) field returns name, email and stashCode for any id. You are user 2, and no check stops you reading another record.
You read another user private data.
Why the solution worked
The resolver returns the record matching the id with no check that the current user owns it; object-level authorization is missing on the field. The fix is an ownership check inside every resolver that returns private data.
The root cause
The resolver does not check object ownership before returning it. The root is missing object-level authorization in GraphQL.
How the code is fixed
Check object ownership inside every resolver that returns private data; do not trust the id.
Vulnerable code
user: (parent, { id }) => db.users.find(id) // returns anyone's private data
Safe code
user: (parent, { id }, ctx) => {
if (String(id) !== String(ctx.user.id)) throw new ForbiddenError('not your record');
return db.users.find(id);
}
Impact in the real world
Broken object authorization leaks any user data by changing an id, among the most common GraphQL bugs.
How defenders detect it
Defenders enforce an ownership check in every resolver and alert on queries requesting records by ids that are not the user.
Your workspace now has a Server logs tab: your own attack, as the defender saw it, with the alerting lines marked.
Solved with the walkthrough. Put it aside and solve again to earn the feather.