include(FetchContent) set(HTTPLIB_REQUIRE_OPENSSL ON CACHE BOOL "" FORCE) set(HTTPLIB_USE_OPENSSL_IF_AVAILABLE ON CACHE BOOL "" FORCE) # Pinned, and the pin is a decision rather than a default. # # v0.46.0 -> v0.59.0 closes 17 releases. What made it worth doing, limited to # fixes that are actually REACHABLE through this service's surface - every # route here is a regex route, /fn/{project}/* is unauthenticated, and the web # UI is served from a static mount point: # v0.51.0 `chunked` matched only as the WHOLE Transfer-Encoding value, so a # final-coding spelling slipped past it - a request-smuggling shape, # and we sit behind nginx, which is where that class bites. # v0.51.0 an out-of-range Content-Length was cast straight to size_t and # silently truncated instead of being refused. # v0.57.0 control characters accepted in the chunk-size line. # v0.56.0 a Range first-byte-pos that overflows ssize_t now answers 416; # it reaches us because we serve static files. # v0.53.0 a static mount point was compared as a byte PREFIX rather than on # a path-segment boundary. # v0.52.0 listen backlog raised from 5 to 128, which five pending # connections overflow under ordinary churn. # # NOT the reason, and recorded because it was my first one and it was wrong: # v0.53.1's stack overflow in RegexMatcher::match() is real but was never # reachable here. CPPHTTPLIB_REQUEST_URI_MAX_LENGTH is 8192 in v0.46.0 too and # is enforced BEFORE routing, so a path long enough to overflow the stack is # answered 414 and never reaches the matcher. Checked in both headers rather # than taken from the changelog, and confirmed against a running server whose # identity was verified first: a ~4 KB path on /fn/ routes normally, ~10 KB and # ~16 KB are refused 414 before routing, and beyond that the client cannot # deliver the request at all. The server stayed up throughout. # # Other fixes in the range apply to code paths this project does not use - # multipart SENDING, chunked response trailers, WebSockets, Mbed TLS - so they # are not part of the case either. # # NOT v0.60.0, deliberately: its security fix is Mbed TLS hostname # verification and we build against OpenSSL, and its bug fixes are all # redirect behaviour, which applyOutboundDefaults() turns off. It buys this # project nothing and it was released the same day it was considered. FetchContent_Declare(httplib GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git GIT_TAG v0.59.0) FetchContent_MakeAvailable(httplib)