-
-
Notifications
You must be signed in to change notification settings - Fork 170
Description
Bug Report
Severity: Medium-High
Location
node/rustchain_v2_integrated_v2.2.1_rip200.py, line ~6075
Description
The /wallet/transfer/signed endpoint calls bytes.fromhex(signature) without input validation or error handling:
tx_hash = hashlib.sha256(message + bytes.fromhex(signature)).hexdigest()[:32]If the signature field contains non-hexadecimal characters, bytes.fromhex() raises a ValueError which is unhandled, causing the route to return a 500 Internal Server Error instead of a proper 400 validation error.
Steps to Reproduce
curl -X POST https://rustchain.org/wallet/transfer/signed \
-H "Content-Type: application/json" \
-d '{
"from_address": "RTCtest",
"to_address": "RTCtest2",
"amount_rtc": 1.0,
"nonce": 1234567890,
"signature": "NOT_VALID_HEX_STRING",
"public_key": "test"
}'Expected Behavior
HTTP 400 with {"error": "Invalid signature format"} or similar validation error.
Actual Behavior
HTTP 500 Internal Server Error. Unhandled ValueError exception, potentially leaking stack trace information.
Impact
- Malformed requests cause 500 errors instead of proper 400 validation
- Potential information disclosure via stack traces in error responses
- Could be used for DoS by flooding with malformed signature requests
- Inconsistent error handling compared to other validated endpoints
Additional Issues Found
While reviewing the codebase, I also noticed:
-
Float precision in
/wallet/history(lines ~5057-5059): Direct float division without rounding (int(amount_i64) / UNIT) where other endpoints useround(). Financial values should use explicitround(value, 6)for consistency with the documented 6-decimal precision. -
Inconsistent UNIT constants: Mix of
1_000_000and1000000across the codebase. -
Memo truncation without notification (line ~6118): Memos are silently truncated at 80 characters with no client feedback.
Suggested Fix
# Validate signature format before use
try:
sig_bytes = bytes.fromhex(signature)
except ValueError:
return jsonify({"error": "Invalid signature format — must be hex string"}), 400
tx_hash = hashlib.sha256(message + sig_bytes).hexdigest()[:32]Wallet for payout: wirework