
Your tests are passing. Your API works... But can one user access another user's data?
Let's talk about a dangerous assumption developers make all the time:
"If the user is logged in, they can access the endpoint."
Nope.
Being authenticated doesn't automatically mean someone is authorized to access every resource in your application.
And confusing those two concepts can turn an ordinary API endpoint into a serious security vulnerability.
In June 2025, security researchers discovered exactly this kind of problem while investigating McDonald's hiring platform, McHire.
The incident involved a weak test account and an API that allowed access to other applicants' records by changing a numeric identifier.
More than 64 million application records were potentially exposed.
What makes this particularly interesting for developers?
The vulnerability didn't require complicated exploitation.
It exposed a problem that could exist in thousands of applications we build every day.
Let's break it down.
The 10-second code review test
Imagine you see this code in a pull request:
app.get('/users/:id', authenticate, async (req, res) => {
const user = await User.findById(req.params.id);
res.json(user);
});
Would you approve it?
Maybe.
It has authentication middleware. It retrieves the requested user. There's nothing obviously broken.
But here's the question:
What stops User A from requesting User B's profile?
Try this:
GET /users/101
Then:
GET /users/102
If the application only checks whether someone is logged in, changing the ID might be enough to access another user's information.
This is an example of IDOR (Insecure Direct Object Reference), a vulnerability associated with Broken Access Control.
And it's precisely the kind of issue that can survive an ordinary code review.
Authentication vs. authorization: They're not the same thing
Let's make this simple.
Authentication: Who are you?
Authorization: What are you allowed to do?
For example:
Imagine an employee management application.
Alice and Bob both have valid accounts.
Alice is authenticated. Bob is authenticated.
But Alice shouldn't automatically be able to access Bob's salary information just because she knows his employee ID.
Authentication confirms Alice's identity.
Authorization determines whether Alice has permission to view that particular record.
A safer implementation would look like this:
app.get('/users/:id', authenticate, async (req, res) => {
const user = await User.findOne({
_id: req.params.id,
organizationId: req.user.organizationId
});
if (!user) {
return res.status(404).json({
message: 'User not found'
});
}
res.json(user);
});
Now the database query also checks organization ownership.
Of course, real applications may need more sophisticated role-based or resource-based authorization. But the principle remains the same.
Never assume that a valid session grants unrestricted access.
2025 gave developers several reminders
The McHire incident wasn't the only security story worth paying attention to.
A few other incidents in 2025 highlighted different weaknesses in software development.
1. Tea app: Cloud storage isn't private by default
The dating-safety app Tea experienced a major exposure involving publicly accessible cloud storage.
Approximately 72,000 images were reported exposed, including selfies and identity documents.
Lesson: Always verify storage permissions. A secure API cannot protect files sitting in a publicly accessible bucket.
2. Next.js: Middleware isn't a complete security boundary
CVE-2025-29927 affected middleware-based authorization in Next.js and allowed bypasses under affected configurations.
Lesson: Don't put every security decision in one middleware layer. Sensitive backend operations should enforce their own authorization rules.
3. npm supply-chain compromise: Your dependencies are part of your attack surface
In September 2025, a phishing attack compromised the account of a major npm package maintainer, resulting in malicious package releases.
Lesson: Your application isn't only the code your team writes. It's also the packages your build process trusts.
Different incidents, different technologies, but one common lesson:
Security needs to be part of everyday development, not something we think about after an incident.
Why do we keep missing these bugs?
I don't think the answer is that developers are careless.
Most developers already know that security matters.
The problem is how software gets built.
Think about a typical development cycle:
- A feature gets assigned.
- A developer implements it.
- AI tools help generate some of the code.
- Tests pass.
- A pull request gets created.
- Someone reviews it between meetings.
- The code gets merged.
Now imagine that reviewer has 10 more pull requests waiting.
They're checking whether the implementation makes sense, whether tests pass, and whether the feature behaves correctly.
A missing authorization condition is easy to overlook because the code still works exactly as written.
This is where we need to rethink code review.
What I would check before merging an API pull request
Here's a small checklist I think every backend developer should keep nearby.
1. Check resource ownership
Whenever you see:
Model.findById(id);
Ask whether the requesting user is allowed to access that record.
2. Test with another user's account
Don't only test the happy path.
Create two test users:
- User A owns Resource A.
- User B owns Resource B.
Authenticate as User A and try accessing Resource B.
The expected result should be an authorization failure.
3. Don't trust client-side permissions
Hiding a button in the frontend doesn't prevent someone from calling the API directly.
The backend must enforce permissions.
4. Check updates and deletes too
Developers sometimes secure GET endpoints but forget:
PATCH /users/:id
DELETE /users/:id
Authorization must be enforced consistently across every operation.
5. Check configuration and dependencies
Reviewing application code isn't enough.
Look at:
- Environment variables and secrets.
- Cloud storage permissions.
- Dependency versions.
- CI/CD configuration.
- Security-sensitive middleware.
Security is an application-wide responsibility.
Can AI code review help?
I think it can, especially when used as an additional reviewer rather than a replacement for humans.
Consider the earlier example:
const user = await User.findById(req.params.id);
A security-focused AI reviewer could flag:
Potential issue: Missing authorization check
This query retrieves a user record using an identifier but doesn't verify whether the authenticated user has permission to access it.
Potential impact: Unauthorized access to another user's information if the endpoint is exposed without additional authorization controls.
Suggested fix: Scope the database query to the authenticated user's permissions or organization.
That's useful feedback.
Not just "this code looks suspicious."
It explains what might go wrong and gives the developer a starting point for fixing it.
Of course, AI tools aren't perfect.
They can produce false positives, miss complex business-logic vulnerabilities, and struggle with infrastructure changes outside the repository.
That's why I believe the best approach is a combination of:
- Human code review.
- Automated security scanning.
- AI-assisted review.
- Automated authorization tests.
- Runtime monitoring.
Each layer catches different problems.
What we're trying to solve with Codzee
This is one of the problems behind our work on Codzee.
We believe code review should do more than check whether code follows conventions.
It should help developers identify meaningful bugs and security risks before those changes reach production.
Codzee reviews pull requests, highlights issues on the relevant lines, explains why they matter, and suggests fixes that developers can apply.
The idea isn't to generate hundreds of warnings.
It's to help teams notice the important things without adding unnecessary noise to their workflow.
Because a code review tool that developers constantly ignore isn't doing its job.
One question before you merge
The next time you review a pull request containing an API endpoint, database query, or resource lookup, pause for a moment.
Don't just ask:
"Does this endpoint work?"
Ask:
"Can someone access something they don't own?"
That question might catch a bug your tests never will.
And sometimes, the difference between a secure application and a security incident is just one missing authorization check.
Let's discuss
I'm curious about your experience as a developer:
- Have you ever discovered an IDOR or authorization bug during code review?
- Do your teams test access permissions using multiple user accounts?
- Would you trust an AI reviewer to flag security issues in your pull requests?
Share your thoughts. I'd love to hear how other teams approach this.
References:
- Ian Carroll and Sam Curry – McHire security research
- NVD – CVE-2025-29927
- OWASP Top 10:2025
- Simon Willison – Tea app security incident
- The Register – npm supply-chain compromise (September 2025)
Disclosure: We're building Codzee, an AI-powered code review tool focused on identifying real bugs and security risks before code gets merged.
About the author
- Codzee is building the future of AI-powered code reviews for modern engineering teams. We help developers review pull requests faster, improve code quality, and ship software with confidence. Codzee analyzes your code, highlights potential issues, suggests meaningful improvements, and delivers actionable feedback that fits your team's coding standards and workflow. Our mission is simple: make code reviews faster, smarter, and more collaborative without disrupting how developers work. Whether you're a startup shipping your first product or a growing engineering organization, Codzee helps reduce review bottlenecks, maintain consistent code quality, and improve developer productivity. At Codzee, we believe AI should support developers, not replace them. That's why we're building AI Code Review That Respects Your Team.
Comments
Join the discussionNo comments yet. Be the first to comment.



