Skip to main content

SKY-D339 · Security in code

Command changes the machine's persistent setup

HighCWE-15

Some commands change the machine for good, not just the current job: shell startup files, cron jobs, system services, SSH authorized_keys, global Git settings and package-manager config. SKY-D339 reports a script or CI command that makes such a change.

Languages
Shell, GitHub Actions, GitLab CI, Dockerfile, Python, TypeScript/JavaScript
Quality gate
counted toward the gate limits (full and diff scans)
Finding type
review
Catalog name
Persistent environment mutation
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

A line appended to ~/.zshrc runs in every shell the developer opens from then on, long after the script is forgotten. The same mechanism is how malware keeps access: an extra key in authorized_keys, a cron entry or a global Git hook path survives reboots and new checkouts.

What Skylos flags

scripts/dev-setup.sh · ShellReported on line 6
#!/usr/bin/env bash# One-time setup for new developers.set -euo pipefail npm ciecho "source $PWD/scripts/dev-env.sh" >> ~/.zshrcecho "Open a new terminal to finish."

What Skylos leaves alone

scripts/dev-setup.sh · Shell
#!/usr/bin/env bash# One-time setup for new developers.set -euo pipefail npm ciecho "To load the dev tools in every shell, add this line to ~/.zshrc:"echo "  source $PWD/scripts/dev-env.sh"

Why Skylos leaves it alone

The script only prints the line and leaves the choice to the developer. Mentioning ~/.zshrc is not a write: Skylos needs a >, >> or tee -a into the file.

More languages

Python

Flagged

tools/bootstrap.py · PythonReported on line 5
import subprocess  def install_hooks() -> None:    subprocess.run("git config --global core.hooksPath .githooks", shell=True)

Not flagged

tools/bootstrap.py · Python
import subprocess  def install_hooks() -> None:    subprocess.run("git config core.hooksPath .githooks", shell=True)

Why Skylos leaves it alone

Without --global the setting is written to this repository's own .git/config and affects only this checkout. With --global, every repository on the machine would run hooks from whatever .githooks folder it is in.

How Skylos decides

  1. Reads shell commands in .sh, .bash, .zsh, .ksh and .bats files, GitHub Actions run: steps, GitLab CI script items, Dockerfile RUN instructions, fixed command strings in Python os.system()-style calls or shell=True calls, and fixed strings passed to child_process.exec() in TypeScript and JavaScript.
  2. Splits each command at ;, &&, || and |, and reports these command words (after sudo, nohup, time, command and VAR=value prefixes): crontab with any arguments; systemctl or launchctl with enable, load or bootstrap; npm, pnpm, yarn, pip or pip3 config set (also python -m pip config set); and git config with --global.
  3. Reports output redirected (>, >>, >&, &>) by any command into a persistence file: shell startup files (.bashrc, .bash_profile, .bash_login, .profile, .zshrc, .zprofile, .zshenv, .zlogin), authorized_keys, ~/.ssh/rc and ~/.ssh/environment, /etc/profile*, /etc/environment, /etc/bash.bashrc, /etc/crontab and /etc/cron*, /etc/sudoers*, /etc/ld.so.preload, /etc/rc.local, /etc/init.d/, systemd unit folders, autostart and fish config folders, and Git hook folders outside the project.
  4. Also reports >, >> or tee -a into a startup file under ~, $HOME or ${HOME}, anywhere in the command text. A glob that could name a persistence file counts, and //, /./ and .. in the path are normalised first. Every finding is HIGH.

How to fix it

Print the change and let the person decide, or keep it inside the project: a project-level .envrc that direnv asks to approve, a repo git config without --global, a service file installed by the system's package, not by a build script.

scripts/dev-setup.sh · Shell · the fix, against the flagged file
#!/usr/bin/env bash# One-time setup for new developers.set -euo pipefail npm ciRemoved: echo "source $PWD/scripts/dev-env.sh" >> ~/.zshrcRemoved: echo "Open a new terminal to finish."Added: echo "To load the dev tools in every shell, add this line to ~/.zshrc:"Added: echo "  source $PWD/scripts/dev-env.sh"

When it can be wrong

  • CI and container builds are reported too, where nothing persists: git config --global user.email … or git config --global --add safe.directory /app in a job, and echo 'export PATH=…' >> ~/.bashrc in a Dockerfile.
  • crontab -l, which only lists jobs, is reported like an install.
  • Missed: tee (without -a) or sudo tee writing a persistence file, install or cp into one, and in a GitHub Actions run: | block, or a multi-line GitLab item, a command word on a later line, because the block is split only at ;, &&, || and |, not at line breaks.

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

  • In a shell script, put the marker on the reported line as a real comment. In GitHub Actions, GitLab CI and Dockerfiles the marker may also sit on the line directly above, one rule per marker.

    YAML
    # skylos: ignore[SKY-D339] ephemeral runner, needed for the release commit- run: git config --global user.email "release-bot@acme.example"
  • [tool.skylos] ignore = ["SKY-D339"] turns the rule off for the whole project.

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