Przejdź do treści
Biblioteka skilli
Bezpieczeństwo · Przegląd i audyt

numeric-trust-boundary

/numeric-trust-boundary

Wykrywa w kodzie nieufne dane liczbowe, które po konwersji lub rzutowaniu trafiają do sprawdzania długości, indeksu lub uprawnień bez ponownej kontroli zakresu.

Repozytorium
soundcheck ↗
Licencja
MIT
Ostatnia zmiana repozytorium
30.07.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
4
Przestarzałość

Brak sygnałów. Repozytorium zmienione 30.07.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Wykrywa w kodzie nieufne dane liczbowe, które po konwersji lub rzutowaniu trafiają do sprawdzania długości, indeksu lub uprawnień bez ponownej kontroli zakresu.

Oryginalny opis (EN)

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-supplied input, casts between signed and unsigned integer types, narrows an integer width before a bounds check, or uses an untrusted integer as an allocation size, array index, file offset, length argument to memcpy, or comparison gate for authorization or permission decisions.

Jak działa

  1. What this checks
  2. Vulnerable patterns
  3. Fix immediately
  4. Verification
  5. References
Sekcje z nagłówków SKILL.md, w oryginale · 52 linii, 547 słów
Podgląd SKILL.md
---
name: numeric-trust-boundary
description: 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-supplied input, casts between signed and unsigned integer types, narrows an integer width before a bounds check, or uses an untrusted integer as an allocation size, array index, file offset, length argument to memcpy, or comparison gate for authorization or permission decisions.
---

# 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

- Sign-extension when a narrow signed value is cast into a width-or-size type — a byte of `0xFF` becomes a huge unsigned length.
- A string-to-integer parser whose error indicator is the same value as legitimate zero, used as an authorization or identity key without checking the parse-failure flag.
- Width truncation inside a bounds check — the narrowed value passes the check, but the full-width value is used at the sink.
- Signed/unsigned comparison where a negative value compares as smaller-than the bound, then gets re-promoted to a giant unsigned at the sink.
- Attacker-controlled divisor with no zero check.
- Length arithmetic (`count * sizeof(...)`) on attacker-controlled values that wraps around to a small total while the unwrapped value is later used at the sink.
- Array or buffer indexing where the parsed value is never bounded against the actual length.

## 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:

- [ ] Every conversion of untrusted input checks for parser failure via an out-of-band signal (errno, exception, error return) — a zero return is not treated as a valid integer
- [ ] Every value used as an allocation size, array index, or length argument is checked against a bound *after* conversion to the type the sink expects
- [ ] No bounds check uses a narrower type than the value being checked at the sink
- [ ] Signed/unsigned comparisons are avoided, or both sides are explicitly converted to the same type before comparison
- [ ] Length arithmetic on attacker-controlled values is guarded against wraparound before the multiplication
- [ ] Attacker-controlled divisors and modulus operands are checked against zero

## References

- CWE-190 ([Integer Overflow or Wraparound](https://cwe.mitre.org/data/definitions/190.html))
- CWE-194 ([Unexpected Sign Extension](https://cwe.mitre.org/data/definitions/194.html))
- CWE-704 ([Incorrect Type Conversion or Cast](https://cwe.mitre.org/data/definitions/704.html))
- CWE-20 ([Improper Input Validation](https://cwe.mitre.org/data/definitions/20.html))

Wersje

W bazie nie ma innych skilli o nazwie numeric-trust-boundary.

Migawka bazy z 28.10.2026 · wersja paczki b3bc03905f6b (skrót SHA-256 całej paczki)

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90multi-agent-trust
    Wykrywa wywołania między agentami bez uwierzytelnienia, autoryzacji i ograniczeń uprawnień podagentów.
  • 100security-hardening
    Audytuje zmianę lub system pod kątem osiągalnych podatności, śledząc niezaufane dane wejściowe do ujść i sprawdzając autoryzację na każdej nowej ścieżce, przed wystawieniem w internecie.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.