Numeric trust boundary

From thejefflarson/soundcheck · View interactive version

Numeric trust boundary is an AI agent skill from the GitHub repository thejefflarson/soundcheck. Detects untrusted numeric input that flows through a conversion, cast, or parser into a length, size, index, or authorization comparison without bounds-checking the post-conversion value. Use when writing or modifying code that calls atoi/strtol/parseInt/strconv.Atoi on user-supplied or network-supp

How to use this skill

Skill file

Numeric Trust Boundary (CWE-190, CWE-194, CWE-704, CWE-20)

What this checks

Plain numeric-conversion bugs (parser returns zero on garbage, divide-by-zero,

float equality) are correctness issues that standard linters catch. This skill

targets the security subset: an untrusted integer (from a string parser, a

wire-protocol length field, a JSON number) that flows into a length, size,

index, or permission sink without a bounds check on the post-conversion value.

Local pattern only — conversion within a function or two of the sink.

Vulnerable patterns

Fix immediately

Flag the vulnerable code and explain the risk. Then suggest a fix that establishes

these properties. Translate each property into the audited file's language and

standard library — do not import an example from a different stack.

  1. Use a parser that signals failure out-of-band, distinct from a valid zero. Check the failure indicator (errno, exception, error return, optional) before consuming the value.
  2. Bound the parsed value against the sink's required range after conversion to the sink's type. A check performed on the original narrow type does not protect a wider sink.
  3. Reject negatives explicitly when the sink is an unsigned length, size, or index. Do not rely on the comparison operator to do this — signed-to-unsigned promotion flips the meaning.
  4. Guard multiplications used to compute lengths against wraparound before the multiplication is performed. Compare the operands against the type's maximum divided by the other operand.
  5. Treat any attacker-controlled divisor or modulus as potentially zero and reject before the divide.

Verification

After rewriting, confirm:

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.