Skip to content
This repository has been archived by the owner on Jun 21, 2020. It is now read-only.

KM node panics if signature is bad length #153

Closed
elichai opened this issue May 12, 2019 · 1 comment · Fixed by #154
Closed

KM node panics if signature is bad length #153

elichai opened this issue May 12, 2019 · 1 comment · Fixed by #154
Labels
bug Something isn't working

Comments

@elichai
Copy link
Contributor

elichai commented May 12, 2019

Describe the bug
The KM node panics if it receives a signature with valid hex bad bad length.
The error is at this line: https://github.com/enigmampc/enigma-core/blob/c18f65c11ff86d297776ca13b4a6cbe7507bd7ee/enigma-principal/app/src/boot_network/keys_provider_http.rs#L71
We pass the signature to copy_from_slice without checking length first which then asserts their length.

The solution is to implement something like this: https://github.com/enigmampc/enigma-core/blob/develop/enigma-types/src/hash.rs#L15

To Reproduce
Send this request to the KM node:

{ 
	data: "83a46461746181a752657175657374c0a269649c2d71cc8750cce9cca73c7cccd8ccbe73ccc6a67075626b6579dc0040224540cce8ccb6063118317e04cc9accb6741c17665ecca1ccd90106cc9acc8d0770cc9506cced323acce52ccc9fcca6cce465cce7cc e8cc9a33chdb39ccaf71ccee6557ccbccccc100eccfc4839cca2cce6cc9f4ecc88ccbb572725",
	sig: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" 
}

Expected behavior
Return Invalid length error without crashing.

Backtrace

thread 'jsonrpc-eventloop-1' panicked at 'assertion failed: `(left == right)`
  left: `65`,    a      [                                  
 right: `32`: destination and source slices have different lengths', libcore/slice/mod.rs:1785:9
note:ERun with `RUST_BACKTRACE=1` for a backtrace.         

@elichai elichai added the bug Something isn't working label May 12, 2019
@elichai
Copy link
Contributor Author

elichai commented May 12, 2019

@elichai elichai mentioned this issue May 12, 2019
elichai added a commit that referenced this issue May 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant