All posts by rocco

CWE-824 – Access of Uninitialized Pointer

Read Time:1 Minute, 54 Second

Description

The program accesses or uses a pointer that has not been initialized.

Modes of Introduction:

Likelihood of Exploit:

 

Related Weaknesses

CWE-119
CWE-119
CWE-119
CWE-119
CWE-125
CWE-787

 

Consequences

Confidentiality: Read Memory

If the uninitialized pointer is used in a read operation, an attacker might be able to read sensitive portions of memory.

Availability: DoS: Crash, Exit, or Restart

If the uninitialized pointer references a memory location that is not accessible to the program, or points to a location that is “malformed” (such as NULL) or larger than expected by a read or write operation, then a crash may occur.

Integrity, Confidentiality, Availability: Execute Unauthorized Code or Commands

If the uninitialized pointer is used in a function call, or points to unexpected data in a write operation, then code execution may be possible.

 

Potential Mitigations

CVE References

 

  • CVE-2010-0211
    • chain: unchecked return value (CWE-252) leads to free of invalid, uninitialized pointer (CWE-824).
  • CVE-2009-2768
    • Pointer in structure is not initialized, leading to NULL pointer dereference (CWE-476) and system crash.
  • CVE-2009-1415
    • Improper handling of invalid signatures leads to free of invalid pointer.
  • CVE-2009-0846
    • Invalid encoding triggers free of uninitialized pointer.
  • CVE-2009-0040
    • Crafted PNG image leads to free of uninitialized pointer.
  • CVE-2008-2934
    • Crafted GIF image leads to free of uninitialized pointer.
  • CVE-2007-4682
    • Access of uninitialized pointer might lead to code execution.
  • CVE-2007-4639
    • Step-based manipulation: invocation of debugging function before the primary initialization function leads to access of an uninitialized pointer and code execution.
  • CVE-2007-4000
    • Unchecked return values can lead to a write to an uninitialized pointer.
  • CVE-2007-2442
    • zero-length input leads to free of uninitialized pointer.
  • CVE-2007-1213
    • Crafted font leads to uninitialized function pointer.
  • CVE-2006-6143
    • Uninitialized function pointer in freed memory is invoked
  • CVE-2006-4175
    • LDAP server mishandles malformed BER queries, leading to free of uninitialized memory
  • CVE-2006-0054
    • Firewall can crash with certain ICMP packets that trigger access of an uninitialized pointer.
  • CVE-2003-1201
    • LDAP server does not initialize members of structs, which leads to free of uninitialized pointer if an LDAP request fails.

CWE-825 – Expired Pointer Dereference

Read Time:1 Minute, 50 Second

Description

The program dereferences a pointer that contains a location for memory that was previously valid, but is no longer valid.

When a program releases memory, but it maintains a pointer to that memory, then the memory might be re-allocated at a later time. If the original pointer is accessed to read or write data, then this could cause the program to read or modify data that is in use by a different function or process. Depending on how the newly-allocated memory is used, this could lead to a denial of service, information exposure, or code execution.

Modes of Introduction:

Likelihood of Exploit:

 

Related Weaknesses

CWE-119
CWE-119
CWE-119
CWE-672
CWE-125
CWE-787

 

Consequences

Confidentiality: Read Memory

If the expired pointer is used in a read operation, an attacker might be able to control data read in by the application.

Availability: DoS: Crash, Exit, or Restart

If the expired pointer references a memory location that is not accessible to the program, or points to a location that is “malformed” (such as NULL) or larger than expected by a read or write operation, then a crash may occur.

Integrity, Confidentiality, Availability: Execute Unauthorized Code or Commands

If the expired pointer is used in a function call, or points to unexpected data in a write operation, then code execution may be possible.

 

Potential Mitigations

Phase: Architecture and Design

Effectiveness:

Description: 

Choose a language that provides automatic memory management.

Phase: Implementation

Effectiveness:

Description: 

When freeing pointers, be sure to set them to NULL once they are freed. However, the utilization of multiple or complex data structures may lower the usefulness of this strategy.

CVE References

 

  • CVE-2008-5013
    • access of expired memory address leads to arbitrary code execution
  • CVE-2010-3257
    • stale pointer issue leads to denial of service and possibly other consequences
  • CVE-2008-0062
    • Chain: a message having an unknown message type may cause a reference to uninitialized memory resulting in a null pointer dereference (CWE-476) or dangling pointer (CWE-825), possibly crashing the system or causing heap corruption.
  • CVE-2007-1211
    • read of value at an offset into a structure after the offset is no longer valid

CWE-826 – Premature Release of Resource During Expected Lifetime

Read Time:1 Minute, 9 Second

Description

The program releases a resource that is still intended to be used by the program itself or another actor.

Modes of Introduction:

Likelihood of Exploit:

 

Related Weaknesses

CWE-666
CWE-672

 

Consequences

Confidentiality: Read Application Data, Read Memory

If the released resource is subsequently reused or reallocated, then a read operation on the original resource might access sensitive data that is associated with a different user or entity.

Availability: DoS: Crash, Exit, or Restart

When the resource is released, the software might modify some of its structure, or close associated channels (such as a file descriptor). When the software later accesses the resource as if it is valid, the resource might not be in an expected state, leading to resultant errors that may lead to a crash.

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

When the resource is released, the software might modify some of its structure. This might affect program logic in the sections of code that still assume the resource is active. If the released resource is related to memory and is used in a function call, or points to unexpected data in a write operation, then code execution may be possible upon subsequent accesses.

 

Potential Mitigations

CVE References

 

  • CVE-2009-3547
    • chain: race condition might allow resource to be released before operating on it, leading to NULL dereference

CWE-827 – Improper Control of Document Type Definition

Read Time:1 Minute, 3 Second

Description

The software does not restrict a reference to a Document Type Definition (DTD) to the intended control sphere. This might allow attackers to reference arbitrary DTDs, possibly causing the software to expose files, consume excessive system resources, or execute arbitrary http requests on behalf of the attacker.

Modes of Introduction:

– Implementation

Likelihood of Exploit:

 

Related Weaknesses

CWE-706
CWE-829
CWE-776

 

Consequences

Confidentiality: Read Files or Directories

If the attacker is able to include a crafted DTD and a default entity resolver is enabled, the attacker may be able to access arbitrary files on the system.

Availability: DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory)

The DTD may cause the parser to consume excessive CPU cycles or memory using techniques such as nested or recursive entity references (CWE-776).

Integrity, Confidentiality, Availability, Access Control: Execute Unauthorized Code or Commands, Gain Privileges or Assume Identity

The DTD may include arbitrary HTTP requests that the server may execute. This could lead to other attacks leveraging the server’s trust relationship with other entities.

 

Potential Mitigations

CVE References

 

  • CVE-2010-2076
    • Product does not properly reject DTDs in SOAP messages, which allows remote attackers to read arbitrary files, send HTTP requests to intranet servers, or cause a denial of service.

CWE-828 – Signal Handler with Functionality that is not Asynchronous-Safe

Read Time:1 Minute, 31 Second

Description

The software defines a signal handler that contains code sequences that are not asynchronous-safe, i.e., the functionality is not reentrant, or it can be interrupted.

Modes of Introduction:

Likelihood of Exploit:

 

Related Weaknesses

CWE-364

 

Consequences

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

The most common consequence will be a corruption of the state of the software, possibly leading to a crash or exit. However, if the signal handler is operating on state variables for security relevant libraries or protection mechanisms, the consequences can be far more severe, including protection mechanism bypass, privilege escalation, or information exposure.

 

Potential Mitigations

Phase: Implementation, Architecture and Design

Effectiveness: High

Description: 

Phase: Implementation

Effectiveness:

Description: 

