-
Notifications
You must be signed in to change notification settings - Fork 385
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
supplying invalid blinding factors to rawblindrawtransaction causes node to crash #540
Comments
Interesting report, thanks! Will look and see if we need to get support upstream in secp-zkp. |
@apoelstra says |
If CHECK is removed in upstream secp-zkp, then pre-verification would not be needed. OTOH, that means there would be delay in fixing the bug, so maybe it should be fixed with pre-verification |
secp256k1_ec_seckey_verify also checks for zero scalar, but some code in wallet.cpp passes zero asset blinders to BlindTransaction(), so in addition to secp256k1_ec_seckey_verify there would need to be a check for zero scalar (probably, memcmp with static array of nuls), in that case it should not fail. |
oof ok. That's annoying. |
Maybe it is better to just wait for remove of the CHECK in upstream secp-zkp, considering that the impact of the bug is small |
Just for reference, a patch that fixes this on 0.14 branch (not doing PR because 0.14 is outdated, but I don't have time now to properly build and test on master)
|
The check is removed upstream; we could just update the version of secp256k1-zkp in elements now. |
The updated secp-zkp fixes the crash via CHECK, what is within the secp lib, but the asserts in Elements code are still there, Line 522 in ee642f5
Line 287 in ee642f5
I think the asserts should be replaced with checks that return -1 if ret is 0 |
Yes this should be reopened.
…On Fri, Jun 7, 2019, 7:41 PM Dmitry Petukhov ***@***.***> wrote:
The updated secp-zkp fixes the crash via CHECK, what is within the secp
lib, but the asserts in Elements code are still there,
https://github.com/ElementsProject/elements/blob/ee642f5862df4835e6c4c74739c0a950264b6828/src/blind.cpp#L522
will cause crash if invalid value blinder is supplied via RPC, and
https://github.com/ElementsProject/elements/blob/ee642f5862df4835e6c4c74739c0a950264b6828/src/blind.cpp#L287
that will cause crash if invalid asset blinder is supplied
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#540?email_source=notifications&email_token=ABMAFU7UFZFX6ZOZE4VYBRDPZKMTLA5CNFSM4HBZ5362YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXGQJPQ#issuecomment-499975358>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABMAFU2JEFKKUT5HSQU3N23PZKMTLANCNFSM4HBZ536Q>
.
|
@stevenroose can you reopen this, please ? The original issue is not yet resolved |
I'm adding that test case to the functional test. I agree we shouldn't assert validity of keys when we get them from the user.. |
@stevenroose thanks! |
So #661 covers those two asserts and those are indeed the ones hit when providing incorrect blinders. The blind.cpp file is full of asserts, most of them seem to be from self-generated information, though. Luckily that file is only exposed to RPC users. |
|
Yeah |
f9d159b Don't assert on user-inputed values (Steven Roose) Pull request description: This prevents the assertion from crashing the node when an RPC user enters invalid blinding factors. Fixes #540. Tree-SHA512: d68787edb9919a3a55b94884180700854941c5f273c2ac07f534bd0a3981f163fa26c8cef931001bc9906d6c74a58cdc0148eb7d53d3edbedf005a0be7c60c5b
if invalid value blinder is supplied, this assert is triggered:
elements/src/blind.cpp
Line 517 in dd1623a
if invalid asset blinder is supplied, this CHECK() in secp256k1 is triggered:
elements/src/secp256k1/src/modules/generator/main_impl.h
Line 178 in dd1623a
Triggered with this small patch to qa/rpc-tests/confidential_transactions.py (tested on 0.14.1 branch, but the failing code is the same on master. to trigger first case, you just put
ab
in place of value blinder, not asset blinder as in this patch):While the impact of the bug is not very serious, as this can only be triggered with authenticated rpc request and results only in node crash, I believe the crash is not correct response to invalid user input.
First case can be fixed by checking ret and returning failure, instead of dying on assert.
But the second case is not that easy, and would require checking that a given blinder represents valid scalar before passing it to secp256k1_generator_generate_blinded. I did not find appropriate function in secp256k1 that would allow to check this condition before passing the data to secp256k1_generator_generate_blinded.
The text was updated successfully, but these errors were encountered: