CRLF Injection Affecting yhirose/cpp-httplib package, versions [,0.5.9)


0.0
high

Snyk CVSS

    Attack Complexity Low
    Integrity High

    Threat Intelligence

    Exploit Maturity Proof of concept
    EPSS 0.11% (44th percentile)
Expand this section
NVD
7.5 high

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-UNMANAGED-YHIROSECPPHTTPLIB-2366507
  • published 26 Jan 2022
  • disclosed 12 Apr 2020
  • credit shouc

How to fix?

Upgrade yhirose/cpp-httplib to version 0.5.9 or higher.

Overview

Affected versions of this package are vulnerable to CRLF Injection due to not filtering \r\n in parameters passed into the set_redirect and set_header functions.

PoC

#include "cpp-httplib/httplib.h"
using namespace httplib;
int main() {
    Server svr;
    svr.Get("/1", [](const Request& req, Response& res) {
        res.set_redirect("1\r\nSet-Cookie: a=1");
    });
    svr.Get("/2", [](const Request& req, Response& res) {
        res.set_header("a", "1\r\nSet-Cookie: a=1");
    });
    svr.listen("localhost", 3000);
}