SKY-D416 · Security in code
Non-octal Unix permission mode literal
MediumCWE-732
A standard Unix filesystem extension takes a permission mode written as a decimal or hexadecimal integer. Decimal 644 and octal 0o644 select different permission bits.
- Languages
- Rust
- Quality gate
- listed, not counted by the gate (full and diff scans). The advisory stays visible and does not fail the security gate.
- Finding type
- review
Why it matters
An unintended mode can grant access to the wrong accounts or deny access the application needs.
What Skylos flags
#[cfg(unix)]fn make_mode() -> std::fs::Permissions { use std::os::unix::fs::PermissionsExt; std::fs::Permissions::from_mode(644)}What Skylos leaves alone
#[cfg(unix)]fn make_mode() -> std::fs::Permissions { use std::os::unix::fs::PermissionsExt; std::fs::Permissions::from_mode(0o644)}Why Skylos leaves it alone
The literal expresses the owner, group and other permission bits in octal.
How Skylos decides
- Checks PermissionsExt::from_mode and set_mode, OpenOptionsExt::mode and DirBuilderExt::mode when the standard filesystem type and Unix extension trait are identified. It resolves explicit imports and aliases.
- Looks for a literal value greater than seven. Octal, binary, constants and computed masks are outside this check. Confirm the intended bits before changing the spelling.
How to fix it
Identify the intended access and write that mode in octal or use named permission flags.
#[cfg(unix)]fn make_mode() -> std::fs::Permissions { use std::os::unix::fs::PermissionsExt;Removed: std::fs::Permissions::from_mode(644)Added: std::fs::Permissions::from_mode(0o644)}When it can be wrong
- The author may intentionally use a hexadecimal or decimal literal for a verified bitmask.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Add a Skylos ignore comment to the call after confirming the intended mode.