CWE-639 Base Incomplete High likelihood

Authorization Bypass Through User-Controlled Key

This vulnerability occurs when an application's authorization system fails to verify that a user is allowed to access specific data before retrieving it, allowing an attacker to access another…

Definition

What is CWE-639?

This vulnerability occurs when an application's authorization system fails to verify that a user is allowed to access specific data before retrieving it, allowing an attacker to access another user's information by manipulating an identifier they control.
This flaw typically appears in features that fetch user-specific data, like account pages or search results. The application uses a key—such as a database ID, account number, or session token—to locate the correct record. However, if this key is taken directly from a user-controllable source like a URL parameter, form field, or cookie without verifying the requesting user's permissions, an attacker can simply change the key value to access data belonging to someone else. Attackers often exploit this by tampering with sequential, predictable, or easily-guessed identifiers. For instance, using a simple integer like `user_id=1001` and changing it to `1002` to access another account. The core failure is that the system performs a lookup based on the provided key but skips the critical authorization check to confirm the authenticated user actually owns or has the right to view that specific record.
Real-world impact

Real-world CVEs caused by CWE-639

  • An educational application does not appropriately restrict file IDs to a particular user. The attacker can brute-force guess IDs, indicating IDOR.

How attackers exploit it

Step-by-step attacker path

  1. 1

    Identify a code path that handles untrusted input without validation.

  2. 2

    Craft a payload that exercises the unsafe behavior — injection, traversal, overflow, or logic abuse.

  3. 3

    Deliver the payload through a normal request and observe the application's reaction.

  4. 4

    Iterate until the response leaks data, executes attacker code, or escalates privileges.

Vulnerable code example

Vulnerable C#

The following code uses a parameterized statement, which escapes metacharacters and prevents SQL injection vulnerabilities, to construct and execute a SQL query that searches for an invoice matching the specified identifier [1]. The identifier is selected from a list of all invoices associated with the current authenticated user.

Vulnerable C#
...
   conn = new SqlConnection(_ConnectionString);
   conn.Open();
   int16 id = System.Convert.ToInt16(invoiceID.Text);
   SqlCommand query = new SqlCommand( "SELECT * FROM invoices WHERE id = @id", conn);
   query.Parameters.AddWithValue("@id", id);
   SqlDataReader objReader = objCommand.ExecuteReader();
   ...
Secure code example

Secure pseudo

Secure pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Prevention checklist

How to prevent CWE-639

  • Architecture and Design For each and every data access, ensure that the user has sufficient privilege to access the record that is being requested.
  • Architecture and Design / Implementation Make 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.
  • Architecture and Design Use 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 signals

How to detect CWE-639

Automated Static Analysis High

Automated 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.)

Plexicus auto-fix

Plexicus auto-detects CWE-639 and opens a fix PR in under 60 seconds.

Codex Remedium scans every commit, identifies this exact weakness, and ships a reviewer-ready pull request with the patch. No tickets. No hand-offs.

Frequently asked questions

Frequently asked questions

What is CWE-639?

This vulnerability occurs when an application's authorization system fails to verify that a user is allowed to access specific data before retrieving it, allowing an attacker to access another user's information by manipulating an identifier they control.

How serious is CWE-639?

MITRE rates the likelihood of exploit as High — this weakness is actively exploited in the wild and should be prioritized for remediation.

What languages or platforms are affected by CWE-639?

MITRE has not specified affected platforms for this CWE — it can apply across most application stacks.

How can I prevent CWE-639?

For each and every data access, ensure that the user has sufficient privilege to access the record that is being requested. Make 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.

How does Plexicus detect and fix CWE-639?

Plexicus's SAST engine matches the data-flow signature for CWE-639 on every commit. When a match is found, our Codex Remedium agent opens a fix PR with the corrected code, tests, and a one-line summary for the reviewer.

Where can I learn more about CWE-639?

MITRE publishes the canonical definition at https://cwe.mitre.org/data/definitions/639.html. You can also reference OWASP and NIST documentation for adjacent guidance.

Ready when you are

Don't Let Security
Weigh You Down.

Stop choosing between AI velocity and security debt. Plexicus is the only platform that runs Vibe Coding Security and ASPM in parallel — one workflow, every codebase.