Skip to content

Commit 06fc97e

Browse files
committed
feature symfony#11367 [HttpFoundation] Fix to prevent magic bytes injection in JSONP responses... (CVE-2014-4671) (Andrew Moore)
This PR was merged into the 2.3 branch. Discussion ---------- [HttpFoundation] Fix to prevent magic bytes injection in JSONP responses... (CVE-2014-4671) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no* | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | N/A | CVE Ticket | [CVE-2014-4671](http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-4671) | See Also | [Rosetta Flash](http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/) \* Unless you are parsing the response string manually, which you really shouldn't do anyway **THIS IS A SECURITY FIX AND SHOULD BE MERGED SHORTLY** This fix prevents attacks vectors where third-party browser plugins depends on ASCII magic bytes in order to execute a plugin. This is currently exploited with Flash using a carefully crafted JSONP response, allowing the execution of random SWF data from a domain with a vulnerable JSONP endpoint. This security issue is mitigated by adding an empty comment right before the callback parameter. This does not affect the execution of the JSONP callback. Commits ------- 6af3d05 [HttpFoundation] Fix to prevent magic bytes injection in JSONP responses (Prevents CVE-2014-4671)
2 parents 3c54659 + 6af3d05 commit 06fc97e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/HttpFoundation/JsonResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function update()
111111
// Not using application/javascript for compatibility reasons with older browsers.
112112
$this->headers->set('Content-Type', 'text/javascript');
113113

114-
return $this->setContent(sprintf('%s(%s);', $this->callback, $this->data));
114+
return $this->setContent(sprintf('/**/%s(%s);', $this->callback, $this->data));
115115
}
116116

117117
// Only set the header when there is none or when it equals 'text/javascript' (from a previous update with callback)

src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function testSetCallback()
155155
{
156156
$response = JsonResponse::create(array('foo' => 'bar'))->setCallback('callback');
157157

158-
$this->assertEquals('callback({"foo":"bar"});', $response->getContent());
158+
$this->assertEquals('/**/callback({"foo":"bar"});', $response->getContent());
159159
$this->assertEquals('text/javascript', $response->headers->get('Content-Type'));
160160
}
161161

0 commit comments

Comments
 (0)