Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f27dd4b

Browse filesBrowse files
security #cve-2018-19790 [Security\Http] detect bad redirect targets using backslashes (xabbuh)
This PR was merged into the 2.7 branch. Discussion ---------- [Security\Http] detect bad redirect targets using backslashes | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #76 | License | MIT | Doc PR | Commits ------- 99a0cec [Security\Http] detect bad redirect targets using backslashes
2 parents b65e6f1 + 99a0cec commit f27dd4b
Copy full SHA for f27dd4b

File tree

Expand file treeCollapse file tree

2 files changed

+17
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-3
lines changed

‎src/Symfony/Component/Security/Http/HttpUtils.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/HttpUtils.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct(UrlGeneratorInterface $urlGenerator = null, $urlMatc
5959
*/
6060
public function createRedirectResponse(Request $request, $path, $status = 302)
6161
{
62-
if (null !== $this->domainRegexp && preg_match('#^https?://[^/]++#i', $path, $host) && !preg_match(sprintf($this->domainRegexp, preg_quote($request->getHttpHost())), $host[0])) {
62+
if (null !== $this->domainRegexp && preg_match('#^https?:[/\\\\]{2,}+[^/]++#i', $path, $host) && !preg_match(sprintf($this->domainRegexp, preg_quote($request->getHttpHost())), $host[0])) {
6363
$path = '/';
6464
}
6565

‎src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php
+16-2Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,28 @@ public function testCreateRedirectResponseWithRequestsDomain()
5454
$this->assertTrue($response->isRedirect('http://localhost/blog'));
5555
}
5656

57-
public function testCreateRedirectResponseWithBadRequestsDomain()
57+
/**
58+
* @dataProvider badRequestDomainUrls
59+
*/
60+
public function testCreateRedirectResponseWithBadRequestsDomain($url)
5861
{
5962
$utils = new HttpUtils($this->getUrlGenerator(), null, '#^https?://%s$#i');
60-
$response = $utils->createRedirectResponse($this->getRequest(), 'http://pirate.net/foo');
63+
$response = $utils->createRedirectResponse($this->getRequest(), $url);
6164

6265
$this->assertTrue($response->isRedirect('http://localhost/'));
6366
}
6467

68+
public function badRequestDomainUrls()
69+
{
70+
return array(
71+
array('http://pirate.net/foo'),
72+
array('http:\\\\pirate.net/foo'),
73+
array('http:/\\pirate.net/foo'),
74+
array('http:\\/pirate.net/foo'),
75+
array('http://////pirate.net/foo'),
76+
);
77+
}
78+
6579
public function testCreateRedirectResponseWithProtocolRelativeTarget()
6680
{
6781
$utils = new HttpUtils($this->getUrlGenerator(), null, '#^https?://%s$#i');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.