Red Hat Bugzilla – Bug 1317924
RFC: ncat failing with input/output error with ssl option
Last modified: 2018-04-10 04:37:10 EDT
User can consistently reproduce the problem, even if testing a localhost connection. A test case, on an environment where the problem would happen could be (I cannot reproduce the issue in my environment): ---8<--- # mkdir /tmp/test # cd /tmp/test # yes us | openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout localhost.key -out localhost.pem # ncat -l -p 5000 --ssl --ssl-key localhost.key --ssl-cert localhost.pem > /tmp/F;ls -l /tmp/F <<< on a second terminal >>> # tar --acls -C /boot -cvf - . | ncat --ssl -i 4 -4 --send-only --ssl-verify --ssl-trustfile /tmp/test/localhost.pem localhost 5000 ---8<--- The only workaround we found was to add --scpt to both ncat commands, otherwise it would quickly fail with the message: Ncat: Input/output error. I did several tests, but could not find a way to correct the problem, until I found the "hint" about --sctp on a message, without replies, at: http://seclists.org/nmap-dev/2015/q4/58 and the workaround indeed corrected the problem. The user says there is no firewall, and even validated testing on localhost, and still got the problem. There are no logs, and if running ncat on very verbose mode, the messages on the sending side will look like: ---8<--- [...] libnsock msevent_cancel(): msevent_cancel on event #92 (type TIMER) libnsock msevent_delete(): msevent_delete (IOD #NULL) (EID #92) libnsock msevent_new(): msevent_new (IOD #NULL) (EID #116) libnsock nsock_timer_create(): Timer created - 4000ms from now. EID 116 libnsock nsp_add_event(): NSE #116: Adding event libnsock msevent_delete(): msevent_delete (IOD #2) (EID #98) libnsock nsock_trace_handler_callback(): Callback: WRITE ERROR [Input/output error (5)] for EID 107 [111.22.3.444:5000] Ncat: Input/output error. ---8>---
reproducible (In reply to Paulo Andrade from comment #0) > I did several tests, but could not find a way to correct the > problem, until I found the "hint" about --sctp on a message, without > replies, at: > > http://seclists.org/nmap-dev/2015/q4/58 Unfortunately, nmap upstream does not really focus on ncat, it's more like see what our libraries can do. I've sent them patches for review a long time ago and it's very difficult to get any response from them. ---- for QE: reproducer needs also -subj '/CN=localhost' as openssl command, or ncat will fail with certificate verification error
Created attachment 1136642 [details] localhost.key sorry for the bad example creating certs, need to fill manually. Just attaching ready ones for testing purposes. Or, do not make the "yes us" pipe, and type: us us us us localhost
Created attachment 1136643 [details] localhost.pem
Hi Michal, Can you attach the patches you said was sent to upstream to the case report? Or where they not related to this issue? I asked the user to be 100% sure to reproduce the problem on a localhost connection, and actually, it does not happen in a localhost connection. I assumed it would fail on localhost connection, but after user telling it works, I tested it better, and can also reproduce the issue if connecting two hosts (and then, it works if using --sctp).
(In reply to Paulo Andrade from comment #5) > Can you attach the patches you said was sent to upstream > to the case report? Or where they not related to this issue? > They were not related to this issue. It was just to illustrate, that getting upstream response is close to impossible for example https://github.com/nmap/nmap/issues/157 that is reported upstream with patch for a few years (first mailing list, than issue tracker) with no response
I have just fixed this in Nmap upstream r36652. The problem is in the Ncat server, which was treating SSL_read identically to recv: the problem is that SSL_read can return -1 when all that is required is to try the call again. After adding code to check for this condition, the connection is maintained and transfer is successful. This will be included in the next release of Ncat/Nmap. https://github.com/nmap/nmap/commit/ac8b866d73ca4df63c4b336253afd944d44d9c6a
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2018:0661