Skip to content

File Manager recursive permission change applies directory permissions to files (sets 770 on files) #742

Open

Description

@chiareu

CloudPanel version(s) affected

2.5.3

Description

When using CloudPanel File Manager to change permissions recursively on a directory, the system incorrectly applies the same permission mode to both directories and files.

Specifically, when setting a directory to 770, all contained files are also set to 770, instead of using appropriate file permissions.

Impact:

  • Incorrect file permissions
  • Potential security risk
  • Breaks standard permission models for WordPress and Linux systems

Technical concern:
This suggests the recursive permission logic is applying directory mode to files, instead of distinguishing between:

  • chmod for directories
  • chmod for files

Severity:
Medium to High (incorrect permission handling with security implications)

How to reproduce

  1. Open CloudPanel File Manager
  2. Select a folder (e.g. WordPress theme directory)
  3. Change permissions to 770
  4. Inspect files inside the folder

Expected behaviour:

  • Directories → 770
  • Files → 660 (or remain unchanged)

Possible Solution

Suggestion:

  • Separate handling for files vs directories during recursive chmod
  • Apply:
    • directories → requested mode
    • files → safe default (e.g. 644/660) or leave unchanged

Additional Context

  • OS: Ubuntu 24.04
  • CloudPanel: v2.5.3
  • PHP: 8.5
  • WordPress: latest (observed across multiple installations)

Activity

  1. chiareu commented on Jul 29, 2026

    @chiareu
    Author

    Additional findings:

    While investigating the File Manager permission handling, I reviewed the source code in src/File/Manager.php and found the logic responsible for resetting permissions.

    The current implementation in resetPermissions() appears to apply:

    • directories → 770
    • files → 770

    This seems to be related to the behaviour reported here, where recursive permission handling does not distinguish between directory permissions and regular file permissions.

    I also observed that files created directly through the File Manager receive executable permissions, for example:

    -rwxrwx--- test-manager.php
    -rwxrwx--- test-new-file.txt
    

    while files uploaded through other mechanisms may receive standard permissions:

    -rw-r--r-- test-document.pdf

    From a Linux permissions perspective, directories and regular files normally require different modes. Applying directory permissions directly to files introduces unnecessary executable bits and may trigger security scanners or create inconsistent permission models.

    Expected behaviour would likely be:

    • directories → 770
    • files → 660/640/644 depending on the intended security model

    or preserving existing permissions unless explicitly changed by the administrator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions