You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e9cfa18
Browse filesBrowse the repository at this point in the historyBrowse files
fix: Close integer validation bypass and query parser differential (#109)
* fix: Close integer validation bypass and query parser differential
Two validation bypasses surfaced in a security review of the request
pipeline:
- checkInteger narrowed numbers with longValue() before bound-checking,
so a fractional Double (4.9) satisfied `type: integer` and a value above
2^64 wrapped past a declared maximum. It now rejects non-integral numbers
and compares the full magnitude, keeping an allocation-free long path for
the common case and falling back to BigDecimal/BigInteger otherwise.
- Query parameters were validated from the already-decoded URI.getQuery()
but delivered to handlers from getRawQuery(), so an encoded separator
(%26) could smuggle a value past a schema constraint. Both paths now
share QueryParams.parse over the raw query, so the value validated is the
value the handler receives.
Adds exploit tests asserting both are rejected.
* refactor: Simplify out-of-range integer check and cover new branches
The SonarCloud new-code coverage gate failed on PR #109: extracting the
bound checks into checkIntegerBounds turned the exclusive-bound and
beyond-long paths into "new" lines that no test exercised.
- Simplify the beyond-long branch to delegate to the long path when the
value fits, and otherwise reject against whichever bound lies on its side
(or an int32/int64 format), collapsing the per-bound arms.
- Add tests for exclusive bounds, values above 2^53 that still fit in a
long, every beyond-long rejection path, and QueryParams edge cases
(empty pairs, keys without '=', encoded separators).
* fix: Drop float-equality check that failed the reliability gate
SonarCloud flagged S1244 (floating-point equality) on the `d == Math.rint(d)`
integrality test in checkInteger's fast double path, dropping New Code
reliability to C.
Remove the double fast path entirely: doubles reaching an integer schema are
either fractional (rejected) or rare integral doubles, both handled correctly
by converting through BigDecimal.toBigIntegerExact(). Integral wrappers keep
the allocation-free long path, so the common case is unaffected.
0 commit comments