CWE-732 Classe Rascunho High likelihood

Incorrect Permission Assignment for Critical Resource

This vulnerability occurs when a system grants overly permissive access to a sensitive resource, allowing unauthorized users or processes to read or alter it.

Definição

What is CWE-732?

This vulnerability occurs when a system grants overly permissive access to a sensitive resource, allowing unauthorized users or processes to read or alter it.
This flaw happens when security settings for a critical file, directory, or cloud resource are configured too loosely. Instead of restricting access to only the necessary users or services, the permissions are set to allow a much broader range of actors. This creates an open door for data exposure or unauthorized changes. In practice, this often involves misconfigured file system permissions, database access controls, or cloud storage settings. For instance, a cloud storage container set to 'public read' could leak sensitive data, or a configuration file writable by any system user could be tampered with to alter the program's behavior. The core risk is that the intended security boundary around the resource is incorrectly defined and enforced.
Impacto no mundo real

Real-world CVEs caused by CWE-732

  • Go application for cloud management creates a world-writable sudoers file that allows local attackers to inject sudo rules and escalate privileges to root by winning a race condition.

  • Anti-virus product sets insecure "Everyone: Full Control" permissions for files under the "Program Files" folder, allowing attackers to replace executables with Trojan horses.

  • Product creates directories with 0777 permissions at installation, allowing users to gain privileges and access a socket used for authentication.

  • Photo editor installs a service with an insecure security descriptor, allowing users to stop or start the service, or execute commands as SYSTEM.

  • socket created with insecure permissions

  • 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.

  • Device driver uses world-writable permissions for a socket file, allowing attackers to inject arbitrary commands.

  • LDAP server stores a cleartext password in a world-readable file.

Como os atacantes a exploram

Trajeto do atacante passo a passo

  1. 1

    The following code sets the umask of the process to 0 before creating a file and writing "Hello world" into the file.

  2. 2

    After running this program on a UNIX system, running the "ls -l" command might return the following output:

  3. 3

    The "rw-rw-rw-" string indicates that the owner, group, and world (all users) can read the file and write to it.

  4. 4

    This code creates a home directory for a new user, and makes that user the owner of the directory. If the new directory cannot be owned by the user, the directory is deleted.

  5. 5

    Because the optional "mode" argument is omitted from the call to mkdir(), the directory is created with the default permissions 0777. Simply setting the new user as the owner of the directory does not explicitly change the permissions of the directory, leaving it with the default. This default allows any user to read and write to the directory, allowing an attack on the user's files. The code also fails to change the owner group of the directory, which may result in access by unexpected groups.

Exemplo de código vulnerável

Vulnerable C

The following code sets the umask of the process to 0 before creating a file and writing "Hello world" into the file.

Vulnerável C
#define OUTFILE "hello.out"
  umask(0);
  FILE *out;
```
/* Ignore link following (CWE-59) for brevity */* 
  
  out = fopen(OUTFILE, "w");
  if (out) {
  ```
  	fprintf(out, "hello world!\n");
  	fclose(out);
  }
Exemplo de código seguro

Secure Shell

The command could be modified to disable "Allow Blob Public Access" by setting it to false.

Seguro Shell
az storage account update --name <storage-account> --resource-group <resource-group> --allow-blob-public-access false
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Lista de verificação de prevenção

How to prevent CWE-732

  • Implementation 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.
  • Architecture and Design 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]
  • Architecture and Design / Operation Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software. OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
  • Implementation / Installation 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.
  • System Configuration For all configuration files, executables, and libraries, make sure that they are only readable and writable by the software's administrator.
  • Documentation 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.
  • Installation Do not assume that a system administrator will manually change the configuration to the settings that are recommended in the software's manual.
  • Operation / System Configuration Ensure that the software runs properly under the United States Government Configuration Baseline (USGCB) [REF-199] or an equivalent hardening configuration guide, which many organizations use to limit the attack surface and potential risk of deployed software.
Sinais de deteção

How to detect CWE-732

Automated Static Analysis

Automated static analysis may be effective in detecting permission problems for system resources such as files, directories, shared memory, device interfaces, etc. Automated techniques may be able to detect the use of library functions that modify permissions, then analyze function calls for arguments that contain potentially insecure values. However, since the software's intended security policy might allow loose permissions for certain operations (such as publishing a file on a web server), automated static analysis may produce some false positives - i.e., warnings that do not have any security consequences or require any code changes. When custom permissions models are used - such as defining who can read messages in a particular forum in a bulletin board system - these can be difficult to detect using automated static analysis. It may be possible to define custom signatures that identify any custom functions that implement the permission checks and assignments.

