Skip to main content

SKY-L020 · Logic and resilience

Overly broad file permissions

High

The catalog gives no severity for this rule; the detector always reports HIGH.

os.chmod(path, mode) sets who may read, write and run a file. SKY-L020 reports a call whose mode gives every user on the machine write access, or gives other users any access to a file whose name marks it as a key, certificate or credentials file.

Languages
Python
Quality gate
counted toward the gate limits (full and diff scans)
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

A world-writable folder lets any local account or compromised service replace what is in it, for example swap an uploaded file for a script the next job runs. A private key readable by other users can be copied by any process on the host.

What Skylos flags

app/uploads.py · PythonReported on line 11
"""Prepare the shared upload folder for the web app and the thumbnail worker.""" import os UPLOAD_ROOT = "/srv/media/uploads"  def prepare_upload_dir(tenant_id: str) -> str:    path = os.path.join(UPLOAD_ROOT, tenant_id)    os.makedirs(path, exist_ok=True)    os.chmod(path, 0o777)    return path

What Skylos leaves alone

app/deploy.py · Python
"""Install the release script and the signing key on the build host.""" import os  def install_release_files(script_path: str, key_bytes: bytes) -> None:    os.chmod(script_path, 0o755)    with open("signing_private.pem", "wb") as handle:        handle.write(key_bytes)    os.chmod("signing_private.pem", 0o600)

Why Skylos leaves it alone

0o755 lets others read and run the script but not change it, which is normal for a program. The key file's name contains private and .pem, so Skylos checks it more strictly, and 0o600 gives no access to anyone but the owner.

How Skylos decides

  1. Runs with --quality on Python files. Skips test files: names that start with test_, end in _test.py, or are conftest.py.
  2. Looks only at calls written as os.chmod(...) with at least two positional arguments, where the mode is an integer literal such as 0o777 or 511.
  3. Reports when the mode includes all of 0o777 (everyone may read, write and run), or when it has the world-writable bit 0o002.
  4. Otherwise reports when the path is a string literal or a variable whose name contains a sensitive word (.env, .pem, .key, .crt, credentials, secrets, private, id_rsa, kubeconfig, keystore and others) and the mode gives group or other users any access (mode & 0o077). Add words with extra_sensitive_file_keywords under [tool.skylos.vibe].
  5. Every finding is HIGH and points at the os.chmod call.

How to fix it

Give access to the owner and to a group the web app and the worker share, and nobody else. For key and credential files, use 0o600.

app/uploads.py · Python · the fix, against the flagged file
"""Prepare the shared upload folder for the web app and the thumbnail worker.""" import os UPLOAD_ROOT = "/srv/media/uploads"  def prepare_upload_dir(tenant_id: str) -> str:    path = os.path.join(UPLOAD_ROOT, tenant_id)    os.makedirs(path, exist_ok=True)Removed:     os.chmod(path, 0o777)Added:     os.chmod(path, 0o770)    return path

When it can be wrong

  • A folder that really is meant for every user, such as a shared /tmp style drop folder with the sticky bit (0o1777), is still reported.
  • It misses modes it cannot read as one literal: stat.S_IRWXO, a variable, mode=0o777 passed by keyword, and calls through Path.chmod, os.fchmod or from os import chmod.
  • A sensitive path built with an f-string or os.path.join is not recognised as sensitive, so only the 0o777 and world-writable checks apply to it.

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

  • Put the marker on the os.chmod line.

    Python
    os.chmod(path, 0o777)  # skylos: ignore[SKY-L020] drop folder, sticky bit set
  • [tool.skylos] ignore = ["SKY-L020"] turns the rule off for the project.

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