Add SameSite attribute to WebUI session cookie

This attribute prevents the cookie from being submitted on any cross-site request, strongly limiting CSRF.

Closes #9877.
This commit is contained in:
Thomas Piccirello 2018-11-20 02:56:30 -05:00 committed by sledgehammer999
commit 9cc112aa4e
No known key found for this signature in database
GPG key ID: 6E4A2D025B7CC9A2

View file

@ -657,7 +657,10 @@ void WebApplication::sessionStart()
QNetworkCookie cookie(C_SID, m_currentSession->id().toUtf8());
cookie.setHttpOnly(true);
cookie.setPath(QLatin1String("/"));
header(Http::HEADER_SET_COOKIE, cookie.toRawForm());
QByteArray cookieRawForm = cookie.toRawForm();
if (m_isCSRFProtectionEnabled)
cookieRawForm.append("; SameSite=Strict");
header(Http::HEADER_SET_COOKIE, cookieRawForm);
}
void WebApplication::sessionEnd()