/

CVE-2026-29046

Severity:

HIGH RISK

(8.2)

Improper Input Validation in TinyWeb CGI Environment Mapping

CVE-2026-29046

Analyzed

Vulnerability type

Category:

Improper Input Validation

CWE:

CWE-20, CWE-74, CWE-93, CWE-114

Impact:

CGI Environment Manipulation and Header Injection

Severity:

HIGH RISK

(8.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

TinyWeb, a Win32 web server written in Delphi, insufficiently validated HTTP request headers before mapping them into CGI environment variables.

Because control characters and some encoded forms were not strictly rejected, attackers may confuse downstream header parsing and introduce unsafe data into the CGI execution context under certain request patterns.

Affected context

This vulnerability affects TinyWeb deployments that:

  • Use CGI or other components that rely on environment variables derived from HTTP headers (HTTP_*)
  • Accept client-controlled HTTP headers without additional sanitization at the application layer
  • Run on versions prior to TinyWeb 2.04, where header parsing did not strictly reject CR, LF, NUL, and associated encoded forms

The risk is particularly relevant where CGI scripts or helper programs interpret environment variables as configuration, headers, or command parameters.

Exploit preconditions

  • Attack surface: Network-exposed HTTP/HTTPS endpoints served by TinyWeb.
  • Required access: Ability to send crafted HTTP requests to the server (no prior authentication necessarily required).
  • Trigger point: Processing of malicious header lines whose values contain CR, LF, NUL, or their encoded representations (e.g., %0d, %0a, %00).
  • Why exploitation is possible: TinyWeb's header parser failed to consistently reject or normalize dangerous control characters before mapping header values into CGI environment variables, allowing conflicting interpretations between TinyWeb and downstream CGI components.

Why this happens

The root cause is improper input validation (CWE-20) during HTTP header parsing and translation into CGI environment variables.

TinyWeb trusted header lines and values that contained control characters such as carriage return (CR), line feed (LF), and NUL, and did not consistently treat encoded variants as invalid.

When these unvalidated values were mapped into the CGI environment (e.g., HTTP_X_CUSTOM), they could be interpreted differently by downstream parsers or APIs.

This behavior overlaps with:

  • CWE-74 (Injection): Because untrusted header values can flow into other interpreters or command contexts via CGI variables.
  • CWE-93 (Improper Neutralization of CRLF in Headers): Due to potential header or line confusion caused by CR/LF.
  • CWE-114 (Process Control): When environment variables influence how CGI or helper processes load configuration or external components.

Potential impact

  • Injection of unexpected line breaks into CGI environment variables, which may confuse downstream HTTP or configuration parsing.
  • Manipulation of CGI environment variables so that scripts misinterpret user input as metadata, headers, or control fields.
  • Potential header response splitting or header confusion in CGI-based applications that reflect environment variables into HTTP responses.
  • Alteration of environment-driven behavior in CGI programs, potentially leading to privilege misuse, unsafe configuration loading, or indirect code execution paths where such behavior exists.
  • Increased likelihood of chaining with other vulnerabilities (e.g., command injection in CGI scripts that trust environment variables).

General mitigation guidance

Effective mitigation focuses on strict parsing and normalization of HTTP headers before they are exposed to downstream components:

  • Reject header lines containing raw CR, LF, NUL, or other non-printable control characters, rather than attempting to repair them.
  • Decode percent-encoded header values early and apply the same validation rules to encoded forms such as %0d, %0a, and %00.
  • Normalize accepted header values to a safe subset (e.g., printable ASCII without control characters) before mapping them into CGI environment variables.
  • At the application/CGI layer, treat environment variables derived from HTTP headers as untrusted input, validating and sanitizing them according to strict schemas.
  • Limit how environment variables influence security-critical decisions such as module loading, configuration selection, or external process invocation, following least-privilege and least-configuration principles.

How teams detect issues like this

Detection can combine code-centric and behavior-centric approaches:

  • Static analysis and code review:
  • Look for HTTP parsing code that copies raw header values directly into environment variables, process arguments, or configuration structures.
  • Flag usage patterns where control characters are not explicitly rejected or where validation only checks for a small subset of unsafe characters.
  • Review any mapping logic from Header-Name: to HTTP_HEADER_NAME environment variables to ensure normalization and validation are applied.
  • Security testing and fuzzing:
  • Use HTTP fuzzers to send headers containing CR, LF, NUL, and their URL-encoded equivalents, observing how CGI scripts and logs interpret them.
  • Monitor for discrepancies between what TinyWeb logs and what CGI environment variables contain.
  • Operational monitoring:
  • Enable verbose logging of unusual or malformed request headers and correlate with CGI or application errors.
  • Consider web application firewall (WAF) policies that block headers containing control characters or suspicious encodings before they reach TinyWeb.

Sources

SourceLink
github.comgithub.com/maximmasiutin/TinyWeb/commit/53aa8b6e5146491d7be57920e3fc50d7a34e4d5a
github.comgithub.com/maximmasiutin/TinyWeb/security/advisories/GHSA-r3gf-pg2c-m7mc

Frequently asked

questions

Yes. An attacker who can reach the TinyWeb HTTP/HTTPS service can send crafted requests with malicious headers to trigger the issue, without needing local access.

Not necessarily. The vulnerable behavior occurs during HTTP header parsing, which is typically performed before authentication. However, in some deployments, only authenticated endpoints may expose specific CGI scripts that make exploitation more impactful.

The safest fix is to implement strict, centralized header validation that rejects any header line or value containing control characters (including encoded forms) before mapping them to CGI environment variables or other internal representations. Additionally, CGI scripts should treat all environment-derived values as untrusted input.

Future implementations should:

  • Define a clear allowed character set and schema for header values and enforce it at the parsing boundary.
  • Normalize and validate all decoded forms of input before use.
  • Apply a defense-in-depth model where downstream components (such as CGI scripts) re-validate critical environment values.
  • Adopt secure coding guidelines and automated checks for input validation around protocol parsing and environment handling.
Find out what's already
exploitable in your codebase.