Logo
-

Byte Open Security

(ByteOS Network)

Log In

Sign Up

ByteOS

Security
Vulnerability Details
Registries
Custom Views
Weaknesses
Attack Patterns
Filters & Tools
CWE-412:Unrestricted Externally Accessible Lock
Weakness ID:412
Version:v4.17
Weakness Name:Unrestricted Externally Accessible Lock
Vulnerability Mapping:Allowed
Abstraction:Base
Structure:Simple
Status:Incomplete
Likelihood of Exploit:
DetailsContent HistoryObserved CVE ExamplesReports
▼Description

The product properly checks for the existence of a lock, but the lock can be externally controlled or influenced by an actor that is outside of the intended sphere of control.

▼Extended Description

This prevents the product from acting on associated resources or performing other behaviors that are controlled by the presence of the lock. Relevant locks might include an exclusive lock or mutex, or modifying a shared resource that is treated as a lock. If the lock can be held for an indefinite period of time, then the denial of service could be permanent.

▼Alternate Terms
▼Relationships
Relevant to the view"Research Concepts - (1000)"
NatureMappingTypeIDName
▼Memberships
NatureMappingTypeIDName
▼Tags
NatureMappingTypeIDName
▼Relevant To View
▼Background Detail

▼Common Consequences
ScopeLikelihoodImpactNote
AvailabilityN/ADoS: Resource Consumption (Other)

When an attacker can control a lock, the program may wait indefinitely until the attacker releases the lock, causing a denial of service to other users of the program. This is especially problematic if there is a blocking operation on the lock.

Scope: Availability
Likelihood: N/A
Impact: DoS: Resource Consumption (Other)
Note:

When an attacker can control a lock, the program may wait indefinitely until the attacker releases the lock, causing a denial of service to other users of the program. This is especially problematic if there is a blocking operation on the lock.

▼Potential Mitigations
Phase:Architecture and Design, Implementation
Mitigation ID:
Strategy:
Effectiveness:
Description:

Use any access control that is offered by the functionality that is offering the lock.

Note:


Phase:Architecture and Design, Implementation
Mitigation ID:
Strategy:
Effectiveness:
Description:

Use unpredictable names or identifiers for the locks. This might not always be possible or feasible.

Note:


Phase:Architecture and Design
Mitigation ID:
Strategy:
Effectiveness:
Description:

Consider modifying your code to use non-blocking synchronization methods.

Note:

▼Modes Of Introduction
Phase: Architecture and Design
Note:

N/A

Phase: Implementation
Note:

N/A

▼Applicable Platforms
Languages
Class: Not Language-Specific(Undetermined Prevalence)
▼Demonstrative Examples
Example 1

This code tries to obtain a lock for a file, then writes to it.

Language: ( code)
N/A

Language: PHP(Bad code)
function writeToLog($message){ $logfile = fopen("logFile.log", "a"); //attempt to get logfile lock* if (flock($logfile, LOCK_EX)) { fwrite($logfile,$message); // unlock logfile* flock($logfile, LOCK_UN);} else { print "Could not obtain lock on logFile.log, message not recorded\n"; } } fclose($logFile);

Language: ( code)
N/A

PHP by default will wait indefinitely until a file lock is released. If an attacker is able to obtain the file lock, this code will pause execution, possibly leading to denial of service for other users. Note that in this case, if an attacker can perform an flock() on the file, they may already have privileges to destroy the log file. However, this still impacts the execution of other programs that depend on flock().

▼Observed Examples
ReferenceDescription
CVE-2001-0682
Program can not execute when attacker obtains a mutex.
CVE-2002-1914
Program can not execute when attacker obtains a lock on a critical output file.
CVE-2002-1915
Program can not execute when attacker obtains a lock on a critical output file.
CVE-2002-0051
Critical file can be opened with exclusive read access by user, preventing application of security policy. Possibly related to improper permissions, large-window race condition.
CVE-2000-0338
Chain: predictable file names used for locking, allowing attacker to create the lock beforehand. Resultant from permissions and randomness.
CVE-2000-1198
Chain: Lock files with predictable names. Resultant from randomness.
CVE-2002-1869
Product does not check if it can write to a log file, allowing attackers to avoid logging by accessing the file using an exclusive lock. Overlaps unchecked error condition. This is not quite CWE-412, but close.
Reference: CVE-2001-0682
Description:
Program can not execute when attacker obtains a mutex.
Reference: CVE-2002-1914
Description:
Program can not execute when attacker obtains a lock on a critical output file.
Reference: CVE-2002-1915
Description:
Program can not execute when attacker obtains a lock on a critical output file.
Reference: CVE-2002-0051
Description:
Critical file can be opened with exclusive read access by user, preventing application of security policy. Possibly related to improper permissions, large-window race condition.
Reference: CVE-2000-0338
Description:
Chain: predictable file names used for locking, allowing attacker to create the lock beforehand. Resultant from permissions and randomness.
Reference: CVE-2000-1198
Description:
Chain: Lock files with predictable names. Resultant from randomness.
Reference: CVE-2002-1869
Description:
Product does not check if it can write to a log file, allowing attackers to avoid logging by accessing the file using an exclusive lock. Overlaps unchecked error condition. This is not quite CWE-412, but close.
▼Affected Resources
    ▼Functional Areas
      ▼Weakness Ordinalities
      OrdinalityDescription
      ▼Detection Methods
      White Box
      Detection Method ID:
      Description:

      Automated code analysis techniques might not be able to reliably detect this weakness, since the application's behavior and general security model dictate which resource locks are critical. Interpretation of the weakness might require knowledge of the environment, e.g. if the existence of a file is used as a lock, but the file is created in a world-writable directory.

      Effectiveness:
      Note:

      N/A

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

      This CWE entry is at the Base 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
      Relationship

      This overlaps Insufficient Resource Pool when the "pool" is of size 1. It can also be resultant from race conditions, although the timing window could be quite large in some cases.

      N/A

      ▼Taxonomy Mappings
      Taxonomy NameEntry IDFitEntry Name
      PLOVERN/AN/AUnrestricted Critical Resource Lock
      7 Pernicious KingdomsN/AN/ADeadlock
      OWASP Top Ten 2004A9CWE More SpecificDenial of Service
      The CERT Oracle Secure Coding Standard for Java (2011)LCK00-JN/AUse private final lock objects to synchronize classes that may interact with untrusted code
      The CERT Oracle Secure Coding Standard for Java (2011)LCK07-JN/AAvoid deadlock by requesting and releasing locks in the same order
      Software Fault PatternsSFP22N/AUnrestricted lock
      Taxonomy Name: PLOVER
      Entry ID: N/A
      Fit: N/A
      Entry Name: Unrestricted Critical Resource Lock
      Taxonomy Name: 7 Pernicious Kingdoms
      Entry ID: N/A
      Fit: N/A
      Entry Name: Deadlock
      Taxonomy Name: OWASP Top Ten 2004
      Entry ID: A9
      Fit: CWE More Specific
      Entry Name: Denial of Service
      Taxonomy Name: The CERT Oracle Secure Coding Standard for Java (2011)
      Entry ID: LCK00-J
      Fit: N/A
      Entry Name: Use private final lock objects to synchronize classes that may interact with untrusted code
      Taxonomy Name: The CERT Oracle Secure Coding Standard for Java (2011)
      Entry ID: LCK07-J
      Fit: N/A
      Entry Name: Avoid deadlock by requesting and releasing locks in the same order
      Taxonomy Name: Software Fault Patterns
      Entry ID: SFP22
      Fit: N/A
      Entry Name: Unrestricted lock
      ▼Related Attack Patterns
      IDName
      CAPEC-25
      Forced Deadlock
      ID: CAPEC-25
      Name: Forced Deadlock
      ▼References
      Details not found