Skip to main content

SKY-S101 · Secrets

Secret written into a file

Critical

Provider keys (Stripe, GitHub, AWS and others), private keys, structured credentials such as a Google service-account file, and random-looking values assigned to a secret-like name are CRITICAL. A long random-looking value with no secret-like name earlier on the same line, a password inside a URL, and a literal password or secret in a config or .env file that only the config-credential check catches are reported as HIGH.

A secret is a password, API key, token or private key that gives access to a system. SKY-S101 reports one that is written directly into a source or configuration file, where everyone who can read the repository, its history or a build artefact can copy it.

Languages
Python, TypeScript/JavaScript, Go, Java, Kotlin, C#, PHP, Rust, Ruby, Swift, Dart, C/C++, Shell, configuration, Markdown and key files
Quality gate
fails the gate on its own (full and diff scans). Any secret fails the gate, whatever the limits.
Finding type
review
Catalog name
Secret detected
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Anyone who sees the repository can use the key: to charge cards through your Stripe account, push code with your GitHub token or start servers on your AWS bill. Deleting the line later does not help, because the key stays in Git history until it is revoked.

What Skylos flags

config/settings.py · PythonReported on line 7
"""Billing settings."""import os DATABASE_URL = os.environ["DATABASE_URL"] STRIPE_API_VERSION = "2024-06-20"STRIPE_SECRET_KEY = "sk_live_51HandbookDemo0nly"

What Skylos leaves alone

config/settings.py · Python
"""Billing settings."""import os DATABASE_URL = os.environ["DATABASE_URL"] STRIPE_API_VERSION = "2024-06-20"STRIPE_SECRET_KEY = os.environ["STRIPE_SECRET_KEY"]WEBHOOK_SCHEMA_COMMIT = "9fceb02d0ae598e95dc970b74767f19372d61af8"

Why Skylos leaves it alone

The Stripe key is read from the environment at run time, so the file holds only its name. The 40-character commit hash looks random, but its name says nothing about secrets and it is all lower-case hex: without a secret-like name, Skylos only considers values that mix upper-case letters, lower-case letters and digits.

How Skylos decides

  1. Reads source files in every supported language (except Drupal's .module-style PHP files); configuration such as .yml, .json, .toml, .ini, .properties, .xml, .gradle, .hcl and Terraform; .env and .env.* (and names like app.env); Dockerfiles, .npmrc, .pypirc, HTML, CSS and source maps; shell scripts without an extension; and, for provider keys, private keys and structured credentials only, Markdown, text, .pem/.key files, SSH keys and .aws/credentials.
  2. In test files and folders (test/, tests/, test_*.py, __tests__/, *.test.ts, *.spec.js, testdata/, *_test.go and similar) it looks only for provider keys, private keys and structured credentials; the generic, URL-password and config-credential checks are off there. skylos done and the agent hooks use the same rule. In Rust the same holds for test-only code inside other files: #[cfg(test)] (or #[cfg(all(test, ...))]) items, a #![cfg(test)] file and functions whose attribute ends in test or bench (#[test], #[tokio::test]), when the file parses cleanly.
  3. Looks for provider key shapes first: GitHub ghp_… and github_pat_…, GitLab glpat-… and its other token prefixes, Slack xox…- tokens and webhook URLs, Stripe sk_live_…, sk_test_… and rk_live_…, AWS AKIA…, Google AIza…, SendGrid, Twilio, npm npm_…, PyPI pypi-…, DigitalOcean dop_v1_…, Hugging Face hf_…, and private-key blocks. It also decodes base64- and URL-encoded values to find them. A match is CRITICAL without a randomness check.
  4. Also reports, as CRITICAL, structured credentials: an AWS secret access key (40 random characters), AWS key pairs in JSON or INI files, Azure Storage connection strings, Google service-account files and private JSON Web Keys.
  5. Skips a provider-shaped value that contains a placeholder word (example, sample, fake, dummy, placeholder, changeme, test_test_, not_a_real, do_not_use) at a word boundary: after the start or a non-alphanumeric character, and not followed by a letter. It also skips the example keys AWS and Slack publish in their docs.
  6. Then looks for generic secrets: a value assigned to a name containing api_key, token, secret, password, credential and similar, or a bare value of 32 or more characters that mixes upper-case letters, lower-case letters and digits. The value must look random (Shannon entropy of at least 3.9 over 20 or more characters, or, under a secret-like name, a long hex value with letters and digits). A bare value is skipped when it looks like an identifier (starts with a letter or _, then only letters, digits and _), a URL without credentials, a file path, prose or a ${VAR} reference, and is not reported at all in HTML, CSS, source maps and minified bundles. A whole string literal that is a shuffled standard encoding alphabet (every base64, base64url, base62, base58, base36 or base32 character exactly once) is skipped when it is passed to an alphabet constructor or bound to an alphabet or charset name (Alphabet::new("AphruV…")); elsewhere it stays a finding that is not listed by default.
  7. Also reports a password written inside a URL, such as a database connection string, and literal values for password and secret keys in config files, skipping placeholder passwords such as changeme.
  8. A secret in code that ships to the browser (public/, static/, .next/static/, files marked "use client" and similar) is reported as SKY-S102 instead.
  9. With --danger, the TypeScript, JavaScript and Java security checks also report SKY-S101, in the security list: strings of 16 or more characters with a well-known key prefix (sk-, sk_live_, ghp_, AKIA, xoxb-, eyJ and others) as CRITICAL, and base64-like strings of 20 or more characters with very high entropy as HIGH.

How to fix it

Revoke the key with the provider first: it is already exposed. Then read the new key from the environment or a secret manager, and keep real values out of Git (for example in an ignored .env file).

config/settings.py · Python · the fix, against the flagged file
"""Billing settings."""import os DATABASE_URL = os.environ["DATABASE_URL"] STRIPE_API_VERSION = "2024-06-20"Removed: STRIPE_SECRET_KEY = "sk_live_51HandbookDemo0nly"Added: STRIPE_SECRET_KEY = os.environ["STRIPE_SECRET_KEY"]

When it can be wrong

  • One key can be reported twice: when the quoted value is longer than the provider-shaped part, both the provider and the generic check report it; and in TypeScript, JavaScript and Java with --danger, the security check reports it again.
  • Documentation fixtures shaped like a real key, such as ghp_000…0, are reported, because provider patterns have no randomness check. Start the value with a placeholder word after the prefix, as in ghp_example000….
  • Random identifiers with no secret-like name (build IDs, content hashes in odd shapes) can be reported as HIGH.
  • A random-looking value in a test folder is not reported unless it has a provider or structured-credential shape, and a scan does not read files such as .env-local, .envrc or env.local (the agent hooks do).

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

  • Mark a reviewed value on the same line; a marker on the line above is not read. In Python, Ruby, Swift and config files the text skylos: ignore[SKY-S101] anywhere on the line works; in TypeScript, JavaScript, Go, Java, the other C-like languages, Shell and PHP it must be a real comment. skylos done checks only the lines a change adds and ignores any marker on them.

    Python
    SANDBOX_KEY = "sk_test_51HandbookDemo0nly"  # skylos: ignore[SKY-S101] shared sandbox
  • [tool.skylos] ignore = ["SKY-S101"] has no effect on the secrets scan: its findings stay reported and still fail the gate. It only hides the SKY-S101 findings that --danger adds for TypeScript, JavaScript and Java.

  • A baseline (skylos baseline ., then --baseline) accepts existing findings by file and line. Revoke the keys anyway.

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