-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
signrpc: Add no_hashing flag to signMessage #4495
Conversation
ae231fb
to
258a3ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I took a look at the k1
value mentioned in the issue, as defined here,
k1 (hex encoded 32 bytes of challenge) which is going to be signed by user's linkingPrivKey.
And it seems like it's already 32 bytes, so the function SignDigest
could be stay put? When signing a message, it's always required the message to be hashed before signing. I think what we are dealing here is to decide whether we want to perform a SHA256 on the message or not. If not, we should only allow a 32 byte message to be directly passed to SignDigest
.
Thank you for your feedback @yyforyongyu! I made the code prior to this knowledge, which is why I named the flag to the rather cryptic |
258a3ed
to
511b0c8
Compare
@yyforyongyu Please take another look, I think I addressed all your feedback. |
511b0c8
to
8019495
Compare
Whether to hash the message before signing it or not. Defaults to false to keep backward compatibility. If set to true, signrpc expects a 32 bytes message.
8019495
to
9ea48b4
Compare
Rebased and uppercase'd "MUST" in error message ( |
Thank you for the PR.
While I do think the intentions (and the need for) @cfromknecht what's your opinion here? |
Hi @guggero, I appreciate your reply.
I think this question is best suited for @btcontract. Unfortunately the current schema is widely deployed by different wallets and services. But if this is a security concern, I think it definitely makes sense to address this.
Yes, it's not possible to get the So there will have to be special cases for the |
@guggero your spidey senses are not unfounded.
No, this does not leak your private key. That said, opening this PR did lead to the identification of weaknesses in the construction. The relevant details were disclosed privately to @btcontract 2-3 weeks ago and we remain in contact. Even though there are inherent weaknesses in the primitives, there doesn't appear to be any immediate security implications for LNURL as specified. However, we both agree that these weaknesses are worth fixing and are actively investigating a v2 scheme for lnurl-auth. @hsjoberg As it relates to this PR, unfortunately I am not comfortable exposing insecure signing primitives generically via lnd's rpc interface. Therefore we probably won't see lnurl-auth support in lnd until a replacement is standardized, however we are working to make that happen sooner than later. NOTE: I consulted @btcontract before replying to ensure we were both in agreement that this preliminary disclosure is reasonable given the security risk is minimal. More details will be available soon, as of now there is no immediate action that needs to be taken by clients or servers. |
@cfromknecht Totally understandable. As long as we come up with another solution that works for everyone, I'm happy.
Sounds good, keep me in the loop if there's anything I can do. Cheers |
Closes #4474.
To be able to support lnurl-auth, a message ("k1") needs to be signed by lnd without it being hashed.
This PR addresses this by adding a new flag
no_hashing
to thesignrpc.signMessage
method. It defaults to false to keep current behavior. If it is set to true, no hashing of the message will be made before signing.I have not updated
verifyMessage
with the flag but I could do that as well if you want me to.Cheers