SKY-L020 · Logic and resilience
Overly broad file permissions
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
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
"""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 pathWhat Skylos leaves alone
"""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
- Runs with
--qualityon Python files. Skips test files: names that start withtest_, end in_test.py, or areconftest.py. - Looks only at calls written as
os.chmod(...)with at least two positional arguments, where the mode is an integer literal such as0o777or511. - Reports when the mode includes all of
0o777(everyone may read, write and run), or when it has the world-writable bit0o002. - 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,keystoreand others) and the mode gives group or other users any access (mode & 0o077). Add words withextra_sensitive_file_keywordsunder[tool.skylos.vibe]. - Every finding is HIGH and points at the
os.chmodcall.
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.
"""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 pathWhen it can be wrong
- A folder that really is meant for every user, such as a shared
/tmpstyle 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=0o777passed by keyword, and calls throughPath.chmod,os.fchmodorfrom os import chmod. - A sensitive path built with an f-string or
os.path.joinis not recognised as sensitive, so only the0o777and 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.chmodline.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.