Rule Reference

All 159 review rules organized by layer. Generated from the KERN registry.

Base Rules

14 rules that apply to every TypeScript and Python file. These catch universal code-quality problems regardless of framework or target.

  • floating-promise[error]Unresolved async operation — missing await/void/return
  • state-mutation[error]Illegal state mutation outside designated setter
  • empty-catch[warning]Catch block swallows exception silently
  • machine-gap[warning]Unreachable state or missing transition in state machine
  • config-default-mismatch[warning]Config schema default does not match type
  • event-map-mismatch[warning]Event handler type mismatch with event map
  • non-exhaustive-switch[warning]Switch/map missing cases for known variants
  • cognitive-complexity[warning]Function exceeds cognitive complexity threshold
  • template-available[info]Pattern matches a registered KERN template
  • handler-extraction[info]Handler-like pattern could be extracted to KERN
  • memory-leak[error]Event listener added without cleanup
  • unhandled-async[warning]Async function without error handling
  • sync-in-async[warning]Synchronous blocking call inside async function
  • bare-rethrow[warning]Catch rethrows error without adding context

Security Rules — v1

8 rules covering injection, XSS, secrets, and common web security misconfigurations.

  • xss-unsafe-html[error]innerHTML/dangerouslySetInnerHTML with untrusted data
  • hardcoded-secret[error]API key, password, or secret in source code
  • command-injection[error]exec/spawn with user-controlled input
  • no-eval[error]eval() or Function() constructor usage
  • insecure-random[warning]Math.random() used for security-sensitive operations
  • cors-wildcard[warning]CORS wildcard (*) origin allowed
  • helmet-missing[warning]Express app without helmet security headers
  • open-redirect[error]Unvalidated redirect target from user input

Security Rules — v2

6 rules for authentication hardening, CSRF, and cryptographic misuse.

  • jwt-weak-verification[warning]JWT verified without algorithm restriction
  • cookie-hardening[error]Cookie missing secure/httpOnly/sameSite flags
  • csrf-detection[error]State-changing endpoint without CSRF protection
  • csp-strength[warning]Weak Content-Security-Policy headers
  • path-traversal[error]File path from user input without sanitization
  • weak-password-hashing[error]MD5/SHA1 for password hashing instead of bcrypt/argon2

Security Rules — v3

5 rules targeting modern attack vectors including prototype pollution, ReDoS, and LLM prompt injection.

  • regex-dos[warning]Regex vulnerable to catastrophic backtracking (ReDoS)
  • missing-input-validation[warning]User input used without validation
  • prototype-pollution[error]Object.prototype mutation via user-controlled keys
  • information-exposure[error]Stack traces or internal details in error responses
  • prompt-injection[warning]User input concatenated into LLM prompts

Security Rules — v4 (LLM Attack Surface)

10 rules covering the full OWASP LLM01 prompt injection surface — indirect injection, output execution, RAG poisoning, encoding bypasses, and more. No other SAST tool covers this.

  • indirect-prompt-injection[warning]LLM prompt includes data from external/DB sources
  • llm-output-execution[error]LLM-generated code executed without sandboxing
  • system-prompt-leakage[warning]System prompt exposed in error paths or responses
  • rag-poisoning[warning]RAG documents injected without provenance check
  • tool-calling-manipulation[error]Tool/function call parameters from untrusted LLM output
  • encoding-bypass[warning]Base64/unicode encoding used to bypass prompt filters
  • delimiter-injection[warning]Prompt delimiter breakout via user input
  • unsanitized-history[warning]Chat history concatenated without sanitization
  • json-output-manipulation[warning]LLM JSON output used without schema validation
  • missing-output-validation[warning]LLM output consumed without validation

Dead Logic

8 rules that detect code which compiles but can never affect runtime behavior. Often symptoms of refactoring mistakes.

  • identical-conditions[error]Duplicate conditions in if/else chain
  • identical-expressions[error]Same expression on both sides of operator
  • all-identical-branches[error]All branches produce identical code
  • constant-condition[warning]Condition is always true or always false
  • one-iteration-loop[warning]Loop body always exits on first iteration
  • unused-collection[warning]Collection created but never read
  • empty-collection-access[warning]Accessing elements of provably empty collection
  • redundant-jump[info]Unreachable code after return/break/continue

Null Safety

3 rules that catch null/undefined errors before they become runtime crashes.

  • unchecked-find[warning]array.find() result used without null check
  • optional-chain-bang[warning]Optional chain (?) immediately negated by non-null assertion (!)
  • unchecked-cast[warning]Unsafe type assertion without runtime guard

React Rules

7 rules active when target is nextjs, tailwind, web, native, or ink. Catch hook misuse and rendering pitfalls.

  • async-effect[error]Async function passed directly to useEffect
  • render-side-effect[error]Side effect (fetch, mutation) during render
  • unstable-key[warning]Non-stable key prop (index, random, Date.now)
  • stale-closure[warning]Stale variable captured in hook closure
  • state-explosion[warning]Excessive useState calls — consider useReducer
  • hook-order[error]React hook called inside condition or loop
  • effect-self-update-loop[error]useEffect updates its own dependency — infinite loop

