Skip to content

Commit 4033c72

Browse files
0xLanks0xLanks
0xLanks
authored and
0xLanks
committed
Added 'SameSite=Strict' cookie attribute, reducing overall CSRF attack surface
1 parent 11b9f17 commit 4033c72

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

BlogEngine/BlogEngine.NET/Global.asax

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,17 @@
1212
{
1313
BlogEngineConfig.SetCulture(sender, e);
1414
}
15+
16+
protected void Application_PreSendRequestHeaders ()
17+
{
18+
var httpContext = HttpContext.Current;
19+
if (httpContext != null) {
20+
var cookieValueSuffix = "; SameSite=Strict";
21+
var cookies = httpContext.Response.Cookies;
22+
for (var i = 0; i < cookies.Count; i++)
23+
{
24+
var cookie = cookies[i]; cookie.Value += cookieValueSuffix;
25+
}
26+
}
27+
}
1528
</script>

0 commit comments

Comments
 (0)