Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1317924 - RFC: ncat failing with input/output error with ssl option
RFC: ncat failing with input/output error with ssl option
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: nmap (Show other bugs)
7.2
All Linux
medium Severity medium
: rc
: ---
Assigned To: Pavel Zhukov
Jaroslav Aster
:
Depends On: 1460249
Blocks: 1298243 1420851 1465887 1465928
  Show dependency treegraph
 
Reported: 2016-03-15 10:10 EDT by Paulo Andrade
Modified: 2018-04-10 04:37 EDT (History)
6 users (show)

See Also:
Fixed In Version: nmap-6.40-9.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2018-04-10 04:36:10 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
localhost.key (1.66 KB, text/plain)
2016-03-15 10:45 EDT, Paulo Andrade
no flags Details
localhost.pem (1.24 KB, text/plain)
2016-03-15 10:46 EDT, Paulo Andrade
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:0661 None None None 2018-04-10 04:37 EDT

  None (edit)
Description Paulo Andrade 2016-03-15 10:10:57 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>---
Comment 2 Michal Hlavinka 2016-03-15 10:33:30 EDT
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
Comment 3 Paulo Andrade 2016-03-15 10:45 EDT
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
Comment 4 Paulo Andrade 2016-03-15 10:46 EDT
Created attachment 1136643 [details]
localhost.pem
Comment 5 Paulo Andrade 2016-03-23 09:41:51 EDT
  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).
Comment 6 Michal Hlavinka 2016-03-23 10:01:48 EDT
(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
Comment 8 Daniel Miller 2017-03-18 22:32:42 EDT
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
Comment 20 errata-xmlrpc 2018-04-10 04:36:10 EDT
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

Note You need to log in before you can comment on or make changes to this bug.