Dev.to AI 🤖 Ai 👁 0 📖 7 min read

Your API Has Authentication. But Does It Have Authorization?

Lessons from the McHire security incident and why every API endpoint deserves a second look A developer writes an API endpoint. It checks whether the user is logged in, fetches a database record using an ID, and retu

Your API Has Authentication. But Does It Have Authorization?

Lessons from the McHire security incident and why every API endpoint deserves a second look

A developer writes an API endpoint. It checks whether the user is logged in, fetches a database record using an ID, and returns the result.

The tests pass. The pull request gets approved. The feature ships.

Everything looks fine.

Except there's one problem: the endpoint never checks whether the authenticated user actually owns the requested record.

This is one of the most common and dangerous mistakes in application security. It's also one of the easiest to overlook during code review.

In June 2025, security researchers Ian Carroll and Sam Curry demonstrated exactly how damaging this kind of oversight could be when they investigated McDonald's hiring platform, McHire.

Their discovery offers an important lesson for every developer building APIs in 2025 and beyond:

Authentication tells you who someone is. Authorization determines what they're allowed to access. Never confuse the two.

1. The McHire incident: A missing authorization check

McHire is a hiring platform used by McDonald's franchisees. Applicants interact with an AI-powered chatbot named Olivia and submit personal information during the application process.

While investigating the platform, security researchers discovered an exposed administrative account associated with Paradox.ai, the company behind the hiring software.

The credentials were reportedly:

  • Username: 123456
  • Password: 123456

The account provided access to an administrative interface.

But the bigger issue came next.

The researchers discovered an API endpoint that retrieved job applications using sequential identifiers. By changing the identifier in a request, they could access other applicants' records.

The potential exposure involved more than 64 million application records.

The vulnerability wasn't an advanced exploit. It wasn't a sophisticated zero-day attack.

It was a combination of weak test-account security and an API that failed to enforce proper record-level authorization.

The account was disabled after responsible disclosure.

For developers, however, the most interesting part isn't the password.

It's the API design.

2. Understanding IDOR: The vulnerability hiding in ordinary API code

This class of vulnerability is commonly known as Insecure Direct Object Reference (IDOR), now generally discussed under Broken Access Control.

Consider this Express.js endpoint:

router.get('/api/applications/:id', requireLogin, async (req, res) => {
  const application = await Applications.findById(req.params.id);

  if (!application) {
    return res.status(404).json({
      message: 'Application not found'
    });
  }

  return res.json(application);
});

At first glance, nothing looks particularly suspicious.

  • Authentication middleware exists.
  • The application ID is validated by the database lookup.
  • Missing records return a 404.
  • The endpoint behaves as expected.

But what happens when User A requests an application belonging to User B?

The endpoint doesn't care.

It checks whether the user is authenticated, but never checks whether that user is authorized to access the requested application.

That's the vulnerability.

The fix: Enforce ownership at the data-access layer

A safer implementation scopes the database query to the authenticated user's organization:

router.get('/api/applications/:id', requireLogin, async (req, res) => {
  const application = await Applications.findOne({
    _id: req.params.id,
    organizationId: req.user.organizationId
  });

  if (!application) {
    return res.status(404).json({
      message: 'Application not found'
    });
  }

  return res.json(application);
});

Now the query checks two conditions:

  1. Does the requested application exist?
  2. Does it belong to the authenticated user's organization?

Both conditions must be true.

This is a relatively small implementation change, but it closes a significant authorization gap.

The important lesson: Never rely on authentication middleware alone to protect sensitive resources.

3. Three security mistakes that deserve more attention during code review

The McHire incident isn't an isolated example. Several security failures in 2025 highlighted different ways small implementation mistakes can become major incidents.

A. Missing object-level authorization

The classic IDOR problem.

Look for code patterns such as:

Model.findById(req.params.id);

This isn't automatically vulnerable. However, when the record contains sensitive information, reviewers should ask:

  • Is ownership checked?
  • Is organization membership validated?
  • Can users access records belonging to other tenants?
  • Are permissions enforced consistently across read, update, and delete operations?

Multi-tenant applications deserve particular attention here.

B. Insecure storage permissions

In July 2025, the dating-safety app Tea experienced a major data exposure involving publicly accessible cloud storage.

Reports described approximately 72,000 exposed images, including user-submitted selfies and identity documents.

This highlights another important point: application security doesn't end at the API layer.

Reviewers should also consider:

  • Cloud storage bucket permissions.
  • Public access settings.
  • File upload and retrieval policies.
  • Access to identity documents and private attachments.
  • Whether signed URLs expire appropriately.

Some security failures happen outside the source code entirely, which is why code review must complement infrastructure security checks.

C. Trusting a single security boundary

In March 2025, a vulnerability affecting Next.js middleware, tracked as CVE-2025-29927, allowed middleware-based authorization checks to be bypassed under affected configurations.

The takeaway is straightforward:

Security-critical authorization should not depend entirely on a single middleware layer.

Sensitive backend operations must independently enforce the permissions they require.

Middleware is useful for routing and early access checks, but it shouldn't be the only barrier protecting sensitive data.

4. Why traditional code review misses these problems

Here's an uncomfortable reality.

A security vulnerability doesn't always look like bad code.

Sometimes it looks like perfectly reasonable code with one missing condition.

Imagine reviewing 15 pull requests in a day.

You're checking:

  • Whether the implementation matches the requirements.
  • Whether existing functionality still works.
  • Whether tests pass.
  • Whether the code follows team conventions.
  • Whether the changes introduce performance issues.

Now imagine spotting a missing authorization condition in a 200-line pull request.

It's easy to miss.

This becomes even more challenging as teams increasingly use AI coding assistants to generate and modify code.

Code generation is getting faster. But reviewing every generated change with the same level of attention is difficult.

The solution isn't to slow down development. It's to improve the quality of the review process.

5. Where AI-powered code review fits

AI code review can act as an additional security layer between implementation and deployment.

For example, a security-aware reviewer could inspect:

const application = await Applications.findById(req.params.id);

And raise a contextual warning:

Potential security issue: Missing object-level authorization

This query retrieves an application using its identifier without verifying whether the authenticated user has permission to access it.

An attacker who can manipulate the identifier may be able to access another user's application.

Suggested fix:

const application = await Applications.findOne({
  _id: req.params.id,
  organizationId: req.user.organizationId
});

The value isn't simply identifying a suspicious line.

It's explaining:

  • What's wrong.
  • Why it matters.
  • How it could be exploited.
  • How the developer can fix it.

That's the difference between a useful security review and another generic warning.

What AI code review can catch

A well-designed tool can help identify:

  • Missing authorization checks.
  • Potential IDOR vulnerabilities.
  • Hardcoded credentials.
  • SQL injection risks.
  • Insecure input handling.
  • Dangerous file upload logic.
  • Known vulnerable dependencies.
  • Insecure configurations committed to source control.

What it cannot guarantee

AI review isn't a replacement for comprehensive security testing.

It may not detect:

  • Cloud configuration changes made outside the repository.
  • Newly discovered malicious packages without available intelligence.
  • Complex business-logic vulnerabilities.
  • Runtime-specific security issues.
  • Every possible authorization bypass.

Human review, automated security testing, dependency scanning, and infrastructure monitoring still matter.

6. A practical security checklist for every pull request

Before approving an API-related pull request, ask these questions:

  • [ ] Does every sensitive endpoint enforce authentication?
  • [ ] Does it verify resource-level authorization?
  • [ ] Are database queries scoped to the correct user or organization?
  • [ ] Can changing an ID expose another user's data?
  • [ ] Are permissions checked on updates and deletions too?
  • [ ] Are sensitive files stored with private access?
  • [ ] Are credentials excluded from source control?
  • [ ] Are dependencies checked for known vulnerabilities?
  • [ ] Are negative authorization tests included?

One particularly useful test is to authenticate as User A and attempt to access a resource owned by User B.

If the request succeeds, you have a problem worth investigating.

7. Why we built Codzee

The McHire incident reinforces something we've been thinking about while building Codzee.

Many serious security vulnerabilities aren't hidden behind complicated algorithms. They're hiding in ordinary code that nobody questioned during review.

Codzee is designed to review pull requests, identify meaningful bugs and security risks, and provide actionable suggestions directly on the relevant lines of code.

The goal is simple:

  • Catch problems before they reach production.
  • Explain security issues in developer-friendly language.
  • Suggest practical fixes.
  • Reduce unnecessary review noise.
  • Help teams maintain code quality without slowing development.

AI shouldn't replace the engineer approving a pull request.

It should help that engineer notice the things they might otherwise miss.

Final thoughts

The McHire incident wasn't just a reminder to use stronger passwords.

It was a reminder that working code isn't necessarily secure code.

An endpoint can authenticate users correctly and still expose their data. A test suite can pass while a critical authorization check is missing. A pull request can look perfectly reasonable and still introduce a serious vulnerability.

The next time you review an API endpoint, don't just ask:

"Does this code work?"

Ask:

"Should this user be allowed to access this particular record?"

That one question can make a significant difference.

What security issue have you caught during code review that could easily have made it into production?

I'd love to hear your experience.

References:

  • Ian Carroll and Sam Curry – McHire security research
  • Simon Willison – Tea app security incident coverage
  • NVD – CVE-2025-29927
  • OWASP Top 10:2025 – Broken Access Control
  • The Register – September 2025 npm supply-chain compromise

Disclosure: Codzee is our product, built around the idea of making code review more effective and security-conscious.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.