Skip to content

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

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

security: Fix invalid threshold input validation (#48)#50
zhaog100 wants to merge 1 commit intobitaps-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
Copy link
Copy Markdown

@yatescleta-afk yatescleta-afk left a comment

Choose a reason for hiding this comment

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

👍🏻

@yatescleta-afk
Copy link
Copy Markdown

yatescleta-afk commented Mar 28, 2026

Hello! This is my first bug bounty submission, and I’m very excited about the security of this project.

Please let me know if anything further is required on my end to assist with moving the review process forward. I appreciate your time and consideration.
I apologize for the multiple approvals comments they are a mistake. Unable to delete 😜

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