Skip to content

security: Fix invalid threshold input validation (#48)#50

Open
zhaog100 wants to merge 1 commit into
bitaps-com:masterfrom
zhaog100:bounty-48
Open

security: Fix invalid threshold input validation (#48)#50
zhaog100 wants to merge 1 commit into
bitaps-com:masterfrom
zhaog100:bounty-48

Conversation

@zhaog100

Copy link
Copy Markdown

Security Fix

Invalid threshold inputs caused fallback mode that leaks checksum-index hiding.

Changes

  • Added type validation for threshold/total
  • Rejects NaN, non-integer, out-of-range values
  • Clear error messages

Testing

Valid: threshold=3, total=5 ✅
Invalid: threshold='$', total=5 ❌

BTC: bc1q9ezttyulgmm7lh8a086tsug990h4j3tflk3yc7

Closes #48

…ring (bitaps-com#48)

## 🚨 Security Vulnerability Fix

**Severity:** Significant Implementation Bug
**Issue:** bitaps-com#48
**Bounty Tier:** 0.05 BTC+

## Problem

When invalid threshold/total values were entered (e.g., '$ of 5', '$ of 8'), the tool:
- Silently fell back to trivial 'duplicate + cycle checksum' mode
- Generated identical shares with only the 12th word changing
- Leaked the checksum-index hiding mechanism
- Exposed internal Shamir implementation details

**Root Cause:** No type validation for threshold and total parameters.

## Solution

Added comprehensive input validation in `__split_secret()`:

1. **Undefined/Null checks** - Rejects missing parameters
2. **Type conversion** - Handles string form inputs
3. **NaN validation** - Rejects non-numeric input ('$', '', etc.)
4. **Integer validation** - Ensures whole numbers only
5. **Range validation** - Enforces 1-255 bounds
6. **Logical validation** - threshold ≤ total

## Changes

- Modified `src/functions/shamir_secret_sharing.js`
- Added 25+ lines of validation logic
- Clear error messages for each failure case

## Impact

- ✅ Prevents fallback mode exploitation
- ✅ Protects checksum-index hiding mechanism
- ✅ Clear user feedback on invalid input
- ✅ Maintains backward compatibility for valid inputs

## Testing

Valid inputs still work:
- threshold=3, total=5 ✅
- threshold=2, total=10 ✅

Invalid inputs now rejected:
- threshold='$', total=5 ❌
- threshold='', total=5 ❌
- threshold=NaN, total=5 ❌
- threshold=0, total=5 ❌
- threshold=256, total=5 ❌

Closes bitaps-com#48

Payment: BTC bc1q9ezttyulgmm7lh8a086tsug990h4j3tflk3yc7

@yatescleta-afk yatescleta-afk left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@yatescleta-afk

yatescleta-afk commented Apr 14, 2026

Copy link
Copy Markdown

@4tochka waiting for merge anything I can do to help test 👀please check at your earliest convenience bitaps bounty#48 fix #50 ready to merge

@zhaog100

Copy link
Copy Markdown
Author

This PR has been open 88 days, mergeable with clean state. Any blockers to merging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants