CtrlK
BlogDocsLog inGet started
Tessl Logo
SkillPublic

audit-bugs

Audit of direct bugs and logic errors: incorrect conditions, off-by-one, null dereference, forgotten await, unreachable code, type coercion, argument mutation. Run on /audit-bugs.

Quality

77%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

Fix and improve this skill with Tessl

tessl review fix ./skills/audit-bugs/SKILL.md
SKILL.md
Quality
Evals
Security

Relevance Rule

Applies to any code with business logic. Skip only autogenerated files (migrations, protobuf-generated, build output) and purely declarative configs (JSON, YAML without logic).

Runtime Detection & Stack Profile

This audit is stack-agnostic: the checks are framed neutrally, and the specifics (tools, idioms, anti-patterns, examples) come from the stack profile.

  1. Profile passed in context? If the /audit orchestrator passed runtime=<id> and/or the profile contents, use it and skip steps 2–3.

  2. Otherwise, detect EXACTLY ONE runtime for this directory:

    if   [ -f package.json ]; then echo "runtime=node"
    elif [ -f go.mod ]; then echo "runtime=go"
    elif [ -f pyproject.toml ] || [ -f requirements.txt ] || [ -f setup.py ]; then echo "runtime=python"
    elif [ -f Cargo.toml ]; then echo "runtime=rust"
    elif [ -f pom.xml ] || ls build.gradle* settings.gradle* >/dev/null 2>&1; then echo "runtime=java"
    else echo "runtime=generic"; fi

    One run = one runtime; do not mix backend and frontend. If several markers are found (monorepo), pick the one matching the current scope / files under analysis and record the choice in the Audit Coverage section.

  3. Load the profile via Read: ./skills/audit/stacks/<runtime>.md (fallback ./skills/audit/stacks/_generic.md if the file is not found).

Then use the profile:

  • Tools — from the profile's "Tooling by category" section (the "Tooling Support" section below references categories, not commands).
  • PASS expectations — from "Idioms"; FAIL wording — from "Anti-patterns".
  • Targeted hints — from "Check-ID hints" by the prefix BUG-.
  • If the profile is tier: general or runtime=generic, mark stack-specific findings without unambiguous evidence as 🔍 UNVERIFIED rather than ❌ FAIL. Mark checks whose mechanism is absent in the runtime as N/A.

Severity Guide

SeverityAssignment criterion
🔴 CriticalRCE, auth bypass, data corruption, irreversible financial risk
🟠 Highproduction outage, privilege escalation, data leak
🟡 Mediumperformance or maintainability degradation without an immediate outage
🟢 Lowstyle, readability, minor convention violation

Rule: severity = impact × exploitability × blast radius. The same pattern → the same severity across audits.

Checklist

Check IDCheck
BUG-01Type conversions are safe: parsing errors are handled, no unsafe casts
BUG-02Async/concurrent calls are awaited correctly, the result is not lost
BUG-03Null-safety is observed — property access is guarded against undefined/null
BUG-04Functions do not mutate their input arguments (sort, splice, object spread)
BUG-05Exhaustive handling — all enum/union branches are handled
BUG-06Mathematical guard conditions (division by zero, boundary values)
BUG-07Off-by-one: range boundaries are correct (< vs <=, array indices, slice)
BUG-08Float comparison does not use === for equality (epsilon or toFixed is used)
BUG-09Date/time is stored and processed in UTC, not local time
BUG-10RegExp with user input has no catastrophic backtracking (ReDoS)

Verification Rules

  1. Checklist only: evaluate ONLY the checks above. Do not add new ones.
  2. Explicit verification = PASS: assign ✅ PASS only if you explicitly verified the mechanism (found the schema, config, guard) and confirmed there is no violation — state exactly what was checked.
  3. No evidence = UNVERIFIED: if you cannot point to a file:line for either a violation or a confirmation, assign 🔍 UNVERIFIED.
  4. Baseline takes priority: if the check_id is in docs/audit-baseline.yml → ⏸ ACCEPTED.
  5. Only 🔴/🟠 FAILs require a solution: 🟡/🟢 — a solution is optional.

Evidence Quality Rules

Every ❌ FAIL must include:

  • An exact file:line
  • A minimal code snippet (1–3 lines)
  • Causal chain: why this specific violation → what risk it creates

Not allowed:

  • Assuming runtime behavior without evidence in the code
  • Inferring the prod configuration from the dev configuration
  • Assuming middleware is absent without checking the entire router chain
  • If a conclusion rests on an assumption — only 🔍 UNVERIFIED

Language Rule

Audit results must be written in plain, clear language. Avoid complex terms, jargon, and abstract concepts unless necessary. Common technical terms (Docker, HTTP, API, JSON, URL) are fine. Describe problems so they are understandable to a developer of any level, not only a narrow specialist in the area.

Baseline

Before analysis:

if [ ! -f ./docs/audit-baseline.yml ]; then
  mkdir -p ./docs
  cp ./skills/audit/audit-baseline-template.yml ./docs/audit-baseline.yml 2>/dev/null || \
    printf "accepted: []\n" > ./docs/audit-baseline.yml
fi
cat ./docs/audit-baseline.yml

Analysis Context

The examples below are illustrative (Node/TS). Take the specifics of the current runtime from the loaded profile (stacks/<runtime>.md, the Idioms/Anti-patterns/Check-ID hints sections).

BUG-01 — Type conversions are safe:

  • Parsing a string to a number without handling the error/result
  • An unsafe cast without checking that it succeeded
  • Implicit type coercion with an unexpected result
  • Comparing values of different types with implicit coercion
  • In Go this is an ignored strconv error (v, _ := strconv.Atoi(...)) or a type assertion x.(T) without comma-ok; radix/== coercion is N/A when there is no string parsing (see the profile's Check-ID hints).

BUG-02 — Async/concurrent calls are awaited correctly:

  • An async call is started, but its result/error is not awaited
  • A condition on an unwrapped deferred result (always truthy)
  • A concurrent call is lost because it is not synchronized
  • In Node: await inside forEach (the iteration does not wait for the promises), if (asyncFn()) instead of if (await asyncFn()), an async call without await, a Promise without error handling. In Go there is no forEach syntax (N/A); the analogous risk is in CON-01.

BUG-03 — Null-safety is observed:

  • Property access without a null/undefined check
  • A missing optional chain (obj.a.b where obj.a may be undefined)
  • Destructuring without a default value when the value may be undefined
  • In Go: dereferencing a nil pointer/interface; accessing a nil map; writing to a nil map = panic; map access without v, ok := m[k]

BUG-04 — Functions do not mutate their input arguments:

  • Array.sort() on a passed array without a preceding .slice()
  • Array.splice() mutates the original array argument
  • Directly assigning properties of an object argument instead of creating a copy via spread
  • In Go: sort.Slice mutates the passed slice in place; writing to a slice/map argument is visible to the caller

BUG-05 — Exhaustive handling:

  • switch without a default on an enum value — a new enum value will pass unnoticed
  • A union type without handling all variants in an if/else chain
  • Missing never-check for an exhaustive TypeScript switch
  • In Go: a switch over a value without a default branch

BUG-06 — Mathematical guard conditions:

  • Division by zero without a guard check on the denominator
  • Number() / parseInt() without checking the result for NaN before use
  • Boundary values are not checked (negative index, empty array)

BUG-07 — Off-by-one:

  • for (i = 0; i <= arr.length; i++) — going out of array bounds
  • slice(0, n) / slice(0, n-1) — losing or duplicating the last element
  • Comparing index < arr.length - 1 where index < arr.length is needed
  • Pagination: offset * limit vs (offset - 1) * limit for 1-based pages

BUG-08 — Float comparison:

  • a === b where a and b are results of float arithmetic (0.1 + 0.2 !== 0.3)
  • Comparing monetary amounts via float instead of integer cents / BigDecimal
  • The condition if (parseFloat(x) === 1.0) instead of Math.abs(x - 1.0) < epsilon
  • In Go: comparing float64 via ==; money — in int64 (cents) or shopspring/decimal

BUG-09 — Date/time in UTC:

  • new Date() without explicit UTC handling — the result depends on the server timezone
  • Comparing dates via toLocaleDateString() — depends on the locale
  • Storing a timestamp as a local datetime string instead of ISO 8601 with Z
  • new Date('2024-01-01') is parsed as UTC, new Date('2024-01-01 00:00') as local
  • In Go: time.Now() instead of time.Now().UTC() — the result depends on the server's time zone

BUG-10 — ReDoS:

  • new RegExp(userInput) — the user controls the regular expression
  • Nested quantifiers over overlapping classes: (a+)+, (a*)*, ([a-zA-Z]+\s?)+
  • Test: 'a'.repeat(50000) + 'x' against a suspicious regex hangs the event loop
  • Especially dangerous in middleware (auth, routing), where the regex is applied to every request
  • In Go, the regexp engine (RE2) has no backtracking → ReDoS is practically impossible; mark N/A or Low (see the profile)

Boundary With Other Audits

  • Error handling (timeout, retry, circuit breaker) → audit-errors
  • Race conditions, transactions → audit-concurrency
  • Input validation → audit-validation
  • Security (injection, XSS) → audit-owasp

Output Format

Check IDCheckStatusConfidenceEvidenceSolutionFixed
BUG-01Type conversions are safe: parsing errors are handled, no unsafe casts✅ PASSHighsrc/ — parseInt always with a radix——
BUG-03Null-safety is observed — property access is guarded against undefined/null❌ FAIL 🟠Highservices/order.ts:551. Add an optional chain: user?.address?.city \ 2. Add a guard check before access \ 3. Use nullish coalescing with a defaultNo
BUG-05Exhaustive handling — all enum/union branches are handled⏸ ACCEPTEDMediumhandlers/event.ts:23In baseline: exhaustive check via TypeScript never—

Statuses: ✅ PASS / ❌ FAIL 🔴 / ❌ FAIL 🟠 / ❌ FAIL 🟡 / ❌ FAIL 🟢 / ⏸ ACCEPTED / 🔍 UNVERIFIED

Confidence: High — checked several key files, the pattern is obvious / Medium — checked selectively, the pattern is likely / Low — limited context, full certainty is impossible

For ❌ FAIL: exactly 3 solution options, separated by \\, with option 1 in bold.

Fixed: FAIL → No (the developer changes it to ✅ Yes manually after the fix). PASS / ACCEPTED / UNVERIFIED → —.

Solution requirements:

  • Mutually exclusive (not rephrasings of the same thing)
  • Match the project's current stack (do not propose switching frameworks)
  • Do not require rewriting the whole system — realistic migration cost
  • Option 3 may be "keep it, document the reason" if there is justification

At the end of the report, add a coverage section:

## Audit Coverage
Checked: src/module1/**, src/module2/**
Skipped: scripts/**, migrations/**, tests/**
Files checked: N | Skipped: N

If everything is PASS, output: ✅ No clear logic errors found.

Saving Results

  1. Find the session folder:
    ls -dt ./docs/audits/[0-9]*/ 2>/dev/null | head -1 | sed 's|/$||'
    If empty, create it: mkdir -p ./docs/audits/$(date +"%Y-%m-%d_%H-%M")
  2. Save via Write: <AUDIT_DIR>/audit-bugs.md
# Audit Report: Bugs & Logic Errors — <YYYY-MM-DD HH:MM>
<table>
Repository

uxname/kodu

Path

skills/audit-bugs/SKILL.md

Last updated
First committed

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.