Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V1118. Excessive file permissions...
menu mobile close menu
Additional information
toggle menu Contents

V1118. Excessive file permissions can lead to vulnerabilities. Consider restricting file permissions.

May 19 2025

Excessive file permissions indicate security risks and may lead to vulnerabilities.

The analyzer checks the following system calls for excessive permissions: open, creat, openat, chmod, fchmod, fchmodat, mkdir, mkdirat, mkfifo, mkfifoat, mknod, mknodat, mq_open, and sem_open.

The example:

void foo(int param)
{
  int perms = 0777;
  int fd = open("/path/to/file", O_CREAT | O_RDONLY, perms);
  if (fd < 0) return;
 
  // some work

  close(fd);
}

The code uses the open system call to open a file and process the information it contains. If the file does not exist, it will be created via the O_CREAT flag in the second argument and have permissions specified by the number in the third argument. In this case, the 0777 mask allows any user to read, write, or execute this file, which can lead to vulnerabilities.

To fix the error, modify the permission mask:

void foo(int param)
{
  int perms = 0644;
  int fd = open("/path/to/file", O_CREAT | O_RDONLY, perms);
  if (fd < 0) return;
 
  // some work

  close(fd);
}

This diagnostic is classified as:

close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
close form
Free PVS‑Studio license for Microsoft MVP specialists
close form
To get the licence for your open-source project, please fill out this form
close form
I want to join the test
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam