Skip to content

Stop leaking the environment to student code - #316

Merged
AydinHassan merged 1 commit into
stack/1e-phpstan2from
stack/1e2-env-leak
Oct 22, 2026
Merged

AydinHassan merged 1 commit into
stack/1e-phpstan2from
stack/1e2-env-leak

Conversation

@AydinHassan

@AydinHassan AydinHassan commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

HostProcessFactory meant to strip the inherited environment before running student code, but:

  • It read the variable names from $_ENV, which is empty when variables_order lacks E (the usual production setting), so nothing was stripped and secrets leaked to the process
  • The line meant to also strip $_SERVER ($env + array_map(...)) discarded its result
  • When $_ENV was populated, PATH was stripped too, so composer could not find php

Now the names come from getenv(), and only PATH, HOME and COMPOSER_HOME are kept. Input env is merged over the defaults so it can override them.

🤖 Generated with Claude Code

@AydinHassan
AydinHassan added this pull request to stack #317 October 22, 2026 18:53
@AydinHassan AydinHassan changed the title Strip the inherited env via getenv() and keep PATH/HOME Stop leaking the environment to student code Oct 22, 2026
The env was stripped using $_ENV, which is empty when variables_order lacks E,
so secrets leaked to the process. When it was populated, PATH was removed too,
so composer could not find php. Input env now also overrides the defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AydinHassan
AydinHassan merged commit 1a2cb1c into master Oct 22, 2026
4 checks passed
An error occurred while trying to automatically change base from stack/1e-phpstan2 to master October 22, 2026 19:02
@AydinHassan
AydinHassan deleted the stack/1e2-env-leak branch October 22, 2026 21:11
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