Skip to content
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

binascii.Error: Non-hexadecimal digit found during sendpayment #1069

Closed
laanwj opened this issue Nov 11, 2021 · 1 comment · Fixed by #1070
Closed

binascii.Error: Non-hexadecimal digit found during sendpayment #1069

laanwj opened this issue Nov 11, 2021 · 1 comment · Fixed by #1070

Comments

@laanwj
Copy link
Contributor

laanwj commented Nov 11, 2021

I got the following error during sendpayment (commit 4c284d2):

2021-11-11 08:46:??,??? [INFO]  All IRC servers connected, starting execution.                                    
2021-11-11 08:46:??,??? [INFO]  JM daemon setup complete                                                                                                                                                                            
Unhandled Error                                                                                                                                                                                                                     
Traceback (most recent call last):                                                                                
  File "/home/user/joinmarket-clientserver/jmvenv/lib/python3.8/site-packages/twisted/protocols/amp.py", line 1041, in _commandReceived                                                                                             
    deferred = self.dispatchCommand(box)                                                                                                                                                                                            
  File "/home/user/joinmarket-clientserver/jmvenv/lib/python3.8/site-packages/twisted/protocols/amp.py", line 1099, in dispatchCommand                                                                                              
    return maybeDeferred(responder, box)                                                                                                                                                                                            
  File "/home/user/joinmarket-clientserver/jmvenv/lib/python3.8/site-packages/twisted/internet/defer.py", line 151, in maybeDeferred                                                                                                
    result = f(*args, **kw)                                                                                       
  File "/home/user/joinmarket-clientserver/jmvenv/lib/python3.8/site-packages/twisted/protocols/amp.py", line 1186, in doit                                                                                                         
    return maybeDeferred(aCallable, **kw).addCallback(                                                                                                                                                                              
--- <exception caught here> ---                                                                                   
  File "/home/user/joinmarket-clientserver/jmvenv/lib/python3.8/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks                                                                                                
    current.result = callback(current.result, *args, **kw)                                                        
  File "/home/user/joinmarket-clientserver/jmvenv/lib/python3.8/site-packages/twisted/protocols/amp.py", line 1169, in checkKnownErrors                                                                                             
    key = error.trap(*command.allErrors)                                                                          
  File "/home/user/joinmarket-clientserver/jmvenv/lib/python3.8/site-packages/twisted/python/failure.py", line 460, in trap                                                                                                         
    self.raiseException()                                                                                         
  File "/home/user/joinmarket-clientserver/jmvenv/lib/python3.8/site-packages/twisted/python/failure.py", line 488, in raiseException                                                                                               
    raise self.value.with_traceback(self.tb)                                                                      
  File "/home/user/joinmarket-clientserver/jmvenv/lib/python3.8/site-packages/twisted/internet/defer.py", line 151, in maybeDeferred                                                                                                
    result = f(*args, **kw)                                                                                       
  File "/home/user/joinmarket-clientserver/jmclient/jmclient/client_protocol.py", line 350, in on_JM_REQUEST_MSGSIG_VERIFY                                                                                                          
    pubkey_bin = hextobin(pubkey)                                                                                 
  File "/home/user/joinmarket-clientserver/jmbase/jmbase/support.py", line 98, in hextobin                        
    return binascii.unhexlify(h.encode('utf8'))                                                                   
binascii.Error: Non-hexadecimal digit found                                                                                                                                                                                         
                                                                                                                  
Amp server or network failure unhandled by client application.  Dropping connection!  To avoid, add errbacks to ALL remote commands!
Traceback (most recent call last):               
--- <exception caught here> ---                    
  File "/home/user/joinmarket-clientserver/jmvenv/lib/python3.8/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks                                                                                                
    current.result = callback(current.result, *args, **kw)                                                        
  File "/home/user/joinmarket-clientserver/jmdaemon/jmdaemon/daemon_protocol.py", line 492, in defaultErrback                                                                                                                       
    failure.trap(ConnectionAborted, ConnectionClosed,                                                                                                                                                                               
  File "/home/user/joinmarket-clientserver/jmvenv/lib/python3.8/site-packages/twisted/python/failure.py", line 460, in trap
    self.raiseException()                                                                                         
  File "/home/user/joinmarket-clientserver/jmvenv/lib/python3.8/site-packages/twisted/python/failure.py", line 488, in raiseException
    raise self.value.with_traceback(self.tb)        
twisted.protocols.amp.UnknownRemoteError: Code<UNKNOWN>: Unknown Error

It seems to have been an intermittent error (something a peer sent?) and is non-reproducible. Just leaving it here in case it is significant.

@AdamISZ
Copy link
Member

AdamISZ commented Nov 11, 2021

Yep, this hex to bin cast is unprotected. I'm not at my desk right now so it will take a while before I push a fix, someone else feel free to do it; what I did do, however, was a scan through the codebase to check if there are any other casts like that that are 'naked'. Afaict nothing else similar.

AdamISZ added a commit that referenced this issue Nov 12, 2021
Fixes #1069.
Before this commit, a non-hex encoded pubkey sent
as part of the privmsg signature raised an Exception,
this commit fixes this, checking the encoding of both
the pubkey and signature fields before sending them
from daemon to client.
kristapsk added a commit that referenced this issue Nov 29, 2021
0507f6a Validate message signature encoding (Adam Gibson)

Pull request description:

  Fixes #1069.
  Before this commit, a non-hex encoded pubkey sent
  as part of the privmsg signature raised an Exception,
  this commit fixes this, checking the encoding of both
  the pubkey and signature fields before sending them
  from daemon to client.

ACKs for top commit:
  kristapsk:
    ACK 0507f6a. Checked diff between commits, test suite passes, did successful signet coinjoin. Merging.

Tree-SHA512: d6b59fc340b015157544330a0a4624999559d9f2bcc5ee1ef189558bdab5fb2a2cf80287d1020bfe5be1f4919037b794a0fa4bbe2292a80aca0a03e9de23384a
BitcoinWukong pushed a commit to BitcoinWukong/joinmarket-clientserver that referenced this issue Dec 9, 2021
Fixes JoinMarket-Org#1069.
Before this commit, a non-hex encoded pubkey sent
as part of the privmsg signature raised an Exception,
this commit fixes this, checking the encoding of both
the pubkey and signature fields before sending them
from daemon to client.
takinbo pushed a commit to takinbo/joinmarket-clientserver that referenced this issue May 27, 2022
Fixes JoinMarket-Org#1069.
Before this commit, a non-hex encoded pubkey sent
as part of the privmsg signature raised an Exception,
this commit fixes this, checking the encoding of both
the pubkey and signature fields before sending them
from daemon to client.
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 a pull request may close this issue.

2 participants