Automated Dynamic Analysis

Automated dynamic analysis may be effective in detecting permission problems for system resources such as files, directories, shared memory, device interfaces, etc. However, since the software's intended security policy might allow loose permissions for certain operations (such as publishing a file on a web server), automated dynamic analysis may produce some false positives - i.e., warnings that do not have any security consequences or require any code changes. When custom permissions models are used - such as defining who can read messages in a particular forum in a bulletin board system - these can be difficult to detect using automated dynamic analysis. It may be possible to define custom signatures that identify any custom functions that implement the permission checks and assignments.

Manual Analysis

This weakness can be detected using 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.

Manual Static Analysis

Manual static analysis may be effective in detecting the use of custom permissions models and functions. The code could then be examined to identifying usage of the related functions. Then the human analyst could evaluate permission assignments in the context of the intended security model of the software.

Manual Dynamic Analysis

Manual dynamic analysis may be effective in detecting the use of custom permissions models and functions. The program could then be executed with a focus on exercising code paths that are related to the custom permissions. Then the human analyst could evaluate permission assignments in the context of the intended security model of the software.

Fuzzing

Fuzzing is not effective in detecting this weakness.

Correção automática do Plexicus

O Plexicus deteta automaticamente o CWE-732 e abre um PR de correção em menos de 60 segundos.

O Codex Remedium analisa cada commit, identifica esta fraqueza exata e entrega um pull request pronto para revisão com o patch. Sem tickets. Sem transferências.

Perguntas frequentes

Frequently asked questions

O que é o CWE-732?

This vulnerability occurs when a system grants overly permissive access to a sensitive resource, allowing unauthorized users or processes to read or alter it.

Qual a gravidade do CWE-732?

A MITRE classifica a probabilidade de exploração como Alta — esta fraqueza é ativamente explorada em campo e deve ser priorizada para remediação.

Que linguagens ou plataformas são afetadas pelo CWE-732?

MITRE lists the following affected platforms: Not Technology-Specific, Cloud Computing.

Como posso prevenir o CWE-732?

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. 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…

Como é que o Plexicus deteta e corrige o CWE-732?

O motor SAST do Plexicus correlaciona a assinatura de fluxo de dados do CWE-732 em cada commit. Quando é encontrada uma correspondência, o nosso agente Codex Remedium abre um PR de correção com o código corrigido, testes e um resumo de uma linha para o revisor.

Onde posso saber mais sobre o CWE-732?

A MITRE publica a definição canónica em https://cwe.mitre.org/data/definitions/732.html. Pode também consultar a documentação da OWASP e do NIST para orientações adjacentes.

Fraquezas relacionadas

Weaknesses related to CWE-732

CWE-285 Pai

Improper Authorization

This vulnerability occurs when an application fails to properly verify whether a user has permission to access specific data or perform…

CWE-1230 Irmão

Exposure of Sensitive Information Through Metadata

This vulnerability occurs when an application protects the primary source of sensitive data but fails to secure the metadata derived from…

CWE-1256 Irmão

Improper Restriction of Software Interfaces to Hardware Features

This vulnerability occurs when a system's software interfaces to hardware features—like power, clock, or performance management—are not…

CWE-1297 Irmão

Unprotected Confidential Information on Device is Accessible by OSAT Vendors

This vulnerability occurs when a semiconductor chip does not properly secure sensitive data, making it accessible to third-party…

CWE-1328 Irmão

Security Version Number Mutable to Older Versions

This vulnerability occurs when a hardware system's security version number can be changed, allowing an attacker to downgrade or roll back…

CWE-552 Irmão

Files or Directories Accessible to External Parties

This vulnerability occurs when an application exposes files or directories to users who shouldn't have access to them.

CWE-862 Irmão

Missing Authorization

This vulnerability occurs when an application fails to verify whether a user has permission to access specific data or execute certain…

CWE-863 Irmão

Incorrect Authorization

This vulnerability occurs when an application checks if a user is allowed to perform an action or access data, but the check is flawed or…

CWE-926 Irmão

Improper Export of Android Application Components

This vulnerability occurs when an Android app makes a component (like an Activity, Service, or Content Provider) available to other apps…

Pronto quando você estiver

Pare de pagar por desenvolvedor.
Comece a fechar o ciclo.

O Plexicus é o ASPM nativo de IA que verifica, filtra, corrige, pentesta e explica — de forma autónoma. Programadores ilimitados, repos ilimitados, ações de IA de utilização justa. Nível gratuito real, €269/mo anual quando estiver pronto.