Skip to content

check signed-message length in AIMerSigner.verifySignature - #2401

Closed
rootvector2 wants to merge 1 commit into
bcgit:mainfrom
rootvector2:aimer-verify-envelope-length
Closed

check signed-message length in AIMerSigner.verifySignature#2401
rootvector2 wants to merge 1 commit into
bcgit:mainfrom
rootvector2:aimer-verify-envelope-length

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

AIMerSigner.verifySignature slices the signature out of the message || signature envelope at offset message.length without checking the buffer is that long, so a truncated signature throws ArrayIndexOutOfBoundsException out of Signature.verify() and a valid one with bytes appended still verifies (found by feeding wrong-length signatures to every BCPQC Signature service); it now requires exactly message.length + getSignatureBytes() and returns false otherwise, the guard the Falcon, Faest, Mayo, Snova and QRUOV signers already carry.

@dghgit dghgit self-assigned this Aug 21, 2026
@dghgit

dghgit commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Thanks for the patch, now merged and up on https://downloads.bouncycastle.org/betas - one minor change, we optimised the test. Things are starting to take a while...

@dghgit dghgit closed this Aug 22, 2026
hubot pushed a commit that referenced this pull request Aug 22, 2026
…ture to be exactly the message plus the parameter set's signature size, so that a short signature is reported as a failed verification rather than indexed past its end, and a valid one with data appended to it no longer verifies, relates to github #2401.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants