What are the potential security risks when setting CHMOD in the main directory to 7 for file manipulation in PHP?

Setting CHMOD in the main directory to 7 for file manipulation in PHP can pose a significant security risk as it grants full permissions to all users, potentially allowing unauthorized access and modification of sensitive files. To mitigate this risk, it is recommended to set more restrictive permissions based on the principle of least privilege, granting only the necessary permissions to the appropriate users.

// Set more restrictive permissions for file manipulation
chmod('/path/to/main/directory', 755);