-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ecdsa.ParseDERSignature() succeeds for an invalid signature (append arbitrary data) #2059
Comments
Wdyt @guggero ? |
Hi @benma, In the normal execution path, any calls to As far as In summary, such a signature would never be accepted as valid via normal execution paths. Precondition checks in the VM will cause such signatures to be rejected before we attempt to fully parse them. |
@Roasbeef thanks for the response! I can see that internally for btcd, there is no problem. However, Out of curiosity (maybe also document that in the docstring if it makes sense): why does |
I don't think so, we'd accept a PR to do so.
At the time of porting, it wasn't clear that the implementations matched up 100%, so we kept our existing logic, as changes to this function may end up triggering a consensus divergence in the absolute worst case (we reject parsing, other nodes accept one). I think we can consider switching to that version, but we'd want to do some extensive differential fuzzing first. |
Hi @Roasbeef , Is this issue regarding the ParseDERSignature() function still open? Also, would it be acceptable to make it stricter to only accept valid DER-encoded signatures? If so, I would love to contribute. |
@SulaimanAminuBarkindo sure, we'd accept a contribution to make the external facing usage more consitent. |
I will be working towards it. |
Hi @Roasbeef, I've started addressing the issue with ParseDERSignature() by adding stricter validation for signature lengths. I've opened a draft PR to showcase the updates so far. Before proceeding, I'd appreciate your guidance on the scope of changes needed to ensure consistency and strictness in the function's behavior. Specifically, I'm focusing on enforcing stricter validation of signature lengths but want to ensure I'm addressing all relevant aspects of the issue. Could you provide clarity on any additional changes or considerations we need to make? Are there other areas of the function's behavior we should improve or make more consistent? Your insights would be greatly appreciated as I continue working on this. Looking forward to your feedback. |
@SulaimanAminuBarkindo I looked at the other sanity checks we have and it looks like the maximum size check is the main thing that was missing. |
Thanks for reviewing, @guggero I'll go ahead and switch the PR from draft to ready for review. |
Appending garbage data to a valid DER signature does not fail
ParseDERSignature()
.See for example this modification of the unit tests, which does not fail the unit tests:
master...benma:btcd:der-sigs
The documentation of ParseDerSignature() does not mention anything like this. I would expect signatures longer than 72 bytes to be invalid and return an error.
Is this a bug?
The text was updated successfully, but these errors were encountered: