From bb8b75a2cd6a26f543dbf581d9d870bf741bde75 Mon Sep 17 00:00:00 2001 From: Federico Di Pierro Date: Tue, 23 Nov 2021 09:58:34 +0100 Subject: [PATCH] update(userspace/falco): enforce check that content-type actually starts with "application/json" string. Signed-off-by: Federico Di Pierro Co-authored-by: Leonardo Grasso --- userspace/falco/webserver.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/userspace/falco/webserver.cpp b/userspace/falco/webserver.cpp index 5af8db84..6405d0ca 100644 --- a/userspace/falco/webserver.cpp +++ b/userspace/falco/webserver.cpp @@ -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");