Skip to content

A peer can fill the pending InstantLock queue with about 880 MB of locks it never has to sign #1417

Open

Description

@manki-review

🚫 Blocker · Security · Moderate

A peer can fill the pending InstantLock queue with about 880 MB of locks it never has to sign

What goes wrong: A well-formed lock whose cyclehash names no stored cycle passes the structure check and is cloned into pending_instantlocks. Nothing checks its signature first. With up to 48780 inputs (about 1.76 MB each, under the 3 MB message cap) and 500 slots, one peer can hold about 880 MB for PENDING_TTL (one hour).

How to fix it, why, 17 places read, and 1 other check · confirmed with tools

How to fix it
Limit the pending queue by total input count or bytes instead of entry count. Once header sync is done, drop locks whose cyclehash is not a known block header, as Core's ResolveCycleHeight check does. Optionally cap pending entries per peer so one peer cannot evict others' genuine locks.

Why it matters
The FIFO eviction also pushes out genuine locks that are still waiting for quorum data. Pending dedupe is now by lock hash, so the flood can even reuse one txid. Dash Core drops a lock with an unknown cycleHash on receipt and penalizes the sender.

Checked in the code
On the commented line: self.queue_pending(PendingInstantLock::new(instantlock.clone(), hash)); stores the full lock

const MAX_PENDING_INSTANTLOCKS: usize = 500; counts entries, not bytes

/// Maximum number of pending InstantLocks awaiting validation.
const MAX_PENDING_INSTANTLOCKS: usize = 500;
/// Maximum number of verified txids to cache.
const MAX_CACHE_SIZE: usize = 5000;

An unknown cycle returns Ok(None) without any signature check

};
let Some(cycle) = engine.instant_send_cycle(&instant_lock.cyclehash) else {
return Ok(None);
};
match InstantLockValidator::new(cycle.quorums).validate_signature(instant_lock) {

MAX_MSG_SIZE: usize = 3 * 1024 * 1024 allows a lock of the maximum input count

/// 3 MiB. A header announcing a longer payload is refused before the payload is read.
pub const MAX_MSG_SIZE: usize = 3 * 1024 * 1024;
/// Size of a message header: magic, command, payload length and checksum.
const MESSAGE_HEADER_SIZE: usize = 24;

Double-checked
Manki tried to disprove this by reading the code and could not. A lock of at most 48780 inputs whose cyclehash names no stored cycle passes the structure check and gets Ok(None) from verify with no signature check. It is cl…

Found by Manki in #1336 at dash-spv/src/sync/instantsend/manager.rs:189. See the review thread.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions