SKY-S101 · Secrets
Secret written into a file
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
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
"""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
"""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
- Reads source files in every supported language (except Drupal's
.module-style PHP files); configuration such as.yml,.json,.toml,.ini,.properties,.xml,.gradle,.hcland Terraform;.envand.env.*(and names likeapp.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/.keyfiles, SSH keys and.aws/credentials. - In test files and folders (
test/,tests/,test_*.py,__tests__/,*.test.ts,*.spec.js,testdata/,*_test.goand similar) it looks only for provider keys, private keys and structured credentials; the generic, URL-password and config-credential checks are off there.skylos doneand 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 intestorbench(#[test],#[tokio::test]), when the file parses cleanly. - Looks for provider key shapes first: GitHub
ghp_…andgithub_pat_…, GitLabglpat-…and its other token prefixes, Slackxox…-tokens and webhook URLs, Stripesk_live_…,sk_test_…andrk_live_…, AWSAKIA…, GoogleAIza…, SendGrid, Twilio, npmnpm_…, PyPIpypi-…, DigitalOceandop_v1_…, Hugging Facehf_…, and private-key blocks. It also decodes base64- and URL-encoded values to find them. A match is CRITICAL without a randomness check. - 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.
- 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. - Then looks for generic secrets: a value assigned to a name containing
api_key,token,secret,password,credentialand 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. - 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. - 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. - 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-,eyJand 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).
"""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 inghp_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,.envrcorenv.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 donechecks 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--dangeradds for TypeScript, JavaScript and Java.A baseline (
skylos baseline ., then--baseline) accepts existing findings by file and line. Revoke the keys anyway.