Katalog CWE

CWE-560 · Słabość

Use of umask() with chmod-style Argument

Abstrakcja
Wariant
Status
Szkic
Dodano
19 lipca 2006
Ostatnia zmiana
11 grudnia 2025

Podatności CVE z tą słabościąPełny wpis na cwe.mitre.org ↗

Opis

The product calls umask() with an incorrect argument that is specified as if it is an argument to chmod().

Skutki

  • Confidentiality, Integrity, Access Control

    Read Files or Directories; Modify Files or Directories; Bypass Protection Mechanism

Zapobieganie

  • Implementation

    Use umask() with the correct argument.

Słabość nadrzędna

Kiedy powstaje

Dotyczy

C

Uwagi

Some umask() manual pages begin with the false statement: "umask sets the umask to mask & 0777" Although this behavior would better align with the usage of chmod(), where the user provided argument specifies the bits to enable on the specified file, the behavior of umask() is in fact opposite: umask() sets the umask to ~mask & 0777. The documentation goes on to describe the correct usage of umask(): "The umask is used by open() to set initial file permissions on a newly-created file. Specifically, permissions in the umask are turned off from the mode argument to open(2) (so, for example, the common umask default value of 022 results in new files being created with permissions 0666 & ~022 = 0644 = rw-r--r-- in the usual case where the mode is specified as 0666)."

Wpis z katalogu CWE 4.20.