Skip to content

Incorrect permission assignment for critical resource

Description

The application is setting file permissions to overly permissive values. Consider using restrictive permissions such as 0400 for read-only access, 0200 for write-only access, or 0600 for read/write access to the file.

Examples

Insecure Code

python
os.chmod('somefile.txt', 0o777)

Secure Code

python
os.chmod('somefile.txt', 0o600)

Remediation

Use os.chmod with restrictive permissions, for example: os.chmod('somefile.txt', 0o600) for read/write access to the file.

Rule Details

FieldValue
IDCODE-0153
CategoryAccessControl
SeverityMEDIUM
CWECWE-732
ConfidenceHIGH
ImpactMEDIUM
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagsfile permissions, access control
OWASPA5:2017-Broken Access Control, A01:2021-Broken Access Control