Category Archives: CWE

CWE-784 – Reliance on Cookies without Validation and Integrity Checking in a Security Decision

Read Time:1 Minute, 47 Second

Description

The application uses a protection mechanism that relies on the existence or values of a cookie, but it does not properly ensure that the cookie is valid for the associated user.

Attackers can easily modify cookies, within the browser or by implementing the client-side code outside of the browser. Attackers can bypass protection mechanisms such as authorization and authentication by modifying the cookie to contain an expected value.

Modes of Introduction:

– Architecture and Design

Likelihood of Exploit: High

 

Related Weaknesses

CWE-807
CWE-565

 

Consequences

Access Control: Bypass Protection Mechanism, Gain Privileges or Assume Identity

It is dangerous to use cookies to set a user’s privileges. The cookie can be manipulated to claim a high level of authorization, or to claim that successful authentication has occurred.

 

Potential Mitigations

Phase: Architecture and Design

Effectiveness:

Description: 

Avoid using cookie data for a security-related decision.

Phase: Implementation

Effectiveness:

Description: 

Perform thorough input validation (i.e.: server side validation) on the cookie data if you’re going to use it for a security related decision.

Phase: Architecture and Design

Effectiveness:

Description: 

Add integrity checks to detect tampering.

Phase: Architecture and Design

Effectiveness:

Description: 

Protect critical cookies from replay attacks, since cross-site scripting or other attacks may allow attackers to steal a strongly-encrypted cookie that also passes integrity checks. This mitigation applies to cookies that should only be valid during a single transaction or session. By enforcing timeouts, you may limit the scope of an attack. As part of your integrity check, use an unpredictable, server-side value that is not exposed to the client.

CVE References

 

  • CVE-2009-1549
    • Attacker can bypass authentication by setting a cookie to a specific value.
  • CVE-2009-1619
    • Attacker can bypass authentication and gain admin privileges by setting an “admin” cookie to 1.
  • CVE-2009-0864
    • Content management system allows admin privileges by setting a “login” cookie to “OK.”
  • CVE-2008-5784
    • e-dating application allows admin privileges by setting the admin cookie to 1.
  • CVE-2008-6291
    • Web-based email list manager allows attackers to gain admin privileges by setting a login cookie to “admin.”

CWE-785 – Use of Path Manipulation Function without Maximum-sized Buffer

Read Time:58 Second

Description

The software invokes a function for normalizing paths or file names, but it provides an output buffer that is smaller than the maximum possible size, such as PATH_MAX.

Passing an inadequately-sized output buffer to a path manipulation function can result in a buffer overflow. Such functions include realpath(), readlink(), PathAppend(), and others.

Windows provides a large number of utility functions that manipulate buffers containing filenames. In most cases, the result is returned in a buffer that is passed in as input. (Usually the filename is modified in place.) Most functions require the buffer to be at least MAX_PATH bytes in length, but you should check the documentation for each function individually. If the buffer is not large enough to store the result of the manipulation, a buffer overflow can occur.

Modes of Introduction:

– Implementation

Likelihood of Exploit:

 

Related Weaknesses

CWE-676
CWE-120
CWE-20

 

Consequences

Integrity, Confidentiality, Availability: Modify Memory, Execute Unauthorized Code or Commands, DoS: Crash, Exit, or Restart

 

Potential Mitigations

Phase: Implementation

Effectiveness:

Description: 

Always specify output buffers large enough to handle the maximum-size possible result from path manipulation functions.

CVE References

 

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-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-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-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-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-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-755 – Improper Handling of Exceptional Conditions

Read Time:31 Second

Description

The software does not handle or incorrectly handles an exceptional condition.

Modes of Introduction:

– Implementation

Likelihood of Exploit: Medium

 

Related Weaknesses

CWE-703

 

Consequences

Other: Other

 

Potential Mitigations

CVE References

 

  • CVE-2021-3011
    • virtual interrupt controller in a virtualization product allows crash of host by writing a certain invalid value to a register, which triggers a fatal error instead of returning an error code
  • CVE-2008-4302
    • Chain: OS kernel does not properly handle a failure of a function call (CWE-755), leading to an unlock of a resource that was not locked (CWE-832), with resultant crash.

CWE-756 – Missing Custom Error Page

Read Time:20 Second

Description

The software does not return custom error pages to the user, possibly exposing sensitive information.

Modes of Introduction:

Likelihood of Exploit:

 

Related Weaknesses

CWE-755
CWE-209

 

Consequences

Confidentiality: Read Application Data

Attackers can leverage the additional information provided by a default error page to mount attacks targeted on the framework, database, or other resources used by the application.

 

Potential Mitigations

CVE References