CWE-639: Authorization Bypass Through User-Controlled Key

What is CWE-639?

CWE-639 is Authorization Bypass Through User-Controlled Key. The flaw arises when the system fails to prevent a user from accessing another user's data or record by modifying the key value that identifies the requested data.

OWASP TOP 10:2025 RANK1 — A01:2025 — Broken Access Control
Related CVES (365 days)-
AbstractionBase
Likelihood of exploitHigh

No data

No vulnerability data for CWE-639

No data

No vulnerability data in CISA KEV for CWE-639

Official definition

ByMitre CWE

The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.

Retrieval of a user record occurs in the system based on some key value that is under user control. The key would typically identify a user-related record stored in the system and would be used to lookup that record for presentation to the user. It is likely that an attacker would have to be an authenticated user in the system. However, the authorization process would not properly check the data access operation to ensure that the authenticated user performing the operation has sufficient entitlements to perform the requested data access, hence bypassing any other authorization checks present in the system.

For example, attackers can look at places where user specific data is retrieved (e.g. search screens) and determine whether the key for the item being looked up is controllable externally. The key may be a hidden field in the HTML form field, might be passed as a URL parameter or as an unencrypted cookie variable, then in each of these cases it will be possible to tamper with the key value.

One manifestation of this weakness is when a system uses sequential or otherwise easily-guessable session IDs that would allow one user to easily switch to another user's session and read/modify their data.

Detailed description

The application retrieves a user-related record using a key that is under user control. Although the requester may be authenticated, the authorization process does not properly verify that this user is entitled to access the specific record, allowing the lookup operation to bypass other authorization checks.

The key may be exposed in an HTML form field, a URL parameter, or an unencrypted cookie variable, all of which can be tampered with. If the server accepts the changed value without binding the record to the current user, the attacker may access another user's data. A related manifestation uses sequential or otherwise predictable session identifiers, allowing one user to switch to another user's session and read or modify its data.

Characteristics

This weakness occurs when record retrieval relies on a user-controlled key and authorization does not confirm access to the particular record identified by that key. The key may be exposed through a hidden HTML form field, URL parameter, or unencrypted cookie, making alteration possible. Sequential or predictable session identifiers can produce a related result by enabling access to another user's session. The weakness is introduced during architecture and design, and its likelihood of exploitation is rated high.

Common consequences

Access-control checks for specific user data or functionality can be bypassed. A user may achieve horizontal privilege escalation by viewing or modifying another user's information. If the user-controlled key represents an administrator-status flag, the same weakness can also enable vertical privilege escalation and administrative access.

ImpactScopeExplanation
Bypass Protection MechanismAccess ControlAccess control checks for specific user data or functionality can be bypassed.
Gain Privileges or Assume IdentityAccess ControlHorizontal escalation of privilege is possible (one user can view/modify information of another user).
Gain Privileges or Assume IdentityAccess ControlVertical escalation of privilege is possible if the user-controlled key is actually a flag that indicates administrator status, allowing the attacker to gain administrative access.

Risk mitigations

Apply authorization checks to every data access operation, verifying that the requesting user has sufficient privilege for the specific record being requested. Do not allow users to externally control the key used to look up another user's record, or ensure that tampering is detected. Encryption can make other valid key values more difficult to guess, while associating a digital signature with the key allows the server to verify that it has not been modified.

  1. Architecture and DesignFor each and every data access, ensure that the user has sufficient privilege to access the record that is being requested.
  2. Architecture and Design, ImplementationMake sure that the key that is used in the lookup of a specific user's record is not controllable externally by the user or that any tampering can be detected.
  3. Architecture and DesignUse encryption in order to make it more difficult to guess other legitimate values of the key or associate a digital signature with the key so that the server can verify that there has been no tampering.

Detection methods

Automated static analysis, commonly called Static Application Security Testing (SAST), can find some instances by analyzing source or binary code without executing the application. It typically builds data-flow and control-flow models and searches for potentially vulnerable patterns connecting input sources with sinks where data interacts with external components or lower layers. This approach does not guarantee detection of every instance because it is limited to weaknesses whose relevant flows and patterns can be inferred from the analyzed code.

MethodApproachEffectiveness
Automated Static AnalysisAutomated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)High

Representative vulnerabilities

Representative examples, not an exhaustive list, include CVE-2021-36539. An educational application failed to restrict file IDs to a particular user, allowing an attacker to brute-force guess IDs and demonstrating an IDOR-style access control failure.

Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.