Logo
-

Byte Open Security

(ByteOS Network)

Log In

Sign Up

ByteOS

Security
Vulnerability Details
Registries
Custom Views
Weaknesses
Attack Patterns
Filters & Tools
CWE-566:Authorization Bypass Through User-Controlled SQL Primary Key
Weakness ID:566
Version:v4.17
Weakness Name:Authorization Bypass Through User-Controlled SQL Primary Key
Vulnerability Mapping:Allowed
Abstraction:Variant
Structure:Simple
Status:Incomplete
Likelihood of Exploit:
DetailsContent HistoryObserved CVE ExamplesReports
▼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.

▼Extended Description

When a user can set a primary key to any value, then the user can modify the key to point to unauthorized records.

Database access control errors occur when:

  • Data enters a program from an untrusted source.
  • The data is used to specify the value of a primary key in a SQL query.
  • The untrusted source does not have the permissions to be able to access all rows in the associated table.
▼Alternate Terms
▼Relationships
Relevant to the view"Research Concepts - (1000)"
NatureMappingTypeIDName
ChildOfAllowedB639Authorization Bypass Through User-Controlled Key
Nature: ChildOf
Mapping: Allowed
Type: Base
ID: 639
Name: Authorization Bypass Through User-Controlled Key
▼Memberships
NatureMappingTypeIDName
MemberOfProhibitedC994SFP Secondary Cluster: Tainted Input to Variable
MemberOfProhibitedC1011Authorize Actors
MemberOfProhibitedC1345OWASP Top Ten 2021 Category A01:2021 - Broken Access Control
MemberOfProhibitedC1396Comprehensive Categorization: Access Control
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 994
Name: SFP Secondary Cluster: Tainted Input to Variable
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1011
Name: Authorize Actors
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1345
Name: OWASP Top Ten 2021 Category A01:2021 - Broken Access Control
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1396
Name: Comprehensive Categorization: Access Control
▼Tags
NatureMappingTypeIDName
MemberOfProhibitedBSBOSS-240Weaknesses in Software Written in SQL
MemberOfProhibitedBSBOSS-272Weaknesses in Database Server
MemberOfProhibitedBSBOSS-316Bypass Protection Mechanism (impact)
MemberOfProhibitedBSBOSS-318Modify Application Data (impact)
MemberOfProhibitedBSBOSS-328Read Application Data (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-240
Name: Weaknesses in Software Written in SQL
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-272
Name: Weaknesses in Database Server
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-316
Name: Bypass Protection Mechanism (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-318
Name: Modify Application Data (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-328
Name: Read Application Data (impact)
▼Relevant To View
Relevant to the view"Architectural Concepts - (1008)"
NatureMappingTypeIDName
MemberOfProhibitedC1011Authorize Actors
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 1011
Name: Authorize Actors
Relevant to the view"OWASP Top Ten (2021) - (1344)"
NatureMappingTypeIDName
MemberOfProhibitedC1345OWASP Top Ten 2021 Category A01:2021 - Broken Access Control
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 1345
Name: OWASP Top Ten 2021 Category A01:2021 - Broken Access Control
Relevant to the view"Software Fault Pattern (SFP) Clusters - (888)"
NatureMappingTypeIDName
MemberOfProhibitedC994SFP Secondary Cluster: Tainted Input to Variable
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 994
Name: SFP Secondary Cluster: Tainted Input to Variable
▼Background Detail

▼Common Consequences
ScopeLikelihoodImpactNote
ConfidentialityIntegrityAccess ControlN/ARead Application DataModify Application DataBypass Protection Mechanism
N/A
Scope: Confidentiality, Integrity, Access Control
Likelihood: N/A
Impact: Read Application Data, Modify Application Data, Bypass Protection Mechanism
Note:
N/A
▼Potential Mitigations
Phase:Implementation
Mitigation ID:
Strategy:
Effectiveness:
Description:

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.

Note:


Phase:Implementation
Mitigation ID:
Strategy:
Effectiveness:
Description:

Use a parameterized query AND make sure that the accepted values conform to the business rules. Construct your SQL statement accordingly.

Note:

▼Modes Of Introduction
Phase: Architecture and Design
Note:

COMMISSION: This weakness refers to an incorrect design related to an architectural security tactic.

Phase: Implementation
Note:

N/A

▼Applicable Platforms
Languages
Class: SQL(Often Prevalence)
Technology
Class: Database Server(Often Prevalence)
▼Demonstrative Examples
Example 1

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.

Language: ( code)
N/A

Language: C#(Bad code)
... 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(); ...

Language: ( code)
N/A

The problem is that the developer has not considered all of the possible values of id. Although the interface generates a list of invoice identifiers that belong to the current user, an attacker can bypass this interface to request any desired invoice. Because the code in this example does not check to ensure that the user has permission to access the requested invoice, it will display any invoice, even if it does not belong to the current user.

▼Observed Examples
ReferenceDescription
▼Affected Resources
    ▼Functional Areas
      ▼Weakness Ordinalities
      OrdinalityDescription
      ▼Detection Methods
      Automated Static Analysis
      Detection Method ID:DM-14
      Description:

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

      Effectiveness:High
      Note:

      N/A

      ▼Vulnerability Mapping Notes
      Usage:Allowed
      Reason:Acceptable-Use
      Rationale:

      This CWE entry is at the Variant level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.

      Comments:

      Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.

      Suggestions:
      ▼Notes
      ▼Taxonomy Mappings
      Taxonomy NameEntry IDFitEntry Name
      Software Fault PatternsSFP25N/ATainted input to variable
      Taxonomy Name: Software Fault Patterns
      Entry ID: SFP25
      Fit: N/A
      Entry Name: Tainted input to variable
      ▼Related Attack Patterns
      IDName
      ▼References
      Details not found