fix: cap slot range in xmss_key_gen to prevent unbounded memory allocation#163
Closed
jiayaoqijia wants to merge 1 commit intoleanEthereum:mainfrom
Closed
fix: cap slot range in xmss_key_gen to prevent unbounded memory allocation#163jiayaoqijia wants to merge 1 commit intoleanEthereum:mainfrom
jiayaoqijia wants to merge 1 commit intoleanEthereum:mainfrom
Conversation
Collaborator
|
Hi, it's important to allow anyone to use a lifetime arbitrarily big (up to 2^32). Having to switch keys, even once a year, is extremely anoying in practice. With a better implem, we could do it on a constrained memory. But that's not within the current priorities. |
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.
Fixes #133.
xmss_key_genpreviously accepted any(slot_start, slot_end)range up to2^32slots, which could allocate tens of GiB for the Merkle tree (each leaf requires a WOTS key generation + hash). A malicious or accidental call with a large range would cause OOM.This adds a
MAX_SLOT_RANGEcap of1 << 20(~1M slots, ~32 MiB tree), returning a newXmssKeyGenError::RangeTooLargeerror for ranges exceeding this limit. This cap is generous for practical use — with 12-second slots, 1M slots covers ~139 days of validator operation.Changes:
RangeTooLargevariant toXmssKeyGenErrorslot_start > slot_endvalidation