Repository navigation
fix(security): guard enrollment_weight and epoch_weight_to_units against non-finite weights (#8619) - #8621
Open
thinhnx128 wants to merge 1 commit into
Conversation
…nst non-finite and non-coercible weights (Scottcjn#8619) - Enforce fail-closed 0.0 return in sybil_guard.enrollment_weight() for None, booleans, non-coercible strings, negative values, and non-finite floats (NaN, +inf, -inf). - Catch OverflowError in sybil_guard.hold_for_settlement() when converting escrowed weights. - Guard epoch_weight_to_units() against non-finite Decimal values and clamp to MAX_EPOCH_WEIGHT_UNITS. - Add regression test suite node/tests/test_sybil_guard_nonfinite_8619.py. Fixes Scottcjn#8619
Contributor
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
Open
3 tasks done
This branch has not been deployed
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.
Summary
Fixes #8619
This PR hardens the sybil-guard enrollment and settlement weight conversion chain against non-finite (
NaN,+inf,-inf), boolean, negative, and non-coercible (None,"N/A") weight inputs:node/sybil_guard.py(enrollment_weight):boolvalues (isinstance(hw_weight, bool)), non-coercible inputs (TypeError,ValueError), negative numbers (weight < 0.0), and non-finite floats (not math.isfinite(weight)) by failing closed to0.0instead of returning the raw uncapped input or propagatingNaN/infinto grandfathered/trusted branches.node/sybil_guard.py(hold_for_settlement):OverflowError(raised byint(float("inf"))) alongsideTypeErrorandValueErrorso settlement hold recording strictly honors its "Never raises" contract.node/rustchain_v2_integrated_v2.2.1_rip200.py(epoch_weight_to_units):bool,None, and non-finiteDecimalvalues (not value.is_finite()) before integer quantization, preventing unhandleddecimal.InvalidOperation/OverflowErrorHTTP 500 crashes on the enrollment path, and clamps toMAX_EPOCH_WEIGHT_UNITS.node/tests/test_sybil_guard_nonfinite_8619.py):None,"N/A",float("nan"),float("inf"),float("-inf"), negative weights, booleans, andhold_for_settlementescrow resilience across all probation states.