[SECURITY] Non-finite and garbage weights pass the sybil-guard money chain — enrollment_weight has no isfinite guard and epoch_weight_to_units raises on NaN/inf
Maintainers usually reply within 10 days
@thinhnx128 is already working on this.
Since Nov 6, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Read node/sybil_guard.py lines 385-419, node/rustchain_v2_integrated_v2.2.1_rip200.py lines 1539-1548, and the enrollment and settlement call sites listed in the issue. Trace how invalid weights reach unit conversion and the settlement cap, then add regression coverage for None, strings, NaN, infinity, and very large finite values. Done means these inputs are handled safely through enrollment and settlement without uncaught errors or skipped caps.
Written by the indexing model from the issue text.
Description
Component
Node (rustchain_v2_integrated)
What happened?
Reporter: @elvergon8888
Native RTC wallet: RTC36c07693911c7f3b0a7ede4d2c92a08f32e7edcb
Registered at: https://github.com/Scottcjn/rustchain-bounties/issues/17178
Program: [BOUNTY] Ongoing Bug Bounty Program #71 (rustchain-bounties)
Files affected (main, 2026-11-05):
- node/sybil_guard.py:385-419 (enrollment_weight)
- node/rustchain_v2_integrated_v2.2.1_rip200.py:1539-1548 (epoch_weight_to_units)
- Uncaught call sites: node/rustchain_v2_integrated_v2.2.1_rip200.py:7097, 7115-7119, 7493 (attestation enroll + settlement escrow)
- Settlement cap comparison: node/rustchain_v2_integrated_v2.2.1_rip200.py ~lines 5707-5712
Summary
The money-weight chain between enrollment and settlement has no non-finite guard. Two related defects in the same payment path:
-
enrollment_weight()(node/sybil_guard.py:385-419) documents its contract as "Never raises. Apply the guard ... max() only ... min(weight, PROBATION_WEIGHT_CAP)". The implementation violates it:- any non-coercible
hw_weight(e.g. None, "N/A") takes theexcept (TypeError, ValueError): return hw_weightbranch and returns the RAW, uncapped value to the caller (code lines 398-401); float("nan")/float("inf")parse without exception, and nomath.isfinitecheck follows, so NaN and Inf degrade grandfathered and trusted states to unguarded, uncapped weights (lines 402-419 have no isfinite).
Real call site (node, ~4821-4828):return sybil_guard.enrollment_weight(adjusted, probation_status)whereadjustedfeeds directly into the epoch-enroll weight write.
- any non-coercible
-
epoch_weight_to_units()(node/rustchain_v2_integrated_v2.2.1_rip200.py:1539-1548) is the units converter used by every enroll weight write:Decimal(str(float("nan")))buildsDecimal("NaN"), thenvalue <= 0evaluates False (NaN is not <= 0), so the positive-side path runs andint()raisesdecimal.InvalidOperation— an unhandled 500 on the enroll path (call sites are without try/except: nan/inf mode at node:7095-7110 with branch if/else);Decimal(str(float("inf")))-> OverflowError (same path);- huge-but-finite weights (1e308) turn into 317-digit integer units stored into
epoch_enroll(node:7109), only capped later at settlement (~5707-5712); - the settlement cap check (
if weight > MAX_EPOCH_WEIGHT_UNITS) is a float comparison that evaluates FALSE for NaN — cap skipped for NaN-weighted rows.
Impact (requesting Low/Medium, 5-30 RTC per #71)
- Attacker-influenced temporal metrics reach this chain directly: the module's own docstring acknowledges every temporal metric is "self-reported JSON" (node/sybil_guard.py:2-53). Inflation of
rotation_eval(hw_weight * rotation_eval["active_ratio"], node:7097, 7493) with hostile temporal-profile parameters can push weight to non-finite without any isfinite guard in flight. - Local DoS with reward-path effect: a crashed enrollment (InvalidOperation/OverflowError) leaves an epoch stuck for that miner's enroll write and any hostile wallet can repeat the same crash once per epoch — line 7095-7110 has no try/except wrapper; and
epoch_weight_to_unitshandling before 400 is absent. - Defense-in-depth break in the money path specifically on the units converter and cap-comparison semantics (NaN skips the capped value at settlement —
NaN > MAX_EPOCH_WEIGHT_UNITSis False). - Contract violation on the coin-new-miner gate may allow an unguarded grandfathered miner to attain weights above PROBATION_WEIGHT_CAP without triggering the measurement-binding treatment intended for it (REQUIRE_MEASUREMENT_BINDING_FOR_NEW_PREMIUM=False on line 116 lets trusted-bound miners bypass the cap).
Reproduction (offline, code-exact, Executed locally on cpython-3.14.10 (Termux); PoC code below is verbatim from main)
PoC 1 (sybil_guard.enrollment_weight, guard-contract violations):
- probation + hw_weight=None -> returns None (no cap applied, NOT 0.0)
- probation + hw_weight="N/A" -> returns "N/A" (guard bypass; raw value reaches enroll layer)
- grandfathered + hw_weight=NaN -> returns nan
- trusted + hw_weight=+inf -> returns inf
PoC 2 (epoch_weight_to_units, the units converter on the enroll money path):
- hw_weight=NaN -> decimal.InvalidOperation (unhandled in caller, 500)
- hw_weight=+inf -> OverflowError: cannot convert Infinity to integer
- hw_weight=1e308 -> accepted, 1e317-unit integer stored to epoch_enroll
PoC 3 (cap comparison used at settlement):
- nan > MAX_EPOCH_WEIGHT_UNITS -> False (cap skipped)
Suggested fix
- In
enrollment_weight(node/sybil_guard.py:398-401): replace the raw return with a guarded floor (min(0 or min(cap, weight), cap)semantics mirroring fail-closed decisions elsewhere in the file), and add amath.isfinite(weight)check in the same branch. - In
epoch_weight_to_units(node:1539-1548): reject non-finite weights up front the waypayout_preflight._safe_decimal(node/payout_preflight.py:35-42) already does withamount.is_finite()— same guard the codebase deployed to withdrawal validation in #5728. - Wrap node:7095-7122 (enroll weight write) in try/except and return a canonical 400/503 error consistent with the already-fixed
node/sophia_elya_service.pypaths (#6028) instead of an unhandled exception. - Add
NaN-guardbefore the settle cap comparison at ~5707 so NaN cannot skip the clamp. - Add regression tests exercising non-finite + non-coercible weights through
enrollment_weightandepoch_weight_to_units(same style as #6033's ark).
Duplicates check (verified 2026-11-05 via repo issues search)
#5728 (withdrawals), #6028/#6033 (ELYA /epoch/enroll tickets), #5361 (bridge NaN), #6466/#7879 (SPV bloom size) — all same CLASS on other routes. The attestation-enroll weight chain (node:7095-7122) and the sybil-guard gate itself (node/sybil_guard.py:385-419) remain unpatched on main as of 2026-11-05, demonstrated by the PoC.
Evidence
PoC (all cases verbatim from main; pasted below). Executed locally on Python 3.14.10.
--- PoC code (poc.py, runs as-is; stdlib only) ---
[Full PoC attached as poc.py — verbatim from repo functions + 3 assertion groups]
--- PoC stdout ---
[OK ] C1 probation + hw_weight=None -> None
[OK ] C2 probation + hw_weight=str -> 'N/A'
[OK ] C3 grandfathered + hw_weight=NaN -> nan
[OK ] C4 trusted + hw_weight=+inf -> inf
[RAISED ] C5 hw_weight=NaN -> InvalidOperation: [<class 'decimal.InvalidOperation'>]
[RAISED ] C6 hw_weight=+inf -> OverflowError: cannot convert Infinity to integer
[OK ] C7 hw_weight=1e308 -> 100000000000000000000000...
NaN > MAX_EPOCH_WEIGHT_UNITS -> False (cap SKIPPED)
### Expected behavior
The system should handle non-finite and non-coercible values safely without crashing the node or bypassing the settlement cap.
1) enrollment_weight() should always return a finite float (e.g., 0.0 or capped at PROBATION_WEIGHT_CAP) when receiving None, strings, NaN, or Inf, rather than returning the raw uncapped value.
2) epoch_weight_to_units() should explicitly reject NaN/Inf values (returning 0 or raising a handled ValueError) instead of throwing an unhandled decimal.InvalidOperation or OverflowError that leads to a 500 error.
3) The settlement cap comparison should properly clamp or reject NaN-weighted rows, preventing them from skipping the cap.
[poc.py](https://github.com/user-attachments/files/34458468/poc.py)
### Steps to reproduce
1. Clone the repository at main (v2.2.1).
2. Use the attached poc.py or copy the verbatim functions `enrollment_weight` (sybil_guard.py:385-419) and `epoch_weight_to_units` (rustchain_v2_integrated...py:1539-1548).
3. Execute the functions with non-finite values (NaN, Inf) or non-coercible types (None, "N/A").
4. Observe that enrollment_weight returns the raw uncapped value instead of a safe float.
5. Observe that epoch_weight_to_units raises unhandled InvalidOperation/OverflowError, leading to an HTTP 500 in the enrollment path.
### Version / Commit
main (v2.2.1-rip200)
### Operating System
Other
### Relevant logs
```shell
[OK ] C1 probation + hw_weight=None -> None
[OK ] C2 probation + hw_weight=str -> 'N/A'
[OK ] C3 grandfathered + hw_weight=NaN -> nan
[OK ] C4 trusted + hw_weight=+inf -> inf
[RAISED ] C5 hw_weight=NaN -> InvalidOperation: [<class 'decimal.InvalidOperation'>]
[RAISED ] C6 hw_weight=+inf -> OverflowError: cannot convert Infinity to integer
[OK ] C7 hw_weight=1e308 -> 100000000000000000000000...
NaN > MAX_EPOCH_WEIGHT_UNITS -> False (cap SKIPPED)
- Dominant language
- Python
- Stars
- 850
- Forks
- 589
- Avg merge
- 11d 7h
- Merged PRs (30d)
- 29
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Scottcjn/Rustchain
-
utxo_ledger (reference): failed apply_transaction leaks already-created outputs (supply inflation)Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 10 days
-
SDK CLI prints 0 RTC for canonical /wallet/balance responsesPossibly taken @ArtyormSatori claimed this 37 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Scottcjn/Rustchain#8580 · 4 comments ·
Maintainers usually reply within 10 days
-
utxo_ledger (reference): no coinbase authorization; mempool admits any input-less MINING_REWARDOpen
Difficulty 4/5 3-5 days Newbie friendliness 38/100
Maintainers usually reply within 10 days
-
[Antiquity] Celeron M (Banias/Dothan, 2004) has no brand rule — real vintage silicon falls to x86 default 1.0x while its Pentium M twin earns 1.9xPossibly taken @Limm-web claimed this 60 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Scottcjn/Rustchain#8578 · 5 comments ·
Maintainers usually reply within 10 days
-
Python SDK attest --json returns status without running advertised attestation flowPossibly taken @ArtyormSatori claimed this 36 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
Scottcjn/Rustchain#8566 · 1 comment ·
Maintainers usually reply within 10 days
All issues in Scottcjn/Rustchain
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
daniel-ospina/tortoise#15308 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
difficulty:easy prio:low type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NatronGitHub/Natron#2405 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Jstar269/nakagawa-recomp#3746 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day