ext/standard: reject control characters in the from address#170
Closed
iliaal wants to merge 1 commit into
Closed
Conversation
The ftp and http wrappers build protocol data out of FG(from_address) without the control-character check they already apply to a URL-supplied password, so a from address carrying CRLF injects a command after PASS and a header after From. Validate at both sinks. The from ini setting is PHP_INI_ALL, so this is consistency with the existing checks rather than a trust boundary.
iliaal
force-pushed
the
std-ss006-ftp-from-pass-ctl
branch
from
July 16, 2026 15:02
fd3ed58 to
f28947c
Compare
Owner
Author
|
Superseded. The HTTP The FTP PASS half was the part that was genuinely missing (21658 deferred FTP/SOAP): php#22770, on master, reusing the existing PHP_FTP_CNTRL_CHK macro. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ftp and http wrappers both build protocol data out of
FG(from_address)without the control-character check they already apply to a URL-supplied password (ftp_fopen_wrapper.c:243,:260). A from address carrying CRLF injects a command into the FTP control channel after PASS, and a header into the HTTP request after From:Both sinks now validate. The ftp wrapper fails the connection the way it already does for a bad URL password; the http wrapper drops the optional From header and warns, matching how it handles a User-agent it cannot construct.
Framing:
fromis PHP_INI_ALL, so setting it needs php.ini/.htaccess or ini_set(), and either already grants more than the injection buys. This is consistency with the checks at :243 and :260, not a trust boundary.user_agentsits at the same INI level and reaches the same request builder unvalidated, so it has the same shape.