Skip to main content

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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

An unintended mode can grant access to the wrong accounts or deny access the application needs.

What Skylos flags

src/lib.rs · RustReported on line 4
#[cfg(unix)]fn make_mode() -> std::fs::Permissions {    use std::os::unix::fs::PermissionsExt;    std::fs::Permissions::from_mode(644)}

What Skylos leaves alone

src/lib.rs · Rust
#[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

  1. 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.
  2. 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.

src/lib.rs · Rust · the fix, against the flagged file
#[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.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.