Incorrect Authorization

Incorrect Authorization

CWE-863 · High severity · Updated November 6, 2026

What it is

CWE-863 exists when an application performs an authorization check that is present but logically wrong: it verifies the wrong principal, checks the wrong resource, uses OR where AND is required, or relies on a token that the requester controls. The result is broken access control with a check that looked correct in review.

Why it matters

Incorrect authorization is consistently in the OWASP Top 10 (A01:2025 Broken Access Control). It is harder to detect than missing authorization (CWE-862) because the code does check something. Common manifestations include Insecure Direct Object References (IDOR), tenant-id confusion in multi-tenant systems, and role hierarchies where one role's permissions accidentally include another's. Many major breaches trace back to flawed authorization logic rather than missing authentication.

Common patterns

  • Fetching a resource by a request-supplied ID without checking that the authenticated user owns it (IDOR).
  • Authorization check on req.user but the operation acts on req.params.userId.
  • Role check that uses OR when AND is required (any of these roles vs all of these roles).
  • Tenant scoping via a query parameter rather than via a property of the authenticated identity.
  • GraphQL resolvers that authorize at the query level but not at the field or row level.
  • Cached authorization decisions that do not invalidate when permissions change.

Languages affected

JavaScript, TypeScript, Python, Ruby, Java, Go, PHP, C#

What Deva detects

Deva flags ORM lookups such as findByPk and findUnique that take a request parameter directly, and includes a Spring @PreAuthorize rule. Authorization logic is hard to judge statically, so most incorrect checks still need review by hand.

Example

Vulnerable

app.get('/api/orders/:id', requireAuth, async (req, res) => {
  // The check is present but wrong: any customer passes it, for any order.
  if (!['customer', 'admin'].includes(req.user.role)) {
    return res.status(403).json({ error: 'Forbidden' })
  }
  const order = await db.orders.findById(req.params.id)
  if (!order) return res.status(404).json({ error: 'Not found' })
  res.json(order)
})

Fixed

app.get('/api/orders/:id', requireAuth, async (req, res) => {
  const scope = req.user.role === 'admin' ? {} : { userId: req.user.id }
  const order = await db.orders.findOne({
    where: { id: req.params.id, ...scope },
  })
  if (!order) return res.status(404).json({ error: 'Not found' })
  res.json(order)
})

The vulnerable version authenticates the user and runs an authorization check, but the check asks the wrong question: it confirms the caller's role, not their right to this order. Any customer can request /api/orders/12345 regardless of who owns it. The fix scopes the query by the authenticated user's id. For systems where multiple users can legitimately view the same resource (admin, customer-service), encode the rule in the where clause, not at the application layer above the query. Returning the same 404 for not-found and not-authorized prevents enumeration.

Where this fits in OWASP Top 10

Compliance framework references

These references explain how the weakness relates to control topics. They do not mean Deva offers evaluation for every framework listed. CMMC evaluation and SPRS scoring are currently unavailable. See the FAQ for offered frameworks and preview status. Deva provides code-level evidence for your assessment, without certifying compliance.

FrameworkControls
OWASP Top 10:2025A01:2025 Broken Access Control
NIST 800-53 Rev 5AC-3 Access Enforcement, AC-6 Least Privilege
PCI-DSS v4.0.17.2 Access appropriately defined and assigned
HIPAA Security Rule164.312(a)(1) Access Control
CMMC L2AC.L2-3.1.1 Access control policy, AC.L2-3.1.2 Limit transactions

Related CWEs

  • CWE-862 · Missing authorization (sibling: check absent vs check wrong).
  • CWE-639 · IDOR specifically (subset of incorrect authorization).
  • CWE-284 · Improper access control (parent category).
  • CWE-287 · Improper authentication (often confused but distinct).

Related glossary terms