Next.js Rules

3 rules specific to the Next.js App Router model.

  • server-hook[error]React hook used in Server Component
  • hydration-mismatch[warning]Nondeterministic expression causes SSR/client mismatch
  • missing-use-client[warning]Event handler in Server Component — needs use client

Vue Rules

4 rules active when target is vue or nuxt.

  • missing-ref-value[warning]ref() used without .value in script setup
  • missing-onUnmounted[error]watch/addEventListener without onUnmounted cleanup
  • setup-side-effect[warning]Top-level await in setup without onMounted
  • reactive-destructure[warning]Destructuring reactive() loses reactivity

Nuxt Rules

3 rules specific to Nuxt 3.

  • missing-ssr-guard[error]Browser global accessed without SSR guard
  • nuxt-direct-fetch[warning]Raw fetch() instead of $fetch/useFetch in Nuxt component
  • server-route-leak[error]Server API route may expose sensitive fields

Express Rules

5 rules for Express.js server applications.

  • unvalidated-input[error]req.body/params/query used without validation
  • missing-error-middleware[warning]Express app without error-handling middleware
  • sync-in-handler[warning]Blocking I/O in request handler
  • double-response[error]Response sent twice without early return
  • express-missing-next[error]Middleware accepts next but never calls it — request hangs

FastAPI Rules

5 rules for Python FastAPI applications.

  • fastapi-missing-response-model[warning]Endpoint without response_model — undocumented response
  • fastapi-blocking-sync-route[warning]Blocking call in async route stalls event loop
  • fastapi-shared-state[error]Route mutates global/module state — race condition
  • fastapi-broad-except[warning]Broad except without re-raising HTTPException
  • fastapi-broad-cors[warning]CORSMiddleware with allow_origins=["*"] — overly permissive

CLI Rules

4 rules for Commander.js CLI applications.

  • cli-missing-shebang[warning]Commander CLI entrypoint missing #!/usr/bin/env node
  • cli-missing-parse[error]Command instance created without parse()/parseAsync()
  • cli-async-parse-sync[error]Async Commander action paired with parse() instead of parseAsync()
  • cli-process-exit-in-action[warning]Commander action handler calls process.exit() directly

Terminal Rules

7 rules for terminal UI applications.

  • terminal-missing-tty-guard[warning]Interactive terminal code runs without TTY guard
  • terminal-raw-mode-no-restore[error]stdin raw mode enabled without restore on exit
  • terminal-readline-no-close[warning]Readline interface never closed — process can hang
  • terminal-alt-screen-no-restore[warning]Alternate screen entered without restore on exit
  • terminal-missing-signal-handler[warning]No SIGINT/SIGTERM handler for cleanup
  • terminal-cursor-not-restored[warning]Cursor hidden without restore on exit
  • terminal-unthrottled-render[warning]Render loop with excessive refresh rate

Ink Rules

6 rules for Ink (React terminal UI) applications. Active on top of React rules.

  • ink-console-output[warning]console.* output corrupts Ink terminal rendering
  • ink-direct-stdout[error]Direct stdout/stderr writes bypass Ink renderer
  • ink-process-exit[warning]process.exit() used instead of useApp().exit()
  • ink-stdin-bypass[warning]Raw stdin/readline listeners bypass Ink useInput()
  • ink-uncleared-interval[warning]setInterval without cleanup in Ink component
  • ink-missing-error-boundary[warning]Ink render() without error handling

Concept Rules

5 language-agnostic rules that operate on semantic concepts extracted from the KERN IR. Always active.

  • boundary-mutation[warning]Global/shared state mutation across boundaries
  • ignored-error[warning]Caught exception silently ignored
  • illegal-dependency[warning]Module imports from a disallowed layer or boundary
  • unguarded-effect[warning]Network/DB effect without auth/validation guard
  • unrecovered-effect[warning]Network/DB effect without error recovery

Severity levels

Every finding is assigned one of three severity levels. CI enforcement via --enforce fails on any error-level finding by default.

LevelMeaningExamples
errorMust fix. Security vulnerability, data loss risk, or guaranteed runtime failure.command-injection, llm-output-execution, floating-promise, hook-order
warningShould fix. Code smell, potential bug, or degraded maintainability.cognitive-complexity, stale-closure, prompt-injection, constant-condition
infoInformational. Extraction opportunity or low-risk observation.template-available, handler-extraction, redundant-jump

Confidence scores

Each finding includes a confidence score from 0 to 1 indicating how certain the analyzer is that the finding is a true positive.

  • 0.9 – 1.0 — High confidence. Pattern matched exactly with full taint-tracking or type evidence.
  • 0.7 – 0.89 — Medium confidence. Pattern matched but some context is ambiguous (e.g., dynamic import, indirect call).
  • 0.5 – 0.69 — Low confidence. Heuristic match that may be a false positive. Review manually.
  • Below 0.5 — Suppressed by default. Enable with --min-confidence=0 to see all findings.

Filter findings by confidence:

# Only show findings with >= 80% confidence
kern review src/ --recursive --min-confidence=0.8