Skip to main content
Authorization is the process of determining whether an authenticated user has permission to access a resource or perform an action. Authorization vulnerabilities arise when these permission checks are missing, incomplete, or can be bypassed.These vulnerabilities can allow attackers to access unauthorized data, perform privileged operations, or completely take over accounts and systems. Proper authorization is a critical component of a secure application’s defense-in-depth strategy.
Missing function level authorization occurs when an application fails to check if the authenticated user has the necessary permissions to perform a specific function.To implement proper function level authorization:
  • Apply authorization checks to all sensitive functions
  • Use role-based access control (RBAC) or attribute-based access control (ABAC)
  • Implement middleware for common authorization patterns
  • Apply the principle of least privilege
  • Log authorization decisions for sensitive operations
Insecure Direct Object References (IDOR) occur when an application exposes references to internal implementation objects, allowing attackers to manipulate these references to access unauthorized data.To prevent IDOR vulnerabilities:
  • Implement proper access control checks for each object access
  • Use indirect references that are mapped to actual database IDs
  • Validate that the current user has permission to access the requested object
  • Implement proper error handling that doesn’t reveal sensitive information
  • Use database queries that include user permissions in the selection criteria
Broken Object Level Authorization occurs when an application does not properly verify that a user has permission to access or modify a specific object.To implement proper object level authorization:
  • Verify ownership or permission for every object access
  • Implement a consistent authorization model across all objects
  • Use database queries that include user permissions
  • Consider using an authorization framework
  • Test authorization logic thoroughly with different user roles
Privilege escalation occurs when a user can gain access to resources or functionality that should be protected from them, either by elevating their own privileges or accessing another user’s resources.To prevent privilege escalation:
  • Implement strict role checks for sensitive operations
  • Prevent users from modifying their own roles or permissions
  • Validate that users can only access or modify their own data unless explicitly authorized
  • Implement proper access control for administrative functions
  • Log and monitor privilege changes
Missing authorization headers in API requests can lead to unauthorized access if the server doesn’t properly enforce authentication requirements.To implement proper authorization headers:
  • Always include authorization tokens in API requests
  • Implement consistent token validation on the server
  • Use secure methods for storing and transmitting tokens
  • Implement token expiration and refresh mechanisms
  • Consider using standardized authentication schemes like OAuth 2.0 or JWT
Improper access control occurs when an application does not correctly restrict access to resources based on the user’s identity and permissions.To implement proper access control:
  • Verify user permissions for every protected resource
  • Implement role-based or attribute-based access control
  • Apply the principle of least privilege
  • Use declarative security when possible
  • Centralize access control logic
  • Regularly audit access control implementations
Not verifying JWT signatures allows attackers to forge tokens and gain unauthorized access to protected resources.To implement proper JWT handling:
  • Always verify JWT signatures using the appropriate algorithm and key
  • Validate all JWT claims (expiration, issuer, audience, etc.)
  • Use strong, properly secured signing keys
  • Implement token expiration and refresh mechanisms
  • Consider using a JWT library that handles security best practices
Relying solely on client-side authorization is dangerous because client-side code can be modified or bypassed by attackers.To implement proper authorization:
  • Always enforce authorization on the server side
  • Treat client-side authorization as a UI convenience only
  • Implement consistent authorization checks across all API endpoints
  • Validate all incoming requests regardless of the client
  • Test API endpoints directly to ensure proper authorization
Insufficient authorization granularity occurs when an application uses overly broad permissions that don’t properly restrict access to specific resources or actions.To implement fine-grained authorization:
  • Define specific permissions for different resources and actions
  • Implement role-based access control with detailed permission sets
  • Consider attribute-based access control for complex authorization requirements
  • Apply data filtering based on user permissions
  • Regularly review and refine authorization rules
Hardcoded roles or permissions make it difficult to manage access control and can lead to authorization bugs when roles change.To avoid hardcoded roles:
  • Use a configurable permission system
  • Implement declarative security with annotations or configuration
  • Store permissions in a database or configuration file
  • Use role hierarchies or permission inheritance when appropriate
  • Implement a centralized authorization service
Missing re-authentication for sensitive operations can lead to account takeover if a user’s session is compromised.To implement proper re-authentication:
  • Require password verification for sensitive operations
  • Implement step-up authentication for high-risk actions
  • Consider using multi-factor authentication for critical operations
  • Implement proper session management
  • Log all sensitive operations
Insecure authorization decisions occur when an application bases access control on untrusted input or client-controlled data.To implement secure authorization decisions:
  • Base authorization decisions only on server-verified data
  • Never trust client-supplied role or permission information
  • Implement proper session management
  • Use secure, tamper-proof tokens for authorization
  • Validate all inputs used in authorization decisions
Lack of context-aware authorization occurs when an application doesn’t consider relevant contextual factors when making authorization decisions.To implement context-aware authorization:
  • Consider factors like time, location, device, and behavior patterns
  • Implement risk-based authentication for sensitive operations
  • Apply different authorization rules based on the context
  • Use anomaly detection for suspicious activities
  • Implement step-up authentication when context changes
Failing to validate authorization on each request can lead to unauthorized access if a user’s permissions change after their token is issued.To implement proper authorization validation:
  • Validate permissions on every request
  • Consider using short-lived tokens
  • Implement a token revocation mechanism
  • Check current permissions from the database when needed
  • Use a centralized authorization service