6. Security
codeknife sec scans your source files, GitHub Actions workflows and Dockerfiles for a fixed set of security mistakes: SQL and shell injection, unsafe HTML sinks, hard-coded secrets, weak crypto in auth code, unsafe deserialization, weakened JWT checks, wildcard CORS with credentials, simple taint flows, routes that skip auth middleware their siblings use, unpinned actions and root containers. Use it as a fast pre-merge net for these specific patterns. It is not a full security scanner.
Quick example
Section titled “Quick example”The demo repository below has one file per language plus a workflow and a Dockerfile. All secrets in it are fake.
// src/api.ts (excerpt)export function findUser(userId: string) { const q = `SELECT * FROM users WHERE id = ${userId}`; return q;}
export function newSessionToken() { const token = Math.random().toString(36); return token;}
export const corsConfig = { origin: '*', credentials: true };
export const stripeKey = "sk_live_FAKE0000NOTAREALKEY";export const awsKeyId = "AKIAFAKE000000000000";export const dbUrl = "postgres://admin:hunter2fake@db.internal/app";export const api_key = "q7Zr2Lw9Xk4Pv8Ns3Jd6Hf1Tb5Gm0Cy";// src/handlers.ts (excerpt)export async function download(req: any, res: any) { const fname = req.query.file; const data = fs.readFileSync(fname, 'utf8'); await fetch(req.body.callback); res.redirect(req.query.next); const settings: any = {}; settings[req.body.key] = req.body.value; Object.assign(settings, req.body); return data;}on: issuesjobs: triage: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@main - uses: someorg/lint-action@v2 - uses: someorg/other-action@0123456789abcdef0123456789abcdef01234567 - run: echo "${{ github.event.issue.title }}" - run: | echo start echo "${{ github.event.comment.body }}"codeknife sec --no-cache --format humanerror[CK_SEC_XSS_SINK]: unsafe HTML/eval sink (`dangerouslySetInnerHTML`, `innerHTML`, `document.write`, or `eval`) --> src/View.tsx:2 = fix: Render sanitized text nodes or safe templating instead of raw HTML/eval injection.
error[CK_SEC_HARDCODED_SECRET]: potential hardcoded secret (high-entropy secret in sensitive variable) in source code --> src/api.ts:28 = fix: Move credentials to environment variables or an Age/secret manager vault.
error[CK_SEC_HARDCODED_SECRET]: potential hardcoded secret (database connection URL with embedded credentials) in source code --> src/api.ts:27 = fix: Move credentials to environment variables or an Age/secret manager vault.
error[CK_SEC_HARDCODED_SECRET]: potential hardcoded secret (AWS access key ID) in source code --> src/api.ts:26 = fix: Move credentials to environment variables or an Age/secret manager vault.
error[CK_SEC_HARDCODED_SECRET]: potential hardcoded secret (Stripe live secret key) in source code --> src/api.ts:25 = fix: Move credentials to environment variables or an Age/secret manager vault.
error[CK_SEC_CORS_WILDCARD]: wildcard CORS origin `*` combined with `credentials: true` --> src/api.ts:23 = fix: Restrict CORS origins to an explicit allowlist when credentials are enabled....error[CK_SEC_SQL_INTERP]: SQL query built via string interpolation/concatenation (SQL injection risk) --> src/api.ts:5 = fix: Use parameterized queries / bind placeholders instead of interpolating variables.
warning[CK_SEC_AUTH_PARITY]: route `app.delete("/api/orders/:id", () => {})` omits auth middleware applied by 4/5 sibling routes --> src/api.ts:36 (app.delete("/api/orders/:id", () => {})) = fix: Attach the router's auth middleware/dependency or explicitly mark this endpoint as public.
warning[CK_SEC_PATH_TRAVERSAL]: unvalidated user input flows into filesystem path operation --> src/handlers.ts:5 = fix: Canonicalize and verify the resolved path stays inside the allowed base directory.
warning[CK_SEC_SSRF]: unvalidated URL input flows into outbound HTTP request (SSRF risk) --> src/handlers.ts:6 = fix: Validate URL scheme/host against an explicit allowlist and block private IP ranges.
warning[CK_SEC_OPEN_REDIRECT]: unvalidated input flows into HTTP redirect destination --> src/handlers.ts:7 = fix: Restrict redirect targets to relative paths or an allowlisted origin.
warning[CK_SEC_PROTO_POLLUTION]: dynamic bracket write with tainted key/value without prototype pollution guard --> src/handlers.ts:9 = fix: Guard against `__proto__`, `constructor`, and `prototype` before dynamic property writes.
warning[CK_SEC_PROTO_POLLUTION]: untrusted object passed into merge/Object.assign without prototype-key guard --> src/handlers.ts:10 = fix: Reject `__proto__`, `constructor`, and `prototype` keys or use `Object.create(null)`....warning[CK_SEC_UNPINNED_ACTION]: GitHub Action `actions/setup-node@main` is not pinned to a full commit SHA --> .github/workflows/ci.yml:7 (actions/setup-node@main) = fix: Pin workflow `uses:` references to an immutable 40-character commit SHA.
info[CK_SEC_UNPINNED_ACTION]: GitHub Action `someorg/lint-action@v2` is not pinned to a full commit SHA --> .github/workflows/ci.yml:8 (someorg/lint-action@v2) = fix: Pin workflow `uses:` references to an immutable 40-character commit SHA.
error[CK_SEC_WORKFLOW_INJECTION]: untrusted `github.event.issue.title` interpolated directly in GitHub Actions `run:` script --> .github/workflows/ci.yml:10 (github.event.issue.title) = fix: Pass untrusted event fields through an intermediate `env:` variable instead of `${{ ... }}` in `run:`.
error[CK_SEC_WORKFLOW_INJECTION]: untrusted `github.event.comment.body` interpolated directly in GitHub Actions `run:` script --> .github/workflows/ci.yml:13 (github.event.comment.body) = fix: Pass untrusted event fields through an intermediate `env:` variable instead of `${{ ... }}` in `run:`.
error[CK_SEC_DOCKER_PIPE_SH]: Dockerfile `RUN` pipes remote download directly into `sh`/`bash` --> Dockerfile:2 = fix: Download the artifact, verify its SHA-256 checksum/signature, then execute.
warning[CK_SEC_DOCKER_ROOT]: Dockerfile runs final container stage as root (no non-root `USER`) --> Dockerfile:1 = fix: Create a dedicated unprivileged user and switch with `USER <non-root>` before CMD/ENTRYPOINT.
codeknife sec: FAIL (7 files, 28 errors, 10 warnings, 1 info, 4ms)The full run (trimmed above at the ... lines) reported all 17 rule IDs on this page. actions/checkout@v4 and the action pinned to a 40-character SHA produced nothing.
Secret values are never printed
Section titled “Secret values are never printed”A CK_SEC_HARDCODED_SECRET finding names only the kind of secret (for example Stripe live secret key) and the file and line. The message, the fix hint and the location carry no part of the literal, and the finding has no symbol. There is nothing to redact because the value is never copied into the finding. In the run above, the JSON output (--format json) contained none of the fake secret strings.
What it scans
Section titled “What it scans”| Input | Which files | Notes |
|---|---|---|
| Source code | Rust, TypeScript (including .tsx), JavaScript, Python and Go files in the code model |
Files outside the model are not parsed. exclude in codeknife.toml removes files from the model. See Language Support. |
| GitHub Actions | *.yml and *.yaml files directly inside <root>/.github/workflows/ |
Not recursive. A .github/workflows/ folder in a subdirectory is ignored. |
| Dockerfiles | Files named Dockerfile, Dockerfile.* or *.Dockerfile anywhere under the root |
The walk skips hidden files and folders, respects .gitignore, and skips folders named target, node_modules, .git, vendor, dist, build and .codeknife. Paths starting with tests/fixtures/ are skipped. |
Things that are skipped:
- Source files that CodeKnife classifies as test files (for example
*.test.ts,*.spec.ts,*_test.go, or Rust and Python files undertests/) are not scanned at all. The exact rules per language are on Language Support. - Inside other files, any line that falls within a test item (for example a Rust
#[test]function in a#[cfg(test)]module) is skipped by every source check. - The workflow and Dockerfile scanners do not read
codeknife.toml. A Dockerfile under a path listed inexcludeis still scanned.
Every rule below is pattern-based. CodeKnife matches syntax tree node kinds and substrings in the node text. It does not resolve types, follow calls into other functions, or understand frameworks beyond the names listed.
| Rule ID | Severity | Impact | Languages or files | Trigger |
|---|---|---|---|---|
CK_SEC_SQL_INTERP |
error | 95 | All source languages, by node kind (see below) | Interpolated or concatenated string that contains a SQL clause |
CK_SEC_CMD_INJECTION |
error | 95 | Python, TS/JS, Go, Rust | Shell execution with interpolated input |
CK_SEC_HARDCODED_SECRET |
error | 95 | All source languages | Known key prefix, AWS key ID, PEM private key, DB URL with password, or high-entropy value in a sensitive variable |
CK_SEC_XSS_SINK |
error | 90 | TS/JS only | dangerouslySetInnerHTML, .innerHTML =, document.write(, eval( |
CK_SEC_UNSAFE_DESER |
error | 90 | All source languages | pickle.load(, pickle.loads(, marshal.loads(, unserialize(, yaml.load( without a safe loader |
CK_SEC_JWT_NONE |
error | 90 | All source languages | JWT call with none algorithm or disabled verification |
CK_SEC_WEAK_CRYPTO |
error | 85 | All source languages | MD5, SHA-1 or Math.random near auth words |
CK_SEC_CORS_WILDCARD |
error | 85 | All source languages | Wildcard origin plus credentials |
CK_SEC_AUTH_PARITY |
warning | 80 | Any language with matching route calls | A route without auth when at least 80% of its sibling routes in the file have auth |
CK_SEC_PATH_TRAVERSAL |
warning | 85 | All source languages | Tainted argument reaches a file path call |
CK_SEC_SSRF |
warning | 85 | All source languages | Tainted argument reaches an outbound HTTP call |
CK_SEC_OPEN_REDIRECT |
warning | 75 | All source languages | Tainted argument reaches a redirect call |
CK_SEC_PROTO_POLLUTION |
warning | 75 | Bracket writes: TS/JS only. Merge calls: any | Tainted object merged, or tainted key or value written with obj[key] = |
CK_SEC_WORKFLOW_INJECTION |
error | 90 | .github/workflows/*.yml, *.yaml |
Untrusted event field inside a run: script |
CK_SEC_UNPINNED_ACTION |
warning or info | 70 or 35 | .github/workflows/*.yml, *.yaml |
uses: reference not pinned to a 40-character SHA |
CK_SEC_DOCKER_PIPE_SH |
error | 85 | Dockerfiles | RUN line that pipes curl or wget into sh or bash |
CK_SEC_DOCKER_ROOT |
warning | 55 | Dockerfiles | Container runs as root |
No rule in this blade has a threshold or config key. --strict does not change any of them; it only tightens size and complexity thresholds that this blade never reads. None of these rules has an autofixer: codeknife fix plans no patches for CK_SEC_* findings. See Autofix Engine. The full catalogue across all blades is on Rule Catalogue.
CK_SEC_SQL_INTERP
Section titled “CK_SEC_SQL_INTERP”A node is a candidate when it is one of these kinds:
| Node kind | Condition |
|---|---|
template_string (TS/JS) |
contains ${ |
macro_invocation (Rust) |
starts with format! and contains { |
binary_expression (TS/JS, Go, Rust) |
contains + |
string (Python, TS/JS) |
starts with f" or f', or contains %s |
Python string concatenation is a binary_operator node in Python’s grammar, so "SELECT * FROM users WHERE id = " + uid in Python is not reported. Go concatenation is.
The candidate text is upper-cased and must contain a SQL clause:
SELECTfollowed later byFROMUPDATEfollowed bySET, with one or two words between them on one lineINSERT INTODELETE FROM
The keyword must not follow a letter, digit or underscore. Outside template strings it also must not follow a backtick, so prose such as `SELECT DISTINCT ...` inside a Rust format! message is ignored.
A template string is not reported when it is the direct argument of a tagged call whose tag ends in sql, query, queryraw, executeraw, $queryraw, $executeraw, gql, psql, mysql or sqlite (case-insensitive, with any <...> type argument removed). Tags named raw or unsafe, or ending in .raw or .unsafe, are always reported.
export function queries(sql: any, prisma: any, id: string, table: string) { const a = sql`SELECT * FROM users WHERE id = ${id}`; const b = prisma.$queryRaw`SELECT * FROM t WHERE id = ${id}`; const c = sql.raw`SELECT * FROM ${table}`; const d = `SELECT * FROM users WHERE id = ${id}`; const e = "SELECT * FROM users WHERE id = " + id; const f = `Update to ${id}`; return [a, b, c, d, e, f];}CODEKNIFE sec status=fail files=1 errors=3 warnings=0 infos=0 elapsed_ms=6[1] ERROR CK_SEC_SQL_INTERP src/q.ts:4-4 sym=- impact=95 | SQL query built via string interpolation/concatenation (SQL injection risk) | fix: Use parameterized queries / bind placeholders instead of interpolating variables.[2] ERROR CK_SEC_SQL_INTERP src/q.ts:5-5 sym=- impact=95 | SQL query built via string interpolation/concatenation (SQL injection risk) | fix: Use parameterized queries / bind placeholders instead of interpolating variables.[3] ERROR CK_SEC_SQL_INTERP src/q.ts:6-6 sym=- impact=95 | SQL query built via string interpolation/concatenation (SQL injection risk) | fix: Use parameterized queries / bind placeholders instead of interpolating variables.Lines 2 and 3 use parameterized tags and pass. Line 7 has no SQL clause.
CK_SEC_CMD_INJECTION
Section titled “CK_SEC_CMD_INJECTION”Only call nodes are checked. The rule differs per language:
| Language | Reported when the call text |
|---|---|
| Python | starts with subprocess. and contains shell=True, or starts with os.system( |
| TypeScript, JavaScript | starts with child_process.exec( or exec(, and contains ${ or + |
| Go | starts with exec.Command("sh", and contains -c and + |
| Rust | is at most 400 characters and contains Command::new("sh"), -c and format! |
execSync(, execFile( and a plain exec(cmd) with no interpolation are not reported.
CK_SEC_HARDCODED_SECRET
Section titled “CK_SEC_HARDCODED_SECRET”Only string literal nodes are checked: string_literal, string, interpreted_string_literal and raw_string_literal. JavaScript and TypeScript template literals (backtick strings) are not checked. Quotes and backticks are trimmed from both ends first. Two detectors run in order.
Known formats. The value must be at least 16 characters. The first match wins:
| Value starts with | Reported kind |
|---|---|
sk-proj- |
OpenAI project API key |
sk_live_ |
Stripe live secret key |
rk_live_ |
Stripe restricted key |
sk-ant- |
Anthropic API key |
ghp_ |
GitHub personal access token |
gho_ |
GitHub OAuth token |
ghs_ |
GitHub server token |
ghu_ |
GitHub user token |
github_pat_ |
GitHub fine-grained PAT |
xoxb- |
Slack bot token |
xoxp- |
Slack user token |
AIza |
Google/Firebase API key |
SG. |
SendGrid API key |
npm_ |
npm access token |
pypi- |
PyPI API token |
glpat- |
GitLab personal access token |
hf_ |
Hugging Face token |
AKIA, exactly 20 characters, all ASCII letters or digits |
AWS access key ID |
at least 32 characters, containing -----BEGIN and PRIVATE KEY----- |
private key block |
postgres://, postgresql://, mysql://, mongodb://, mongodb+srv:// or redis:// with user:password@ in the host part |
database connection URL with embedded credentials |
A database URL is skipped when the password is empty, contains ${ or <, or looks like a placeholder (see below). The placeholder check does not apply to the prefix, AWS or private key formats.
High-entropy values. If no known format matched, the value is reported as high-entropy secret in sensitive variable when all of these hold:
- It is at least 20 characters, has no whitespace, no
/and no\, and does not start withhttp://orhttps://. - It is not a placeholder: its lower-cased text does not contain
test,dummy,example,changeme,placeholder,xxxx,localhostoryour_. - Its Shannon entropy, counted per byte, is at least 4.5 bits per character.
- It is assigned to a name that contains
api_key,apikey,secret,token,password,passwd,private_key,auth_keyorclient_secret(case-insensitive). CodeKnife looks at up to four parent nodes for a variable declarator,constorstaticitem,letdeclaration, assignment, Go short variable declaration, object or dictionary pair, or struct field, and uses the first one it finds.
This demo shows what is skipped:
password = "changeme_aB3$dK9!qL2@xZ7%"api_token = "Zq8!vR2@kT5#wY9$mB3^nC6&"DATABASE_URL = "postgres://app:${DB_PASS}@db/app"DATABASE_URL2 = "mysql://app:<password>@db/app"greeting = "q7Zr2Lw9Xk4Pv8Ns3Jd6Hf1Tb5Gm0Cy"short = "ghp_short"Only line 2 (api_token) is reported. Line 1 contains changeme, lines 3 and 4 use a template and a <placeholder> password, line 5 is not a sensitive name, and line 6 is shorter than 16 characters.
[1] ERROR CK_SEC_HARDCODED_SECRET src/secrets_neg.py:2-2 sym=- impact=95 | potential hardcoded secret (high-entropy secret in sensitive variable) in source code | fix: Move credentials to environment variables or an Age/secret manager vault.CK_SEC_XSS_SINK
Section titled “CK_SEC_XSS_SINK”TypeScript and JavaScript only:
- a JSX attribute whose text starts with
dangerouslySetInnerHTML - an assignment whose left side ends with
.innerHTML - a call whose text starts with
document.write(oreval(
The value being written is not inspected. Any such sink is reported.
CK_SEC_UNSAFE_DESER
Section titled “CK_SEC_UNSAFE_DESER”A call node of at most 400 characters that does not contain .contains( and whose text, after leading whitespace, starts with pickle.loads(, pickle.load(, marshal.loads( or unserialize(. yaml.load( is reported unless the call text contains SafeLoader, CSafeLoader or BaseLoader.
CK_SEC_JWT_NONE
Section titled “CK_SEC_JWT_NONE”A call node of at most 400 characters, without .contains(. The lower-cased call text must contain jwt, verify( or decode(, and also one of: "none", 'none', verify_signature: false, verify_signature": false, verify: false, ignoreexpiration: true.
CK_SEC_WEAK_CRYPTO
Section titled “CK_SEC_WEAK_CRYPTO”A call whose lower-cased text contains createhash('md5'), createhash("md5"), createhash('sha1') or createhash("sha1"), or starts with hashlib.md5(, hashlib.sha1(, md5.new(, sha1.new( or math.random(. It is only reported in an auth context: the call or one of its three nearest parent nodes must contain token, auth, secret, password, session or csrf (case-insensitive).
CK_SEC_CORS_WILDCARD
Section titled “CK_SEC_CORS_WILDCARD”A call, object or dictionary node of at most 500 characters, without .contains(, matching one of:
- contains
Access-Control-Allow-Origin,*andCredentials - contains
origin: '*'andcredentials: true - contains
allow_origins=["*"]andallow_credentials=True
The match is literal. origin: "*" with double quotes does not match the second form.
CK_SEC_AUTH_PARITY
Section titled “CK_SEC_AUTH_PARITY”This rule compares routes registered in the same file.
What counts as a route. A call node (call_expression or call) or a Python decorated definition whose first line contains one of .get(, .post(, .put(, .delete(, .patch(, .Get(, .Post(, @app.get, @app.post, @router.get or @router.post, and whose text contains a string starting with / ("/ or '/). The match is case-sensitive, so r.GET( does not count. Any call that matches, such as cache.get("/key"), is treated as a route.
Skipped routes. A route whose lower-cased text contains public, /health or /login is ignored.
What counts as auth. The lower-cased text of the whole call or decorated function contains auth, require_user, requireauth, jwt, bearer or get_current_user.
When it fires. Routes are de-duplicated by start line. With at least four routes, if at least 80% of them have auth and at least one does not, each route without auth is reported. The symbol is the first 60 characters of the route’s first line.
@app.get("/items")def list_items(user=Depends(get_current_user)): return []...@router.get("/reports")def reports(): return []
@app.get("/health")def health(): return "ok"[3] WARNING CK_SEC_AUTH_PARITY src/routes.py:24-24 sym=@router.get("/reports") impact=80 | route `@router.get("/reports")` omits auth middleware applied by 4/5 sibling routes | fix: Attach the router's auth middleware/dependency or explicitly mark this endpoint as public.Auth applied at router or app level (for example a middleware registered once with app.use) is not seen. Routes in different files are never compared.
Taint analysis
Section titled “Taint analysis”The taint rules (CK_SEC_PATH_TRAVERSAL, CK_SEC_SSRF, CK_SEC_OPEN_REDIRECT, CK_SEC_PROTO_POLLUTION) track untrusted values inside one function at a time.
Function boundaries. function_item, function_declaration, method_definition, method_declaration, function_definition, arrow_function and function_expression. A nested function starts with an empty taint set; it does not inherit its parent’s tainted variables. Code outside any function is not analysed.
Sources.
- A parameter whose lower-cased name equals or contains
req,request,user_input,user_path,redirect_url,target_url,callback_urloruntrusted. Because this is a substring match, a parameter namedfrequencyis also tainted. - Any expression whose text contains
req.query,req.params,req.body,req.headers,request.args,request.form,request.json,request.GET,request.POST,r.URL.Query,r.FormValue,os.Args,std::env::argsorenv::args.
Propagation. For a variable declarator, let declaration, assignment or Go short variable declaration, if the right side is tainted, the first identifier on the left side becomes tainted. Statements are processed in source order.
Sanitisers. basename, canonicalize, starts_with, validate, allowlist, whitelist, escape, is_safe_url. These are substring matches. If any of them appears anywhere in the function’s text, path, SSRF and redirect findings are suppressed for the whole function, including sinks that come before the sanitiser. A call’s arguments that contain a sanitiser name are also not reported.
Sinks. A call is checked when any of its arguments is tainted. The callee text must match exactly:
| Rule | Callee |
|---|---|
CK_SEC_PATH_TRAVERSAL |
open, or fs.readFile, fs.readFileSync, fs.writeFile, fs.writeFileSync, fs.promises.readFile, path.join, path.resolve, os.ReadFile, os.Open, std::fs::read, std::fs::read_to_string, File::open (exactly, or ending in . plus that name) |
CK_SEC_SSRF |
fetch, axios, axios.get, axios.post, axios.request, requests.get, requests.post, httpx.get, urllib.request.urlopen, http.Get, reqwest::get, ureq::get |
CK_SEC_OPEN_REDIRECT |
res.redirect, redirect, http.Redirect, RedirectResponse |
CK_SEC_PROTO_POLLUTION |
Object.assign, merge, deepMerge |
CK_SEC_PROTO_POLLUTION also fires in TypeScript and JavaScript for an assignment whose left side is a subscript (obj[key] = value) when the key or the value is tainted. Sanitisers do not suppress either form. Both forms are suppressed when the function text contains __proto__, "constructor", 'constructor' or "prototype".
What it does not do. It does not follow a value into another function. In the demo below, only loadSchedule is reported (because frequency contains req). handler passes tainted input to readIt, but readIt’s parameter is not a source, so nothing is reported there. laterSanitize is silent because escape appears in the function.
import * as fs from 'fs';export function loadSchedule(frequency: string) { return fs.readFileSync(frequency, 'utf8');}export function laterSanitize(req: any) { const data = fs.readFileSync(req.query.file, 'utf8'); escape(data); return data;}CODEKNIFE sec status=fail files=1 errors=0 warnings=1 infos=0 elapsed_ms=2[1] WARNING CK_SEC_PATH_TRAVERSAL src/a.ts:3-3 sym=- impact=85 | unvalidated user input flows into filesystem path operation | fix: Canonicalize and verify the resolved path stays inside the allowed base directory.GitHub Actions checks
Section titled “GitHub Actions checks”Each workflow file is read line by line. It is not parsed as YAML. Blank lines and lines starting with # are skipped.
CK_SEC_WORKFLOW_INJECTION
Section titled “CK_SEC_WORKFLOW_INJECTION”A line is a script line when, after an optional leading -, it starts with run:. If the value after run: starts with | or >, every following line indented deeper than the run: line is also a script line. A script line is reported (error, impact 90) when it contains one of:
github.event.issue.title, github.event.issue.body, github.event.pull_request.title, github.event.pull_request.body, github.event.comment.body, github.event.review.body, github.event.discussion.title, github.event.discussion.body, github.event.head_ref, github.event.commits
This is a plain substring test; the ${{ }} wrapper is not required. One finding is raised per line, and its symbol is the matched field. env: blocks and other keys are not checked.
CK_SEC_UNPINNED_ACTION
Section titled “CK_SEC_UNPINNED_ACTION”Every uses: line outside a run: block is checked. A trailing # comment and quotes are removed first.
| Reference | Result |
|---|---|
starts with ./ or docker:// |
not reported |
has no @ |
not reported |
| ref is a 40-character hex SHA | not reported |
ref is main, master, latest, HEAD, dev or develop |
warning, impact 70, for any owner |
owner is actions/ or github/ and ref starts with v |
not reported |
| anything else (third-party tag, short SHA) | info, impact 35 |
Dockerfile checks
Section titled “Dockerfile checks”Each Dockerfile is read line by line. Each line is trimmed and upper-cased, so instructions match in any case. Blank lines and # comments are skipped.
CK_SEC_DOCKER_PIPE_SH
Section titled “CK_SEC_DOCKER_PIPE_SH”A line that starts with RUN , contains CURL or WGET , and contains | SH, |SH, | BASH or |BASH. Line continuations are not joined. A RUN whose pipe is on a continuation line is not reported:
1 FROM alpine 2 RUN apk add curl && \ 3 curl -fsSL https://example.com/a.sh | sh 4 run wget -qO- https://example.com/b.sh |bash 5 USER app 6 CMD ["x"]CODEKNIFE sec status=fail files=0 errors=1 warnings=0 infos=0 elapsed_ms=1[1] ERROR CK_SEC_DOCKER_PIPE_SH Dockerfile:4-4 sym=- impact=85 | Dockerfile `RUN` pipes remote download directly into `sh`/`bash` | fix: Download the artifact, verify its SHA-256 checksum/signature, then execute.CK_SEC_DOCKER_ROOT
Section titled “CK_SEC_DOCKER_ROOT”Reported once per file, at line 1, when all of these hold:
- the file has at least one
FROMline - the file has a
CMDorCMD[orENTRYPOINTline anywhere, in any stage - after the last
FROM, there is noUSERline, or the lastUSERvalue isrootor0
Each FROM resets the USER tracking, so only the final stage’s USER counts. The CMD or ENTRYPOINT does not have to be in the final stage. A file whose first stage has CMD and whose final stage has neither CMD nor USER is reported.
Flags and configuration
Section titled “Flags and configuration”codeknife sec has no flags of its own. These global flags change its behaviour:
| Flag | Effect on sec |
|---|---|
--path <PATH> |
Repository root to scan. Default .. |
--format <FORMAT> |
auto, human, agent, json, sarif or markdown. See Output Formats & Exit Codes. |
--changed |
Only source files, workflow files and Dockerfiles in the changed set are scanned. See Paths, Excludes & Changed Scope. |
--since <REF> |
Base ref for --changed. |
--no-cache |
Do not write .codeknife/. |
--max-items <N> |
Limit items in --format agent output. |
--strict |
No effect on this blade. |
codeknife.toml key |
Effect |
|---|---|
[blades] sec |
Default true. When false, codeknife check (and anything that runs the static suite) skips this blade. codeknife sec still runs. |
exclude |
Removes source files from the scan. Does not affect workflow or Dockerfile discovery. |
Findings that match an entry in codeknife.baseline are suppressed and counted in a note. See Ratchet Baseline.
What it does not attempt
Section titled “What it does not attempt”- No data flow across functions or files, no type information, and no framework model beyond the names listed on this page.
- No checks for Terraform, Kubernetes manifests, Helm charts, Compose files, or CI systems other than GitHub Actions.
- No secret scanning of non-source files (
.env, YAML, JSON, Markdown) and no scanning of git history. - No dependency vulnerability database lookup. For dependency risks see Dependencies.
- Every finding is a pattern match and can be a false positive or miss a real issue.
Exit codes
Section titled “Exit codes”| Code | When |
|---|---|
0 |
No error or warning findings (info findings alone still pass). |
1 |
At least one error or warning finding remains after baseline filtering. |
The demo above exited with 1. A --changed run with no changed files printed status=pass and exited with 0. See Output Formats & Exit Codes for the full exit code reference.
Also available via
Section titled “Also available via”codeknife checkruns this blade as part of the gate when[blades] secistrue. See The Check Gate.- The MCP tool
codeknife_checkruns the same static suite, including this blade. See MCP Tools.