All posts by rocco

CWE-688 – Function Call With Incorrect Variable or Reference as Argument

Read Time:40 Second

Description

The software calls a function, procedure, or routine, but the caller specifies the wrong variable or reference as one of the arguments, which may lead to undefined behavior and resultant weaknesses.

Modes of Introduction:

– Implementation

 

 

Related Weaknesses

CWE-628

 

Consequences

Other: Quality Degradation

 

Potential Mitigations

Phase: Testing

Description: 

Because this function call often produces incorrect behavior it will usually be detected during testing or normal operation of the software. During testing exercise all possible control paths will typically expose this weakness except in rare cases when the incorrect function call accidentally produces the correct results or if the provided argument type is very similar to the expected argument type.

CVE References

  • CVE-2005-2548
    • Kernel code specifies the wrong variable in first argument, leading to resultant NULL pointer dereference.

CWE-689 – Permission Race Condition During Resource Copy

Read Time:43 Second

Description

The product, while copying or cloning a resource, does not set the resource’s permissions or access control until the copy is complete, leaving the resource exposed to other spheres while the copy is taking place.

Modes of Introduction:

– Implementation

 

 

Related Weaknesses

CWE-362
CWE-362
CWE-732

 

Consequences

Confidentiality, Integrity: Read Application Data, Modify Application Data

 

Potential Mitigations

CVE References

  • CVE-2002-0760
    • Archive extractor decompresses files with world-readable permissions, then later sets permissions to what the archive specified.
  • CVE-2005-2174
    • Product inserts a new object into database before setting the object’s permissions, introducing a race condition.
  • CVE-2006-5214
    • Error file has weak permissions before a chmod is performed.
  • CVE-2003-0265
    • Database product creates files world-writable before initializing the setuid bits, leading to modification of executables.

CWE-69 – Improper Handling of Windows ::DATA Alternate Data Stream

Read Time:1 Minute, 12 Second

Description

The software does not properly prevent access to, or detect usage of, alternate data streams (ADS).

An attacker can use an ADS to hide information about a file (e.g. size, the name of the process) from a system or file browser tools such as Windows Explorer and ‘dir’ at the command line utility. Alternately, the attacker might be able to bypass intended access restrictions for the associated data fork.

Alternate data streams (ADS) were first implemented in the Windows NT operating system to provide compatibility between NTFS and the Macintosh Hierarchical File System (HFS). In HFS, data and resource forks are used to store information about a file. The data fork provides information about the contents of the file while the resource fork stores metadata such as file type.

Modes of Introduction:

– Architecture and Design

 

 

Related Weaknesses

CWE-66

 

Consequences

Access Control, Non-Repudiation, Other: Bypass Protection Mechanism, Hide Activities, Other

 

Potential Mitigations

Phase: Testing

Description: 

Software tools are capable of finding ADSs on your system.

Phase: Implementation

Description: 

Ensure that the source code correctly parses the filename to read or write to the correct stream.

CVE References

  • CVE-1999-0278
    • In IIS, remote attackers can obtain source code for ASP files by appending “::$DATA” to the URL.
  • CVE-2000-0927
    • Product does not properly record file sizes if they are stored in alternative data streams, which allows users to bypass quota restrictions.

CWE-647 – Use of Non-Canonical URL Paths for Authorization Decisions

Read Time:48 Second

Description

The software defines policy namespaces and makes authorization decisions based on the assumption that a URL is canonical. This can allow a non-canonical URL to bypass the authorization.

Modes of Introduction:

– Architecture and Design

 

Likelihood of Exploit: High

 

Related Weaknesses

CWE-863

 

Consequences

Access Control: Bypass Protection Mechanism

An attacker may be able to bypass the authorization mechanism to gain access to the otherwise-protected URL.

Confidentiality: Read Files or Directories

If a non-canonical URL is used, the server may choose to return the contents of the file, instead of pre-processing the file (e.g. as a program).

 

Potential Mitigations

Phase: Architecture and Design

Description: 

Make access control policy based on path information in canonical form. Use very restrictive regular expressions to validate that the path is in the expected form.

Phase: Architecture and Design

Description: 

Reject all alternate path encodings that are not in the expected canonical form.

CVE References

CWE-648 – Incorrect Use of Privileged APIs

Read Time:1 Minute, 43 Second

Description

The application does not conform to the API requirements for a function call that requires extra privileges. This could allow attackers to gain privileges by causing the function to be called incorrectly.

Modes of Introduction:

– Architecture and Design

 

Likelihood of Exploit: Low

 

Related Weaknesses

CWE-269

 

Consequences

Access Control: Gain Privileges or Assume Identity

An attacker may be able to elevate privileges.

Confidentiality: Read Application Data

An attacker may be able to obtain sensitive information.

Integrity, Confidentiality, Availability: Execute Unauthorized Code or Commands

An attacker may be able to execute code.

 

Potential Mitigations

Phase: Implementation

Description: 

Before calling privileged APIs, always ensure that the assumptions made by the privileged code hold true prior to making the call.

Phase: Architecture and Design

Description: 

Know architecture and implementation weaknesses of the privileged APIs and make sure to account for these weaknesses before calling the privileged APIs to ensure that they can be called safely.

Phase: Implementation

Description: 

If privileged APIs make certain assumptions about data, context or state validity that are passed by the caller, the calling code must ensure that these assumptions have been validated prior to making the call.

Phase: Implementation

Description: 

If privileged APIs do not shed their privilege prior to returning to the calling code, then calling code needs to shed these privileges immediately and safely right after the call to the privileged APIs. In particular, the calling code needs to ensure that a privileged thread of execution will never be returned to the user or made available to user-controlled processes.

Phase: Implementation

Description: 

Only call privileged APIs from safe, consistent and expected state.

Phase: Implementation

Description: 

Ensure that a failure or an error will not leave a system in a state where privileges are not properly shed and privilege escalation is possible (i.e. fail securely with regards to handling of privileges).

CVE References

  • CVE-2003-0645
    • A Unix utility that displays online help files, if installed setuid, could allow a local attacker to gain privileges when a particular file-opening function is called.

CWE-649 – Reliance on Obfuscation or Encryption of Security-Relevant Inputs without Integrity Checking

Read Time:3 Minute, 20 Second

Description

The software uses obfuscation or encryption of inputs that should not be mutable by an external actor, but the software does not use integrity checks to detect if those inputs have been modified.

When an application relies on obfuscation or incorrectly applied / weak encryption to protect client-controllable tokens or parameters, that may have an effect on the user state, system state, or some decision made on the server. Without protecting the tokens/parameters for integrity, the application is vulnerable to an attack where an adversary traverses the space of possible values of the said token/parameter in order to attempt to gain an advantage. The goal of the attacker is to find another admissible value that will somehow elevate their privileges in the system, disclose information or change the behavior of the system in some way beneficial to the attacker. If the application does not protect these critical tokens/parameters for integrity, it will not be able to determine that these values have been tampered with. Measures that are used to protect data for confidentiality should not be relied upon to provide the integrity service.

Modes of Introduction:

– Architecture and Design

 

Likelihood of Exploit: High

 

Related Weaknesses

CWE-345

 

Consequences

Integrity: Unexpected State

The inputs could be modified without detection, causing the software to have unexpected system state or make incorrect security decisions.

 

Potential Mitigations

Phase: Architecture and Design

Description: 

Protect important client controllable tokens/parameters for integrity using PKI methods (i.e. digital signatures) or other means, and checks for integrity on the server side.

Phase: Architecture and Design

Description: 

Repeated requests from a particular user that include invalid values of tokens/parameters (those that should not be changed manually by users) should result in the user account lockout.

Phase: Architecture and Design

Description: 

Client side tokens/parameters should not be such that it would be easy/predictable to guess another valid state.

Phase: Architecture and Design

Description: 

Obfuscation should not be relied upon. If encryption is used, it needs to be properly applied (i.e. proven algorithm and implementation, use padding, use random initialization vector, user proper encryption mode). Even with proper encryption where the ciphertext does not leak information about the plaintext or reveal its structure, compromising integrity is possible (although less likely) without the provision of the integrity service.

CVE References

  • CVE-2005-0039
    • An IPSec configuration does not perform integrity checking of the IPSec packet as the result of either not configuring ESP properly to support the integrity service or using AH improperly. In either case, the security gateway receiving the IPSec packet would not validate the integrity of the packet to ensure that it was not changed. Thus if the packets were intercepted the attacker could undetectably change some of the bits in the packets. The meaningful bit flipping was possible due to the known weaknesses in the CBC encryption mode. Since the attacker knew the structure of the packet, they were able (in one variation of the attack) to use bit flipping to change the destination IP of the packet to the destination machine controlled by the attacker. And so the destination security gateway would decrypt the packet and then forward the plaintext to the machine controlled by the attacker. The attacker could then read the original message. For instance if VPN was used with the vulnerable IPSec configuration the attacker could read the victim’s e-mail. This vulnerability demonstrates the need to enforce the integrity service properly when critical data could be modified by an attacker. This problem might have also been mitigated by using an encryption mode that is not susceptible to bit flipping attacks, but the preferred mechanism to address this problem still remains message verification for integrity. While this attack focuses on the network layer and requires an entity that controls part of the communication path such as a router, the situation is not much different at the software level, where an attacker can modify tokens/parameters used by the application.

CWE-65 – Windows Hard Link

Read Time:1 Minute, 2 Second

Description

