Files
SimpleRemoter/server/2015Remote
yuanyuanxiang 4f9bfb0fdc fix(server): stop two remote-input paths from killing the server
Both bugs let a remote peer terminate the server process: the first needs no
credentials at all, the second needs only a malicious client.

1) cpp-httplib 0.14.3 -- unauthenticated DoS via Content-Length

Content-Length was parsed with strtoull, which accepts a leading sign, so
"-1" wrapped around to ULLONG_MAX. read_content then treated that as an
oversized body and called skip_content_with_length(strm, ULLONG_MAX), a loop
that only exits after consuming 18 EB -- a client trickling bytes never trips
the read timeout, so the worker thread is stuck forever. With ThreadPool(32)
that is 32 connections to wedge the whole server. Body parsing runs before
the MCP token check, so no token is required.

Backported from upstream 0.51.0/0.64.0 as parse_content_length_strict(): only
plain decimal digits are accepted and overflow is rejected. Upgrading the
library instead is not possible -- 0.25.0+ requires _WIN32_WINNT >= 0x0A00
(Win10) while this project targets 0x0602 (Win8), and the last Win8-compatible
release (0.20.0) predates the fix.

Verified: negative, leading-plus, overflow and trailing-garbage values now all
return 400; 40 concurrent "-1" requests are rejected in under 50 ms with the
thread pool still healthy; plain and chunked requests are unaffected.

2) HideScreenSpyDlg::JPG_BMP -- malformed JPEG terminated the process

The decoder was set up with libjpeg's default error_exit, which calls
exit(EXIT_FAILURE). Since the input is a JPEG stream sent by the remote
client, one structurally invalid frame killed the whole server. Replaced with
a setjmp/longjmp handler that turns fatal errors into "return false", matching
this function's existing failure paths. Warnings still go through
emit_message, so truncated-but-recoverable images behave exactly as before.

Verified against 36 malformed samples: 19 used to terminate the process, none
do now (the same 19 return false), and valid JPEGs decode identically.

3) Drop the dead file_server.h

An older HTTP file-serving implementation, superseded by WebService.cpp and
referenced by nothing: no include anywhere, no instantiation, no entry in the
vcxproj or any build script. Removing it keeps the real HTTP attack surface --
httplib's /mcp plus WebService -- unambiguous for anyone auditing this code.
2026-11-01 14:33:58 +01:00
..
2026-10-31 18:24:54 +01:00