Where non-reentrant functionality must be leveraged within a signal handler, be sure to block or mask signals appropriately. This includes blocking other signals within the signal handler itself that may also leverage the functionality. It also includes blocking all signals reliant upon the functionality when it is being accessed or modified by the normal behaviors of the software.

CVE References

 

  • CVE-2008-4109
    • Signal handler uses functions that ultimately call the unsafe syslog/malloc/s*printf, leading to denial of service via multiple login attempts
  • CVE-2006-5051
    • Chain: Signal handler contains too much functionality (CWE-828), introducing a race condition (CWE-362) that leads to a double free (CWE-415).
  • CVE-2001-1349
    • unsafe calls to library functions from signal handler
  • CVE-2004-0794
    • SIGURG can be used to remotely interrupt signal handler; other variants exist.
  • CVE-2004-2259
    • SIGCHLD signal to FTP server can cause crash under heavy load while executing non-reentrant functions like malloc/free.
  • CVE-2002-1563
    • SIGCHLD not blocked in a daemon loop while counter is modified, causing counter to get out of sync.

CWE-829 – Inclusion of Functionality from Untrusted Control Sphere

Read Time:3 Minute, 39 Second

Description

The software imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere.

Modes of Introduction:

– Implementation

Likelihood of Exploit:

 

Related Weaknesses

CWE-669
CWE-669

 

Consequences

Confidentiality, Integrity, Availability: Execute Unauthorized Code or Commands

An attacker could insert malicious functionality into the program by causing the program to download code that the attacker has placed into the untrusted control sphere, such as a malicious web site.

 

Potential Mitigations

Phase: Architecture and Design

Effectiveness:

Description: 

Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.

Phase: Architecture and Design

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: 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: Architecture and Design, Operation

Effectiveness:

Description: 

Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.

Phase: Implementation

Effectiveness: High

Description: 

Phase: Architecture and Design, Operation

Effectiveness:

Description: 

Phase: Architecture and Design, Implementation

Effectiveness:

Description: 

Phase: Operation

Effectiveness: Moderate

Description: 

Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth.

An application firewall might not cover all possible input vectors. In addition, attack techniques might be available to bypass the protection mechanism, such as using malformed inputs that can still be processed by the component that receives those inputs. Depending on functionality, an application firewall might inadvertently reject or modify legitimate requests. Finally, some manual effort may be required for customization.

CVE References

 

  • CVE-2010-2076
    • Product does not properly reject DTDs in SOAP messages, which allows remote attackers to read arbitrary files, send HTTP requests to intranet servers, or cause a denial of service.
  • CVE-2004-0285
    • Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
  • CVE-2004-0030
    • Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
  • CVE-2004-0068
    • Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
  • CVE-2005-2157
    • Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
  • CVE-2005-2162
    • Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
  • CVE-2005-2198
    • Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
  • CVE-2004-0128
    • Modification of assumed-immutable variable in configuration script leads to file inclusion.
  • CVE-2004-0127
    • Directory traversal vulnerability in PHP include statement.
  • CVE-2005-1971
    • Directory traversal vulnerability in PHP include statement.
  • CVE-2005-3335
    • PHP file inclusion issue, both remote and local; local include uses “..” and “%00” characters as a manipulation, but many remote file inclusion issues probably have this vector.

CWE-83 – Improper Neutralization of Script in Attributes in a Web Page

Read Time:2 Minute, 2 Second

Description

The software does not neutralize or incorrectly neutralizes “javascript:” or other URIs from dangerous attributes within tags, such as onmouseover, onload, onerror, or style.

Modes of Introduction:

– Implementation

Likelihood of Exploit:

 

Related Weaknesses

CWE-79

 

Consequences

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

 

Potential Mitigations

Phase: Implementation

Effectiveness:

Description: 

Carefully check each input parameter against a rigorous positive specification (allowlist) defining the specific characters and format allowed. All input should be neutralized, not just parameters that the user is supposed to specify, but all data in the request, including tag attributes, hidden fields, cookies, headers, the URL itself, and so forth. A common mistake that leads to continuing XSS vulnerabilities is to validate only fields that are expected to be redisplayed by the site. We often encounter data from the request that is reflected by the application server or the application that the development team did not anticipate. Also, a field that is not currently reflected may be used by a future developer. Therefore, validating ALL parts of the HTTP request is recommended.

Phase: Implementation

Effectiveness:

Description: 

Phase: Implementation

Effectiveness:

Description: 

With Struts, write all data from form beans with the bean’s filter attribute set to true.

Phase: Implementation

Effectiveness: Defense in Depth

Description: 

To help mitigate XSS attacks against the user’s session cookie, set the session cookie to be HttpOnly. In browsers that support the HttpOnly feature (such as more recent versions of Internet Explorer and Firefox), this attribute can prevent the user’s session cookie from being accessible to malicious client-side scripts that use document.cookie. This is not a complete solution, since HttpOnly is not supported by all browsers. More importantly, XMLHTTPRequest and other powerful browser technologies provide read access to HTTP headers, including the Set-Cookie header in which the HttpOnly flag is set.

CVE References

 

  • CVE-2001-0520
    • Bypass filtering of SCRIPT tags using onload in BODY, href in A, BUTTON, INPUT, and others.
  • CVE-2002-1495
    • XSS in web-based email product via onmouseover event.
  • CVE-2004-1935
    • Onload, onmouseover, and other events in an e-mail attachment.
  • CVE-2005-0945
    • Onmouseover and onload events in img, link, and mail tags.
  • CVE-2003-1136
    • Javascript in onmouseover attribute in e-mail address or URL.

CWE-830 – Inclusion of Web Functionality from an Untrusted Source

Read Time:20 Second

Description

The software includes web functionality (such as a web widget) from another domain, which causes it to operate within the domain of the software, potentially granting total access and control of the software to the untrusted source.

Modes of Introduction:

– Implementation

Likelihood of Exploit:

 

Related Weaknesses

CWE-829

 

Consequences

Confidentiality, Integrity, Availability: Execute Unauthorized Code or Commands

 

Potential Mitigations

CVE References

 

CWE-831 – Signal Handler Function Associated with Multiple Signals

Read Time:36 Second

Description

The software defines a function that is used as a handler for more than one signal.

Modes of Introduction:

Likelihood of Exploit:

 

Related Weaknesses

CWE-364

 

Consequences

Availability, Integrity, Confidentiality, Access Control, Other: DoS: Crash, Exit, or Restart, Execute Unauthorized Code or Commands, Read Application Data, Gain Privileges or Assume Identity, Bypass Protection Mechanism, Varies by Context

The most common consequence will be a corruption of the state of the software, possibly leading to a crash or exit. However, if the signal handler is operating on state variables for security relevant libraries or protection mechanisms, the consequences can be far more severe, including protection mechanism bypass, privilege escalation, or information exposure.

 

Potential Mitigations

CVE References

 

CWE-832 – Unlock of a Resource that is not Locked

Read Time:1 Minute, 1 Second

Description

The software attempts to unlock a resource that is not locked.

Depending on the locking functionality, an unlock of a non-locked resource might cause memory corruption or other modification to the resource (or its associated metadata that is used for tracking locks).

Modes of Introduction:

Likelihood of Exploit:

 

Related Weaknesses

CWE-667

 

Consequences

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

Depending on the locking being used, an unlock operation might not have any adverse effects. When effects exist, the most common consequence will be a corruption of the state of the software, possibly leading to a crash or exit; depending on the implementation of the unlocking, memory corruption or code execution could occur.

 

Potential Mitigations

CVE References

 

  • CVE-2010-4210
    • function in OS kernel unlocks a mutex that was not previously locked, causing a panic or overwrite of arbitrary memory.
  • 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.
  • CVE-2009-1243
    • OS kernel performs an unlock in some incorrect circumstances, leading to panic.