Back to all reviewers

Use explicit permission notations

astral-sh/ruff
Based on 1 comments
Rust

When setting file permissions through system calls like `chmod`, always use explicit octal notation (with the `0o` prefix) rather than decimal integers. Decimal integers in permission contexts can lead to unintended access rights, creating security vulnerabilities through incorrect file permissions.

Security Rust

Reviewer Prompt

When setting file permissions through system calls like chmod, always use explicit octal notation (with the 0o prefix) rather than decimal integers. Decimal integers in permission contexts can lead to unintended access rights, creating security vulnerabilities through incorrect file permissions.

For example, instead of:

os.chmod("foo", 644)  # Incorrect - decimal integer

Use:

os.chmod("foo", 0o644)  # Correct - explicit octal notation

The decimal value 644 is not equivalent to the octal value 0o644, and this mismatch can lead to improper permission settings that may expose sensitive files to unauthorized access. Always verify permission values in security-sensitive operations.

1
Comments Analyzed
Rust
Primary Language
Security
Category

Source Discussions