The software, when opening a file or directory, does not sufficiently handle when the name is associated with a hard link to a target that is outside of the intended control sphere. This could allow an attacker to cause the software to operate on unauthorized files.

Failure for a system to check for hard links can result in vulnerability to different types of attacks. For example, an attacker can escalate their privileges if a file used by a privileged program is replaced with a hard link to a sensitive file (e.g. AUTOEXEC.BAT). When the process opens the file, the attacker can assume the privileges of that process, or prevent the program from accurately processing data.

Modes of Introduction:

– Implementation

 

 

Related Weaknesses

CWE-59

 

Consequences

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

 

Potential Mitigations

Phase: Architecture and Design

Description: 

CVE References

  • CVE-2002-0725
    • File system allows local attackers to hide file usage activities via a hard link to the target file, which causes the link to be recorded in the audit trail instead of the target file.
  • CVE-2003-0844
    • Web server plugin allows local users to overwrite arbitrary files via a symlink attack on predictable temporary filenames.

CWE-650 – Trusting HTTP Permission Methods on the Server Side

Read Time:1 Minute, 36 Second

Description

The server contains a protection mechanism that assumes that any URI that is accessed using HTTP GET will not cause a state change to the associated resource. This might allow attackers to bypass intended access restrictions and conduct resource modification and deletion attacks, since some applications allow GET to modify state.

The HTTP GET method and some other methods are designed to retrieve resources and not to alter the state of the application or resources on the server side. Furthermore, the HTTP specification requires that GET requests (and other requests) should not have side effects. Believing that it will be enough to prevent unintended resource alterations, an application may disallow the HTTP requests to perform DELETE, PUT and POST operations on the resource representation. However, there is nothing in the HTTP protocol itself that actually prevents the HTTP GET method from performing more than just query of the data. Developers can easily code programs that accept a HTTP GET request that do in fact create, update or delete data on the server. For instance, it is a common practice with REST based Web Services to have HTTP GET requests modifying resources on the server side. However, whenever that happens, the access control needs to be properly enforced in the application. No assumptions should be made that only HTTP DELETE, PUT, POST, and other methods have the power to alter the representation of the resource being accessed in the request.

Modes of Introduction:

– Architecture and Design

 

Likelihood of Exploit: High

 

Related Weaknesses

CWE-436

 

Consequences

Access Control: Gain Privileges or Assume Identity

An attacker could escalate privileges.

Integrity: Modify Application Data

An attacker could modify resources.

Confidentiality: Read Application Data

An attacker could obtain sensitive information.

 

Potential Mitigations

Phase: System Configuration

Description: 

Configure ACLs on the server side to ensure that proper level of access control is defined for each accessible resource representation.

CVE References

CWE-651 – Exposure of WSDL File Containing Sensitive Information

Read Time:55 Second

Description

The Web services architecture may require exposing a Web Service Definition Language (WSDL) file that contains information on the publicly accessible services and how callers of these services should interact with them (e.g. what parameters they expect and what types they return).

Modes of Introduction:

– Architecture and Design

 

 

Related Weaknesses

CWE-538

 

Consequences

Confidentiality: Read Application Data

The attacker may find sensitive information located in the WSDL file.

 

Potential Mitigations

Phase: Architecture and Design

Description: 

Limit access to the WSDL file as much as possible. If services are provided only to a limited number of entities, it may be better to provide WSDL privately to each of these entities than to publish WSDL publicly.

Phase: Architecture and Design

Description: 

Make sure that WSDL does not describe methods that should not be publicly accessible. Make sure to protect service methods that should not be publicly accessible with access controls.

Phase: Architecture and Design

Description: 

Do not use method names in WSDL that might help an adversary guess names of private methods/resources used by the service.

CVE References

CWE-652 – Improper Neutralization of Data within XQuery Expressions (‘XQuery Injection’)

Read Time:51 Second

Description

The software uses external input to dynamically construct an XQuery expression used to retrieve data from an XML database, but it does not neutralize or incorrectly neutralizes that input. This allows an attacker to control the structure of the query.

The net effect is that the attacker will have control over the information selected from the XML database and may use that ability to control application flow, modify logic, retrieve unauthorized data, or bypass important checks (e.g. authentication).

Modes of Introduction:

– Implementation

 

Likelihood of Exploit: High

 

Related Weaknesses

CWE-943
CWE-91

 

Consequences

Confidentiality: Read Application Data

An attacker might be able to read sensitive information from the XML database.

 

Potential Mitigations

Phase: Implementation

Description: 

Use parameterized queries. This will help ensure separation between data plane and control plane.

Phase: Implementation

Description: 

Properly validate user input. Reject data where appropriate, filter where appropriate and escape where appropriate. Make sure input that will be used in XQL queries is safe in that context.

CVE References