CWEweakness
CWE-566 Authorization Bypass Through User-Controlled SQL Primary Key
- Abstraction
- Variant
- Structure
- Simple
- Status
- Incomplete
- Languages
- SQL
- CWE version
- 5.0
Description
The product uses a database table that includes records that should not be accessible to an actor, but it executes a SQL statement with a primary key that can be controlled by that actor.
Common consequences
• Confidentiality, Integrity, Access Control: Read Application Data, Modify Application Data, Bypass Protection Mechanism — When a user can set a primary key to any value, then the user can modify the key to point to unauthorized records.
Potential mitigations
• [Implementation] Modify the query to include a clause that
performs an authorization check, or otherwise ensure
that the check is performed before the query is
executed.
• [Implementation] Assume all input is malicious. Use a standard input validation mechanism to validate all input for length, type, syntax, and business rules before accepting the data. Use an "accept known good" validation strategy.
• [Implementation] Use a parameterized query AND make sure that the accepted values conform to the business rules. Construct your SQL statement accordingly.
Detection methods
• Automated Static Analysis: 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.)
Related
Child of · CWE (1)
- CWE-639 Authorization Bypass Through User-Controlled Key weakness
Referenced by CVE · weakness (10)
- CVE-2026-85749 MailWatch for MailScanner is a web-based front-end to MailScanner. vulnerability
- CVE-2026-84650 In Jenkins 2.579 and earlier, LTS 2.568.2 and earlier, transient fields cannot be excluded from deserialization, allowing attackers able to… vulnerability
- CVE-2026-21886 OpenCTI is an open source platform for managing cyber threat intelligence knowledge and observables. vulnerability
- CVE-2025-9953 Authorization Bypass Through User-Controlled SQL Primary Key vulnerability in DATABASE Software Training Consulting Ltd. vulnerability
- CVE-2025-61781 OpenCTI is an open source platform for managing cyber threat intelligence knowledge and observables. vulnerability
- CVE-2025-56556 An issue was discovered in Subrion CMS 4.2.1, allowing authenticated adminitrators or moderators with access to the built-in Run SQL Query… vulnerability
- CVE-2025-30368 Zulip is an open-source team collaboration tool. vulnerability
- CVE-2025-30369 Zulip is an open-source team collaboration tool. vulnerability
- CVE-2024-22261 SQL-Injection in Harbor allows priviledge users to leak the task IDs vulnerability
- CVE-2014-0808 Authorization bypass through user-controlled key issue exists in EC-CUBE 2.11.0 through 2.12.2 and EC-Orange systems deployed before June… vulnerability