Skip to content

fix(env): ignore CGI request metadata in $_SERVER as configuration - #44

Merged
brianvarskonst merged 5 commits into
mainfrom
fix/env-reader-ignore-request-metadata
Oct 23, 2026
Merged

brianvarskonst merged 5 commits into
mainfrom
fix/env-reader-ignore-request-metadata

Conversation

@brianvarskonst

@brianvarskonst brianvarskonst commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Finding

Review finding R-S2 (informational): EnvReader treated every $_SERVER entry except HTTP_* as an external configuration source with the highest precedence, and Dotenv interpolation (${NAME}) fell back to $_SERVER as well. No catalog name collides with CGI metadata today, so this is a surface reduction, not a vulnerability.

Change

  • The CGI meta-variables (RFC 3875 plus the usual SAPI additions: REQUEST_URI, REQUEST_METHOD, QUERY_STRING, PATH_INFO, REMOTE_ADDR, SERVER_NAME, SCRIPT_FILENAME, DOCUMENT_ROOT, CONTENT_TYPE, HTTPS, … matched by exact name) plus every HTTP_*, REDIRECT_* and PHP_AUTH_* entry follow the rule HTTP_* already had: they are read only when $_ENV or the real process environment supplies them. Exact names keep operator values such as SERVER_ROLE passed through fastcgi_param working.
  • The same boundary applies to interpolation: interpolationExternalValue(), the compiled templates (EnvCacheTemplates::resolve()) and Dotenv's own $_SERVER fallback during parsing (EnvCacheInterpolation::parse() hides the referenced request names for the duration of the parse).
  • EnvReader::isRequestMetaVariable() is @internal; docs/environment.md documents the boundary.
  • The change is part of the independent generated payload, so regenerating the configuration produces a new payload fingerprint (as with every reader change).

Verification

  • tests/Unit/EnvReaderServerBoundaryTest covers twelve request names, operator names with CGI-like prefixes, a request name supplied through $_ENV, and ${REQUEST_URI:-fallback} interpolation.
  • Environment, interpolation, wp-config, doctor, boot and unit suites pass; composer cs, composer static-analysis and tools/check-docs.py pass. Container-only failures are unchanged from main.

brianvarskonst and others added 5 commits October 24, 2026 00:02
The reader treated every $_SERVER entry except HTTP_* as an external
configuration source. Request metadata the web server derives from the
request (REQUEST_*, QUERY_STRING, PATH_INFO, REDIRECT_*, REMOTE_*, SERVER_*,
SCRIPT_*, ...) is now accepted only from the real process environment or
$_ENV, the same rule HTTP_* already followed.
…olation

The prefix list dropped operator values such as SERVER_ROLE passed through
fastcgi_param. Match the RFC 3875 meta-variables and SAPI additions by exact
name (plus HTTP_, REDIRECT_ and PHP_AUTH_ prefixes) and apply the same boundary
to Dotenv interpolation and compiled templates.
@brianvarskonst
brianvarskonst merged commit 15161b4 into main Oct 23, 2026
16 checks passed
@brianvarskonst
brianvarskonst deleted the fix/env-reader-ignore-request-metadata branch October 23, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant