SKY-D339 · Security in code
Command changes the machine's persistent setup
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
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
#!/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
#!/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
import subprocess def install_hooks() -> None: subprocess.run("git config --global core.hooksPath .githooks", shell=True)Not flagged
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
- Reads shell commands in
.sh,.bash,.zsh,.kshand.batsfiles, GitHub Actionsrun:steps, GitLab CI script items, DockerfileRUNinstructions, fixed command strings in Pythonos.system()-style calls orshell=Truecalls, and fixed strings passed tochild_process.exec()in TypeScript and JavaScript. - Splits each command at
;,&&,||and|, and reports these command words (aftersudo,nohup,time,commandandVAR=valueprefixes):crontabwith any arguments;systemctlorlaunchctlwithenable,loadorbootstrap;npm,pnpm,yarn,piporpip3config set(alsopython -m pip config set); andgit configwith--global. - 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/rcand~/.ssh/environment,/etc/profile*,/etc/environment,/etc/bash.bashrc,/etc/crontaband/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. - Also reports
>,>>ortee -ainto a startup file under~,$HOMEor${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.
#!/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 …orgit config --global --add safe.directory /appin a job, andecho 'export PATH=…' >> ~/.bashrcin a Dockerfile. crontab -l, which only lists jobs, is reported like an install.- Missed:
tee(without-a) orsudo teewriting a persistence file,installorcpinto one, and in a GitHub Actionsrun: |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.