taskserver icon indicating copy to clipboard operation
taskserver copied to clipboard

log IP address of host for TLS handshake failures

Open pbartyik opened this issue 6 years ago • 1 comments

For publicly hosted instances of taskwarrior server to increase security would be nice to have the logs state the IP address which the TLS handshake failed with. Then these could be blocked with fail2ban.

For example nmap -sV <host> -p<port> yields in the log:

2019-10-11 16:21:56 Error: Handshake failed. The TLS connection was non-properly terminated. 2019-10-11 16:21:56 Error: Handshake failed. An unexpected TLS packet was received. 2019-10-11 16:21:57 (Repeated 6 times) 2019-10-11 16:21:57 Error: Handshake failed. A packet with illegal or unsupported version was received. 2019-10-11 16:21:57 Error: Handshake failed. An unexpected TLS packet was received. 2019-10-11 16:21:57 Error: Handshake failed. Error in the pull function. 2019-10-11 16:21:57 Error: Handshake failed. No certificate was found. 2019-10-11 16:22:05 (Repeated 86 times) 2019-10-11 16:22:05 Error: Handshake failed. The TLS connection was non-properly terminated. 2019-10-11 16:22:05 Error: Handshake failed. An unexpected TLS packet was received.

This could be controlled via verbosity in the config, something like: verbose=tls

If this is already implemented, please point me towards the right direction.

pbartyik avatar Oct 11 '19 16:10 pbartyik

At TLSServer.cpp we get access to host. On lines 438 and 441 this could be thrown - isn't that what gets sent to the logfile?

EDIT: Yeah, that does the trick. Created a fork and yielded this:

2019-10-11 18:00:23 Error: Handshake failed for host '192.168.2.102'. The TLS connection was non-properly terminated. 2019-10-11 18:00:23 Error: Handshake failed for host '192.168.2.102'. An unexpected TLS packet was received. 2019-10-11 18:00:23 (Repeated 6 times) 2019-10-11 18:00:23 Error: Handshake failed for host '192.168.2.102'. A packet with illegal or unsupported version was received. 2019-10-11 18:00:23 Error: Handshake failed for host '192.168.2.102'. An unexpected TLS packet was received. 2019-10-11 18:00:23 Error: Handshake failed for host '192.168.2.102'. The TLS connection was non-properly terminated. 2019-10-11 18:00:23 Error: Handshake failed for host '192.168.2.102'. Certificate is required. 2019-10-11 18:00:23 (Repeated 29 times) 2019-10-11 18:00:23 Error: Handshake failed for host '192.168.2.102'. An unexpected TLS packet was received.

pbartyik avatar Oct 11 '19 16:10 pbartyik