CVE-2018-20586 disclosure (log injection vulnerability)

CVE-2018-20586 disclosure (log injection vulnerability)
From: Luke Dashjr @ 2019-11-22 17:13 UTC ( / )
  To: bitcoin-dev;  security

CVE-2018-20586 is a log injection vulnerability which allows any software with 
access to the RPC port to create fake or confusing entries in the debug log. 
Valid authentication (username/password/cookie) for the RPC service is NOT 
required to exploit this vulnerability, only the ability to connect to the 
RPC port (which is by default only exposed to the local machine).

The vulnerability was introduced in 40b556d3742a1f65d67e2d4c760d0b13fe8be5b7 
("libevent-based http server") and first released in Bitcoin Core v0.12.0rc1 
in 2016 Jan 13. A fix was hidden in 79358817e53ac0a7afa64c747115d492a74e3155 
("rpc: Make HTTP RPC debug logging more informative") released in v0.17.1, 
2018 Dec 22.

To be vulnerable, the malicious software must either be running on the same 
machine as the node, have the ability to proxy connections to the node via 
the local machine, or the node must be configured to accept RPC connections 
from a network via which the attacker can connect. Additionally, a human user 
must read the debug log and act on or otherwise believe the injected data, in 
a way that is somehow harmful.

Because the node would log the arbitrary POST request from any connection, an 
attacker can add nearly any content to the request to inject it into the log. 
To ensure their entire request is injected, standard spaces would need to be 
replaced with alternative whitespace characters, and newlines would need to 
become other control characters (such as "\r\v"). Because the injected data 
must use such non-standard characters, it is most likely to not fool other 
software parsing the debug log, and only a human visually reading it.

To fix this vulnerability, POST requests are now sanitised before being 
logged, removing all characters that shouldn't be in an ordinary POST 
request.

Credit goes to practicalswift (https://twitter.com/practicalswift) for 
discovering and fixing the vulnerability.

Timeline:
- 2015-01-18: Vulnerability introduced in PR #5677.
- 2015-09-04: Vulnerability merged to master git repository.
- 2016-01-13: Vulnerability published in v0.12.0rc1.
- 2016-02-18: Vulnerability released in v0.12.0.
...
- 2018-10-25: practicalswift discloses vulnerability to security team.
- 2018-10-31: practicalswift opens PR #14618 to quietly fix vulnerability.
- 2018-11-05: Fix merged to master git repository.
- 2018-11-30: Fix merged to 0.17 git repository.
- 2018-12-07: Fix published in v0.17.1rc1.
- 2018-12-22: Fix released in v0.17.1.
...
- 2019-06-22: Vulnerability existence disclosed to bitcoin-dev ML.
- 2019-11-22: Vulnerability details disclosure to bitcoin-dev ML.