Skip to content

message_signing::sigrec_decode panics for 0-length signatures #1005

@sr-gi

Description

@sr-gi

If an empty signature is passed to sigrec_decode, the function will panic at extracting rsig and rid.

https://github.com/rust-bitcoin/rust-lightning/blob/1f1d7c6890c6c9bef70eeb4ec4c6841e3344159b/lightning/src/util/message_signing.rs#L38-L40

Given sigrec_decode is private, this can either be fixed at recover_pk after zbase32 decoding the signature, by making sure its length is at least 2, or at sigrec_decode by checking the same.

Something on the lines of the following should do:

fn sigrec_decode(sig_rec: Vec<u8>) -> Result<RecoverableSignature, Error> {
    if len(sig_rec) < 2 {
        return Error::InvalidSignature;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions