You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
The Illuminate\Http\JsonResponse class extending the Symfony\Component\HttpFoundation\JsonResponse class, overwrites the default encodingOptions with 0 value.
The Symfony defaults are more secure than the 0 value defined by Laravel.
class JsonResponse extends Response
{
// Encode <, >, ', &, and " characters in the JSON, making it also safe to be embedded into HTML.
// 15 === JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT
const DEFAULT_ENCODING_OPTIONS = 15;
protected $encodingOptions = self::DEFAULT_ENCODING_OPTIONS;
The "0" encodingOptions is not safe when the data is embeded into html
I know this problem is not easily exploitable with direct API call in web browsers and in all other cases, users should not print json in html context without html encoding it first.
But we never know how data will be used and frameworks should have defaults as secured as possible.
In this case, the default encoding options used by Symfony are more secure than the default 0 value of Illuminate\Http\JsonResponse.
Steps To Reproduce:
class TestController extends Controller
{
public function test()
{
return Response::json('<script>alert("abc");</script>');
}
}
Description:
Hi!
The
Illuminate\Http\JsonResponse
class extending theSymfony\Component\HttpFoundation\JsonResponse
class, overwrites the defaultencodingOptions
with0
value.The Symfony defaults are more secure than the
0
value defined by Laravel.The "0" encodingOptions is not safe when the data is embeded into html
The same problem has been reported to Express : expressjs/express#3268
I know this problem is not easily exploitable with direct API call in web browsers and in all other cases, users should not print json in html context without html encoding it first.
But we never know how data will be used and frameworks should have defaults as secured as possible.
In this case, the default encoding options used by Symfony are more secure than the default
0
value ofIlluminate\Http\JsonResponse
.Steps To Reproduce:
It should return
Instead of
Thanks. :)
The text was updated successfully, but these errors were encountered: