CWE-754 – Improper Check for Unusual or Exceptional Conditions

Read Time:2 Minute, 27 Second

Description

The software does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the software.

Many functions will return some value about the success of their actions. This will alert the program whether or not to handle any errors caused by that function.

Modes of Introduction:

– Implementation

Likelihood of Exploit: Medium

 

Related Weaknesses

CWE-703

 

Consequences

Integrity, Availability: DoS: Crash, Exit, or Restart, Unexpected State

The data which were produced as a result of a function call could be in a bad state upon return. If the return value is not checked, then this bad data may be used in operations, possibly leading to a crash or other unintended behaviors.

 

Potential Mitigations

Phase: Requirements

Effectiveness:

Description: 

Phase: Implementation

Effectiveness: High

Description: 

Check the results of all functions that return a value and verify that the value is expected.

Checking the return value of the function will typically be sufficient, however beware of race conditions (CWE-362) in a concurrent environment.

Phase: Implementation

Effectiveness: High

Description: 

If using exception handling, catch and throw specific exceptions instead of overly-general exceptions (CWE-396, CWE-397). Catch and handle exceptions as locally as possible so that exceptions do not propagate too far up the call stack (CWE-705). Avoid unchecked or uncaught exceptions where feasible (CWE-248).

Using specific exceptions, and ensuring that exceptions are checked, helps programmers to anticipate and appropriately handle many unusual events that could occur.

Phase: Implementation

Effectiveness:

Description: 

Phase: Implementation

Effectiveness:

Description: 

Performing extensive input validation does not help with handling unusual conditions, but it will minimize their occurrences and will make it more difficult for attackers to trigger them.

Phase: Architecture and Design, Implementation

Effectiveness:

Description: 

If the program must fail, ensure that it fails gracefully (fails closed). There may be a temptation to simply let the program fail poorly in cases such as low memory conditions, but an attacker may be able to assert control before the software has fully exited. Alternately, an uncontrolled failure could cause cascading problems with other downstream components; for example, the program could send a signal to a downstream process so the process immediately knows that a problem has occurred and has a better chance of recovery.

Phase: Architecture and Design

Effectiveness:

Description: 

Use system limits, which should help to prevent resource exhaustion. However, the software should still handle low resource conditions since they may still occur.

CVE References

 

  • CVE-2007-3798
    • Unchecked return value leads to resultant integer overflow and code execution.
  • CVE-2006-4447
    • Program does not check return value when invoking functions to drop privileges, which could leave users with higher privileges than expected by forcing those functions to fail.
  • CVE-2006-2916
    • Program does not check return value when invoking functions to drop privileges, which could leave users with higher privileges than expected by forcing those functions to fail.

CWE-75 – Failure to Sanitize Special Elements into a Different Plane (Special Element Injection)

Read Time:27 Second

Description

The software does not adequately filter user-controlled input for special elements with control implications.

Modes of Introduction:

– Architecture and Design

Likelihood of Exploit:

 

Related Weaknesses

CWE-74

 

Consequences

Integrity, Confidentiality, Availability: Modify Application Data, Execute Unauthorized Code or Commands

 

Potential Mitigations

Phase: Requirements

Effectiveness:

Description: 

Programming languages and supporting technologies might be chosen which are not subject to these issues.

Phase: Implementation

Effectiveness:

Description: 

Utilize an appropriate mix of allowlist and denylist parsing to filter special element syntax from all input.

CVE References

 

CWE-749 – Exposed Dangerous Method or Function

Read Time:52 Second

Description

The software provides an Applications Programming Interface (API) or similar interface for interaction with external actors, but the interface includes a dangerous method or function that is not properly restricted.

Modes of Introduction:

– Architecture and Design

Likelihood of Exploit: Low

 

Related Weaknesses

CWE-664
CWE-691

 

Consequences

Integrity, Confidentiality, Availability, Access Control, Other: Gain Privileges or Assume Identity, Read Application Data, Modify Application Data, Execute Unauthorized Code or Commands, Other

Exposing critical functionality essentially provides an attacker with the privilege level of the exposed functionality. This could result in the modification or exposure of sensitive data or possibly even execution of arbitrary code.

 

Potential Mitigations

Phase: Architecture and Design

Effectiveness:

Description: 

If you must expose a method, make sure to perform input validation on all arguments, limit access to authorized parties, and protect against all possible vulnerabilities.

