Repository navigation
This is a security release for users of the v1 API (altcha-lib/v1). It closes a bypass of the salt-splicing fix: a solved v1 challenge could be verified after its expiry, and signed salt params could be hidden from extractParams. Upgrading is recommended if you create v1 challenges with params and expires.
The v2 API (the default altcha-lib export) and the framework plugins are not affected.
Security fix
Expiry bypass and param hiding in v1 verifySolution. The salt-splicing fix put an & between the salt and the number so that the boundary between them could not move. That only holds if number is a number, but verifySolution did not check its type. A client could cut the signed salt at an earlier & and send the rest of it inside a string number. The verifier added the & back, so the hashed bytes were the same as the signed ones and the challenge and signature matched. The expiry check and extractParams only saw the shortened salt.
createChallenge adds expires after your custom params. Cutting the salt before &expires= removed the expiry, so an expired challenge verified:
signed salt: <hex>?user=alice&action=login&expires=1795064482&
submitted salt: <hex>?user=alice&action=login
submitted number: "expires=1795064482&4242"
The same trick hid any trailing signed param. This matters if your app binds a challenge to something through params and treats a missing param as "no restriction".
Changing a param value is still rejected; the signature check itself was not broken.
Who is affected: servers that create v1 challenges with custom params (or a salt that already carries a query string) together with expires, and that do not track used challenges. A challenge with only expires is not affected, because there is no earlier & to cut at.
Fix: verifySolution now returns false when number is not an integer. It checks this before the expiry check and before hashing, for both object and base64 payloads. createChallenge throws when you pass it a number that is not an integer.
Upgrade notes
- No changes are needed for normal use. The widget always submits an integer
number, and challenges created with v2.9.0 still verify. verifySolutionnow rejects floats such as4242.0and numeric strings such as"4242".createChallenge({ number })throwsnumber must be an integerfor a value that is not an integer.- If you can't upgrade right away, reject payloads whose
numberfailsNumber.isIntegerbefore callingverifySolution, or record used challenges so that a solved one can't be replayed.