This release fixes the widget's proof-of-work code to match the fixed altcha-lib (v2.6.0). It fixes a key-derivation mismatch that caused valid solutions to be rejected, and a verification bypass in altcha/lib. Upgrading is recommended.
Security
verifySolutionbypass (altcha/lib). If the challenge had nokeySignature, or the verifier passed nohmacKeySignatureSecret,verifySolutionre-derived the key from the submitted counter but never checked it against the signedkeyPrefix. Any counter, for example0, together with its derived key verified without doing any work. The derived key must now also matchkeyPrefix. altcha-lib fixed this ine2a6daf(v2.3.2), but the fix never reached the widget's copy of this code until now.- Obfuscation plugin key exposure.
obfuscate()used the publishedkeyPrefixas its AES key. IfkeyPrefixLengthwas overridden, part or all of that key could be published. It now encrypts with the full derived key and publishes only half of it. With default options the output format is the same, so existing obfuscated strings still decode.
Fixes
- SHA key derivation. Each round now hashes the full digest from the previous round, and the result is cut to
keyLengthonce at the end. This is whataltcha-liband all server ports do. Before, the widget's solutions were rejected (invalidSolution) forSHA-384orSHA-512withcost > 1, and for anySHA-*challenge withkeyLengthbelow the digest size andcost > 1. The default (SHA-256,keyLength32) was not affected. - PBKDF2 key length.
PBKDF2/*now supports anykeyLength. Before, only 16, 24 and 32 worked. - Algorithm names. The built-in
deriveKeyfunctions reject names they don't support. Before, unknownPBKDF2/*names fell back to SHA-256, andSCRYPTandARGON2IDignored the name. Each function now accepts only its own exact names:SHA-256,SHA-384,SHA-512PBKDF2/SHA-256,PBKDF2/SHA-384,PBKDF2/SHA-512SCRYPTARGON2ID
- Input validation (
altcha/lib):createChallengecheckscost,keyLength,memoryCost,parallelism,counter,counterMode,expiresAt,hmacAlgorithmand the secrets.createChallengealso checks the key prefix.keyPrefixmust be a non-empty hex string, and it is lowercased before signing.keyPrefixLengthmust be a positive integer smaller than the derived key.verifySolutionreturnsinvalidSolutionfor a malformedderivedKey(it must be lowercase hex) orcounter(it must be an integer the counter mode can encode), instead of throwing or coercing the value.solveChallengethrows immediately on an invalidkeyPrefixinstead of running until the timeout.hexToBufferrejects non-hex characters.- Canonical JSON keeps a
__proto__key, so an injected key now breaks the signature. verifyServerSignature:- checks
payload.algorithmagainstSHA-1,SHA-256,SHA-384andSHA-512; - requires
hmacSecret; - returns
invalidSignaturewhen the signature is missing; - checks expiry against the current time without rounding it down to whole seconds, so the up to 1 second of grace is gone.
- checks
Upgrade notes
Challenges that are already in flight with these settings will not verify across the upgrade.
- Calls that used to work and now throw:
verifySolutionwithouthmacSignatureSecret, or with an empty one.createChallengewithhmacSignatureSecret: ''ornull.createChallengewithhmacKeySignatureSecretbut nohmacSignatureSecret.createChallengewith an empty or non-hexkeyPrefix.createChallengewith akeyPrefixLengththat is not smaller than the derived key.- Any built-in
deriveKeywith an unsupported algorithm name.