Skip to content

Commit

Permalink
Backport zend-http security patch
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati committed Jan 30, 2019
1 parent cbf4350 commit d27a283
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
},
"zendframework/zend-code:2.6.3": {
"Fix continue switch in FileGenerator and MethodReflection": "zendframework/zend-code/switch-continue.patch"
},
"zendframework/zend-http:2.6.0": {
"Remove support for the X-Original-Url and X-Rewrite-Url headers": "zendframework/zend-http/no-x-original-url-x-rewrite.patch"
}
}
}
Expand Down
50 changes: 50 additions & 0 deletions zendframework/zend-http/no-x-original-url-x-rewrite.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From db28d37edcfc869c7e2c4e189efd789d18282025 Mon Sep 17 00:00:00 2001
From: Matthew Weier O'Phinney <matthew@zend.com>
Date: Mon, 11 Jun 2018 10:28:04 -0500
Subject: [PATCH] Remove support for the X-Original-Url and X-Rewrite-Url headers

This patch modifies the logic of `Zend\Http\PhpEnvironment\Request::detectRequestUri()`
such that it will ignore the X-Original-Url and X-Rewrite-Url headers
when marshaling the request URI.
---
src/PhpEnvironment/Request.php | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/src/PhpEnvironment/Request.php b/src/PhpEnvironment/Request.php
index 2cbef7e93..e27d81d27 100644
--- a/src/PhpEnvironment/Request.php
+++ b/src/PhpEnvironment/Request.php
@@ -436,18 +436,6 @@ class Request extends HttpRequest
$requestUri = null;
$server = $this->getServer();

- // Check this first so IIS will catch.
- $httpXRewriteUrl = $server->get('HTTP_X_REWRITE_URL');
- if ($httpXRewriteUrl !== null) {
- $requestUri = $httpXRewriteUrl;
- }
-
- // Check for IIS 7.0 or later with ISAPI_Rewrite
- $httpXOriginalUrl = $server->get('HTTP_X_ORIGINAL_URL');
- if ($httpXOriginalUrl !== null) {
- $requestUri = $httpXOriginalUrl;
- }
-
// IIS7 with URL Rewrite: make sure we get the unencoded url
// (double slash problem).
$iisUrlRewritten = $server->get('IIS_WasUrlRewritten');
@@ -456,12 +444,10 @@ class Request extends HttpRequest
return $unencodedUrl;
}

+ $requestUri = $server->get('REQUEST_URI');
+
// HTTP proxy requests setup request URI with scheme and host [and port]
// + the URL path, only use URL path.
- if (! $httpXRewriteUrl) {
- $requestUri = $server->get('REQUEST_URI');
- }
-
if ($requestUri !== null) {
return preg_replace('#^[^/:]+://[^/]+#', '', $requestUri);
}

0 comments on commit d27a283

Please sign in to comment.