Repository navigation
mod_rewrite: Check UNCList before prefix_stat() probes a UNC path - #828
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
On Windows, prefix_stat() calls apr_filepath_root() with APR_FILEPATH_TRUENAME on the substitution result before any UNC check. For a UNC path this contacts the host, so a RewriteRule producing one could cause a network lookup even though UNCList denies it. Call ap_stat_check() first, like the file tests of RewriteCond do. PR 70210.
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.
On Windows, prefix_stat() calls apr_filepath_root() with APR_FILEPATH_TRUENAME on the result of a server-context RewriteRule before any UNC check. For a UNC path this makes APR call GetDriveTypeW() on the
\\host\share\root, which contacts the host. With UNCList unset (all UNC access denied), a RewriteRule that produces a UNC path therefore still triggers a network lookup, and a worker waits for it, before the path is rejected.This calls ap_stat_check() first, like the file tests of RewriteCond already do since r1927033. ap_stat_check() is a no-op on other platforms. If the check refuses the path, prefix_stat() returns 0, the same result as when the root probe failed, so the final response is unchanged (404) but without the network access. An allowed host still takes the old path.
PR 70210.
The test is Windows only (UNCList does not exist elsewhere), so it is skipped on Unix. I could only check the Unix side locally: mod_rewrite builds and the pytest_suite rewrite tests give the same results as before.
(see
SECURITY.mdandhttps://www.apache.org/security/#reporting-a-vulnerability).
APLOGNO()tag;numbers are assigned by a committer at merge time (see
docs/log-message-tags/README).(No new log messages with a tag; the new rewritelog() line has none.)
changes-entries/*.txtfile is included,following the template in
README.CHANGES(not needed otherwise).test/modules/xxxdirectory matching themodules/xxxmodule source,or
test/modules/corefor core server changes. On Unix, verify thesepass locally with e.g.
make check-pytest PYTEST_DIRS=test/modules/xxx.