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

 

CWE-708 – Incorrect Ownership Assignment

Read Time:1 Minute, 2 Second

Description

The software assigns an owner to a resource, but the owner is outside of the intended control sphere.

This may allow the resource to be manipulated by actors outside of the intended control sphere.

Modes of Introduction:

– Architecture and Design

Likelihood of Exploit:

 

Related Weaknesses

CWE-282
CWE-345

 

Consequences

Confidentiality, Integrity: Read Application Data, Modify Application Data

An attacker could read and modify data for which they do not have permissions to access directly.

 

Potential Mitigations

Phase: Policy

Effectiveness:

Description: 

Periodically review the privileges and their owners.

Phase: Testing

Effectiveness:

Description: 

Use automated tools to check for privilege settings.

CVE References

 

  • CVE-2007-5101
    • File system sets wrong ownership and group when creating a new file.
  • CVE-2007-4238
    • OS installs program with bin owner/group, allowing modification.
  • CVE-2007-1716
    • Manager does not properly restore ownership of a reusable resource when a user logs out, allowing privilege escalation.
  • CVE-2005-3148
    • Backup software restores symbolic links with incorrect uid/gid.
  • CVE-2005-1064
    • Product changes the ownership of files that a symlink points to, instead of the symlink itself.
  • CVE-2011-1551
    • Component assigns ownership of sensitive directory tree to a user account, which can be leveraged to perform privileged operations.

CWE-707 – Improper Neutralization

Read Time:18 Second

Description

The product does not ensure or incorrectly ensures that structured messages or data are well-formed and that certain security properties are met before being read from an upstream component or sent to a downstream component.

Modes of Introduction:

– Architecture and Design

Likelihood of Exploit:

 

Related Weaknesses

 

Consequences

Other: Other

 

Potential Mitigations

CVE References

 

CWE-706 – Use of Incorrectly-Resolved Name or Reference

Read Time:18 Second

Description

The software uses a name or reference to access a resource, but the name/reference resolves to a resource that is outside of the intended control sphere.

Modes of Introduction:

– Architecture and Design

Likelihood of Exploit:

 

Related Weaknesses

CWE-664
CWE-99

 

Consequences

Confidentiality, Integrity: Read Application Data, Modify Application Data

 

Potential Mitigations

CVE References

 

CWE-705 – Incorrect Control Flow Scoping

Read Time:31 Second

Description

The software does not properly return control flow to the proper location after it has completed a task or detected an unusual condition.

Modes of Introduction:

– Architecture and Design

Likelihood of Exploit:

 

Related Weaknesses

CWE-691

 

Consequences

Other: Alter Execution Logic, Other

 

Potential Mitigations

CVE References

 

  • CVE-2014-1266
    • chain: incorrect “goto” in Apple SSL product bypasses certificate validation, allowing Adversary-in-the-Middle (AITM) attack (Apple “goto fail” bug). CWE-705 (Incorrect Control Flow Scoping) -> CWE-561 (Dead Code) -> CWE-295 (Improper Certificate Validation) -> CWE-393 (Return of Wrong Status Code) -> CWE-300 (Channel Accessible by Non-Endpoint).