update(userspace/falco): enforce check that content-type actually starts with "application/json" string.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
This commit is contained in:
Federico Di Pierro 2021-11-23 09:58:34 +01:00 committed by poiana
parent b359f71511
commit bb8b75a2cd

View File

@ -150,7 +150,8 @@ bool k8s_audit_handler::handlePost(CivetServer *server, struct mg_connection *co
// Ensure that the content-type is application/json
const char *ct = server->getHeader(conn, string("Content-Type"));
if(ct == NULL || strstr(ct, "application/json") == NULL)
// content type *must* start with application/json
if(ct == NULL || strncmp(ct, "application/json", strlen("application/json")) != 0)
{
mg_send_http_error(conn, 400, "Wrong Content Type");