Tenable Research has discovered a memory corruption vulnerability in Fluent Bit versions 2.0.7 thru 3.0.3. This issue lies in the embedded http server’s parsing of trace requests and may result in denial of service conditions, information disclosure, or remote code execution.
Fluent Bit’s monitoring API is intended to allow administrators or other users to query and monitor information internal to the service itself. For example, HTTP endpoints exist to indicate service uptime, plugin metrics, health checks, etc.
Among these endpoints are /api/v1/traces and /api/v1/trace, which allow end-users to enable, disable, or retrieve information about configured traces. Regardless of whether or not any traces are configured, it is still possible for any user with access to this API endpoint to query it.
During the parsing of incoming requests for the “traces” api endpoint, types of input names are not properly validated before being parsed. They are incorrectly assumed to be valid MSGPACK_OBJECT_STRs. This can be seen here: https://github.com/fluent/fluent-bit/blob/master/src/http_server/api/v1/trace.c#L527
By passing non-string values in the “inputs” array of requests, such as integer values, it is possible to cause a variety of memory corruption issues that could lead to RCE. During the flb_sds_create_len() function that assigns the input_name variable, the values passed when an int is supplied happen to be a pointer to the beginning of the inputs array and the integer itself as the “size” of the value.
In an isolated lab environment, researchers were able to reliably exploit this issue to crash the service and cause a denial of service scenario. They were also able to retrieve chunks of adjacent memory, which are returned in the HTTP responses. While this is generally unlikely to reveal anything other than previous metrics requests, the researchers were able to occasionally retrieve partial secrets during their testing, indicating that this issue could potentially leak sensitive information.
As for the remote code execution possibilities of this issue, exploitation is dependent on a variety of environmental factors such as host architecture and operating system. While heap buffer overflows such as this are known to be exploitable, creating a reliable exploit is not only difficult, but incredibly time consuming. Tenable Research believes that the most immediate and primary risks are those pertaining to the ease with which DoS and information leaks can be accomplished.
This issue was ultimately fixed by properly validating the data types of values in the “inputs” array sent to the “traces” endpoint. Further details can be found in the following commit: https://github.com/fluent/fluent-bit/commit/9311b43a258352797af40749ab31a63c32acfd04