Phase: Architecture and Design, Implementation

Effectiveness:

Description: 

CVE References

 

  • CVE-2007-1112
    • security tool ActiveX control allows download or upload of files

CWE-74 – Improper Neutralization of Special Elements in Output Used by a Downstream Component (‘Injection’)

Read Time:2 Minute, 2 Second

Description

The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.

Software has certain assumptions about what constitutes data and control respectively. It is the lack of verification of these assumptions for user-controlled input that leads to injection problems. Injection problems encompass a wide variety of issues — all mitigated in very different ways and usually attempted in order to alter the control flow of the process. For this reason, the most effective way to discuss these weaknesses is to note the distinct features which classify them as injection weaknesses. The most important issue to note is that all injection problems share one thing in common — i.e., they allow for the injection of control plane data into the user-controlled data plane. This means that the execution of the process may be altered by sending code in through legitimate data channels, using no other mechanism. While buffer overflows, and many other flaws, involve the use of some further issue to gain execution, injection problems need only for the data to be parsed. The most classic instantiations of this category of weakness are SQL injection and format string vulnerabilities.

Modes of Introduction:

– Architecture and Design

Likelihood of Exploit: High

 

Related Weaknesses

CWE-707

 

Consequences

Confidentiality: Read Application Data

Many injection attacks involve the disclosure of important information — in terms of both data sensitivity and usefulness in further exploitation.

Access Control: Bypass Protection Mechanism

In some cases, injectable code controls authentication; this may lead to a remote vulnerability.

Other: Alter Execution Logic

Injection attacks are characterized by the ability to significantly change the flow of a given process, and in some cases, to the execution of arbitrary code.

Integrity, Other: Other

Data injection attacks lead to loss of data integrity in nearly all cases as the control-plane data injected is always incidental to data recall or writing.

Non-Repudiation: Hide Activities

Often the actions performed by injected control code are unlogged.

 

Potential Mitigations

Phase: Requirements

Effectiveness:

Description: 

Programming languages and supporting technologies might be chosen which are not subject to these issues.

Phase: Implementation

Effectiveness:

Description: 

Utilize an appropriate mix of allowlist and denylist parsing to filter control-plane syntax from all input.

CVE References

 

CWE-733 – Compiler Optimization Removal or Modification of Security-critical Code

Read Time:30 Second

Description

The developer builds a security-critical protection mechanism into the software, but the compiler optimizes the program such that the mechanism is removed or modified.

Modes of Introduction:

Likelihood of Exploit:

 

Related Weaknesses

CWE-1038

 

Consequences

Access Control, Other: Bypass Protection Mechanism, Other

 

Potential Mitigations

CVE References

 

  • CVE-2008-1685
    • C compiler optimization, as allowed by specifications, removes code that is used to perform checks to detect integer overflows.
  • CVE-2019-1010006
    • Chain: compiler optimization (CWE-733) removes or modifies code used to detect integer overflow (CWE-190), allowing out-of-bounds write (CWE-787).

CWE-732 – Incorrect Permission Assignment for Critical Resource

Read Time:4 Minute, 42 Second

Description

The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.

When a resource is given a permissions setting that provides access to a wider range of actors than required, it could lead to the exposure of sensitive information, or the modification of that resource by unintended parties. This is especially dangerous when the resource is related to program configuration, execution or sensitive user data.

Modes of Introduction:

– Architecture and Design

Likelihood of Exploit: High

 

Related Weaknesses

CWE-285
CWE-668

 

Consequences

Confidentiality: Read Application Data, Read Files or Directories

An attacker may be able to read sensitive information from the associated resource, such as credentials or configuration information stored in a file.

Access Control: Gain Privileges or Assume Identity

An attacker may be able to modify critical properties of the associated resource to gain privileges, such as replacing a world-writable executable with a Trojan horse.

Integrity, Other: Modify Application Data, Other

An attacker may be able to destroy or corrupt critical data in the associated resource, such as deletion of records from a database.

 

Potential Mitigations

Phase: Implementation

Effectiveness:

Description: 

When using a critical resource such as a configuration file, check to see if the resource has insecure permissions (such as being modifiable by any regular user) [REF-62], and generate an error or even exit the software if there is a possibility that the resource could have been modified by an unauthorized party.

Phase: Architecture and Design

Effectiveness: Moderate

Description: 

Divide the software into anonymous, normal, privileged, and administrative areas. Reduce the attack surface by carefully defining distinct user groups, privileges, and/or roles. Map these against data, functionality, and the related resources. Then set the permissions accordingly. This will allow you to maintain more fine-grained control over your resources. [REF-207]

This can be an effective strategy. However, in practice, it may be difficult or time consuming to define these areas when there are many different resources or user types, or if the applications features change rapidly.

Phase: Architecture and Design, Operation

Effectiveness: Limited

Description: 

The effectiveness of this mitigation depends on the prevention capabilities of the specific sandbox or jail being used and might only help to reduce the scope of an attack, such as restricting the attacker to certain system calls or limiting the portion of the file system that can be accessed.

Phase: Implementation, Installation

Effectiveness: High

Description: 

During program startup, explicitly set the default permissions or umask to the most restrictive setting possible. Also set the appropriate permissions during program installation. This will prevent you from inheriting insecure permissions from any user who installs or runs the program.

Phase: System Configuration

Effectiveness: High

Description: 

For all configuration files, executables, and libraries, make sure that they are only readable and writable by the software’s administrator.

Phase: Documentation

Effectiveness:

Description: 

Do not suggest insecure configuration changes in documentation, especially if those configurations can extend to resources and other programs that are outside the scope of the application.

Phase: Installation

Effectiveness:

Description: 

Do not assume that a system administrator will manually change the configuration to the settings that are recommended in the software’s manual.

Phase: Operation, System Configuration

Effectiveness:

Description: 

Ensure that the software runs properly under the Federal Desktop Core Configuration (FDCC) [REF-199] or an equivalent hardening configuration guide, which many organizations use to limit the attack surface and potential risk of deployed software.

CVE References

 

  • CVE-2009-3482
    • Anti-virus product sets insecure “Everyone: Full Control” permissions for files under the “Program Files” folder, allowing attackers to replace executables with Trojan horses.
  • CVE-2009-3897
    • Product creates directories with 0777 permissions at installation, allowing users to gain privileges and access a socket used for authentication.
  • CVE-2009-3489
    • Photo editor installs a service with an insecure security descriptor, allowing users to stop or start the service, or execute commands as SYSTEM.
  • CVE-2009-3289
    • Library function copies a file to a new target and uses the source file’s permissions for the target, which is incorrect when the source file is a symbolic link, which typically has 0777 permissions.
  • CVE-2009-0115
    • Device driver uses world-writable permissions for a socket file, allowing attackers to inject arbitrary commands.
  • CVE-2009-1073
    • LDAP server stores a cleartext password in a world-readable file.
  • CVE-2009-0141
    • Terminal emulator creates TTY devices with world-writable permissions, allowing an attacker to write to the terminals of other users.
  • CVE-2008-0662
    • VPN product stores user credentials in a registry key with “Everyone: Full Control” permissions, allowing attackers to steal the credentials.
  • CVE-2008-0322
    • Driver installs its device interface with “Everyone: Write” permissions.
  • CVE-2009-3939
    • Driver installs a file with world-writable permissions.
  • CVE-2009-3611
    • Product changes permissions to 0777 before deleting a backup; the permissions stay insecure for subsequent backups.
  • CVE-2007-6033
    • Product creates a share with “Everyone: Full Control” permissions, allowing arbitrary program execution.
  • CVE-2007-5544
    • Product uses “Everyone: Full Control” permissions for memory-mapped files (shared memory) in inter-process communication, allowing attackers to tamper with a session.
  • CVE-2005-4868
    • Database product uses read/write permissions for everyone for its shared memory, allowing theft of credentials.
  • CVE-2004-1714
    • Security product uses “Everyone: Full Control” permissions for its configuration files.
  • CVE-2001-0006
    • “Everyone: Full Control” permissions assigned to a mutex allows users to disable network connectivity.
  • CVE-2002-0969
    • Chain: database product contains buffer overflow that is only reachable through a .ini configuration file – which has “Everyone: Full Control” permissions.

CWE-73 – External Control of File Name or Path

Read Time:3 Minute, 12 Second

Description

The software allows user input to control or influence paths or file names that are used in filesystem operations.

Modes of Introduction:

– Architecture and Design

Likelihood of Exploit: High

 

Related Weaknesses

CWE-642
CWE-610
CWE-20
CWE-22
CWE-41
CWE-98
CWE-434
CWE-59

 

Consequences

Integrity, Confidentiality: Read Files or Directories, Modify Files or Directories

The application can operate on unexpected files. Confidentiality is violated when the targeted filename is not directly readable by the attacker.

Integrity, Confidentiality, Availability: Modify Files or Directories, Execute Unauthorized Code or Commands

The application can operate on unexpected files. This may violate integrity if the filename is written to, or if the filename is for a program or other form of executable code.

Availability: DoS: Crash, Exit, or Restart, DoS: Resource Consumption (Other)

The application can operate on unexpected files. Availability can be violated if the attacker specifies an unexpected file that the application modifies. Availability can also be affected if the attacker specifies a filename for a large file, or points to a special device or a file that does not have the format that the application expects.

 

Potential Mitigations

Phase: Architecture and Design

Effectiveness:

Description: 

When the set of filenames is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames, and reject all other inputs. For example, ID 1 could map to “inbox.txt” and ID 2 could map to “profile.txt”. Features such as the ESAPI AccessReferenceMap provide this capability.

Phase: Architecture and Design, Operation

Effectiveness:

Description: 

Phase: Architecture and Design

Effectiveness:

Description: 

For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.

Phase: Implementation

Effectiveness: High

Description: 

Phase: Implementation

Effectiveness:

Description: 

Use a built-in path canonicalization function (such as realpath() in C) that produces the canonical version of the pathname, which effectively removes “..” sequences and symbolic links (CWE-23, CWE-59).

Phase: Installation, Operation

Effectiveness:

Description: 

Use OS-level permissions and run as a low-privileged user to limit the scope of any successful attack.

Phase: Operation, Implementation

Effectiveness:

Description: 

If you are using PHP, configure your application so that it does not use register_globals. During implementation, develop your application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.

Phase: Testing

Effectiveness:

Description: 

Use automated static analysis tools that target this type of weakness. Many modern techniques use data flow analysis to minimize the number of false positives. This is not a perfect solution, since 100% accuracy and coverage are not feasible.

Phase: Testing

Effectiveness:

Description: 

Use dynamic tools and techniques that interact with the software using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The software’s operation may slow down, but it should not become unstable, crash, or generate incorrect results.

Phase: Testing

Effectiveness:

Description: 

Use tools and techniques that require manual (human) analysis, such as penetration testing, threat modeling, and interactive tools that allow the tester to record and modify an active session. These may be more effective than strictly automated techniques. This is especially the case with weaknesses that are related to design and business rules.

CVE References

 

  • CVE-2008-5748
    • Chain: external control of values for user’s desired language and theme enables path traversal.
  • CVE-2008-5764
    • Chain: external control of user’s target language enables remote file inclusion.

CWE-72 – Improper Handling of Apple HFS+ Alternate Data Stream Path

Read Time:44 Second

Description

The software does not properly handle special paths that may identify the data or resource fork of a file on the HFS+ file system.

If the software chooses actions to take based on the file name, then if an attacker provides the data or resource fork, the software may take unexpected actions. Further, if the software intends to restrict access to a file, then an attacker might still be able to bypass intended access restrictions by requesting the data or resource fork for that file.

Modes of Introduction:

– Architecture and Design

Likelihood of Exploit:

 

Related Weaknesses

CWE-66

 

Consequences

Confidentiality, Integrity: Read Files or Directories, Modify Files or Directories

 

Potential Mitigations

CVE References

 

  • CVE-2004-1084
    • Server allows remote attackers to read files and resource fork content via HTTP requests to certain special file names related to multiple data streams in HFS+.

CWE-710 – Improper Adherence to Coding Standards

Read Time:21 Second

Description

The software does not follow certain coding rules for development, which can lead to resultant weaknesses or increase the severity of the associated vulnerabilities.

Modes of Introduction:

– Architecture and Design

Likelihood of Exploit:

 

Related Weaknesses

 

Consequences

Other: Other

 

Potential Mitigations

Phase: Implementation

Effectiveness:

Description: 

Document and closely follow coding standards.

Phase: Testing, Implementation

Effectiveness:

Description: 

Where possible, use automated tools to enforce the standards.

CVE References

 

News, Advisories and much more

Exit mobile version