bug: Encrypt-then-MAC violation in scryptdec_buf — outlen set before HMAC verification (#702) - #411
Closed
lushan888 wants to merge 2 commits into
Closed
bug: Encrypt-then-MAC violation in scryptdec_buf — outlen set before HMAC verification (#702)#411lushan888 wants to merge 2 commits into
lushan888 wants to merge 2 commits into
Conversation
added 2 commits
July 10, 2026 17:41
Bounty #702 (): scryptdec_buf() set *outlen before HMAC verification. An attacker who tampers with encrypted data can cause unauthenticated plaintext to be exposed to the caller even when the function returns an error. Fix: Move *outlen assignment after HMAC verification, so callers only see decrypted plaintext after authentication succeeds. Also early-return with insecure_memzero on HMAC failure instead of falling through to the err1 label.
…turns NULL (#701)
Bounty #701 (): display_params() passes humansize() result directly to
fprintf("%s") without NULL check. On macOS/BSD this causes SIGSEGV crash.
Fix: Add ternary guard "?: (unknown)" for both human_memlimit and
human_mem_minimum before passing to fprintf.
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for Bug Bounty #702 ($50)
Vulnerability
scryptdec_buf()decrypts ciphertext intooutbufand sets*outlenbefore verifying the HMAC signature. This violates the Encrypt-then-MAC principle. An attacker who tampers with encrypted data can cause unauthenticated plaintext to be exposed to the caller, even when the function ultimately returns an error.Fix
*outlen = inbuflen - 128to after HMAC verification succeedsreturn (SCRYPT_EINVAL)withinsecure_memzeroinstead ofgoto err1Verification
Wallet (Base): 0xaa9e4971e0973065513b18dEF9eC06Eb1F39D7A2