Regarding to:
- https://laravel.com/docs/5.3/passport#consuming-your-api-with-javascript
- https://github.com/laravel/passport/blob/1.0/src/ApiTokenCookieFactory.php
Let's assume that Access-Control-Allow-Origin: *
So we have this scenario: I'm authorized as myself getting laravel_token set in into my cookies and csrfToken provided to the frontend framework.
Please tell me why I could not easily create new laravel_token using already provided csrfToken, put it into my cookie and send it to the backend being authorized as different user?
Route::get('/token', function(\Laravel\Passport\ApiTokenCookieFactory $factory, Request $request) {
$cookie = $factory->make(
25665, // different user's ID to be attacked
$providedVisibleCSRFToken
);
return response()->json(['X-CSRF-TOKEN' => $providedVisibleCSRFToken, 'JWT-TOKEN' => $cookie->getValue()]);
});
From now on, when I change the cookie to have my hijacked JWT with different user wouldn't I be logged as him, right?