Fossil SCM

Set the "SameSite=strict" value on cookies (used for authentication) as a further defense-in-depth against CSRF attacks.

drh 2023-09-18 15:36 csrf-defense-enhancement
Commit bc643c32f83424be76d6a1f260db1cb24c5fff3b947ccf9750ff81eca5ca27c7
1 file changed +3 -4
+3 -4
--- src/cgi.c
+++ src/cgi.c
@@ -314,17 +314,16 @@
314314
if( g.zBaseURL!=0 && fossil_strncmp(g.zBaseURL, "https:", 6)==0 ){
315315
zSecure = " secure;";
316316
}
317317
if( lifetime!=0 ){
318318
blob_appendf(&extraHeader,
319
- "Set-Cookie: %s=%t; Path=%s; max-age=%d; HttpOnly; "
320
- "%s Version=1\r\n",
319
+ "Set-Cookie: %s=%t; Path=%s; max-age=%d; HttpOnly; SameSite=strict;"
320
+ " %s\r\n",
321321
zName, lifetime>0 ? zValue : "null", zPath, lifetime, zSecure);
322322
}else{
323323
blob_appendf(&extraHeader,
324
- "Set-Cookie: %s=%t; Path=%s; HttpOnly; "
325
- "%s Version=1\r\n",
324
+ "Set-Cookie: %s=%t; Path=%s; HttpOnly; SameSite=strict; %s\r\n",
326325
zName, zValue, zPath, zSecure);
327326
}
328327
}
329328
330329
331330
--- src/cgi.c
+++ src/cgi.c
@@ -314,17 +314,16 @@
314 if( g.zBaseURL!=0 && fossil_strncmp(g.zBaseURL, "https:", 6)==0 ){
315 zSecure = " secure;";
316 }
317 if( lifetime!=0 ){
318 blob_appendf(&extraHeader,
319 "Set-Cookie: %s=%t; Path=%s; max-age=%d; HttpOnly; "
320 "%s Version=1\r\n",
321 zName, lifetime>0 ? zValue : "null", zPath, lifetime, zSecure);
322 }else{
323 blob_appendf(&extraHeader,
324 "Set-Cookie: %s=%t; Path=%s; HttpOnly; "
325 "%s Version=1\r\n",
326 zName, zValue, zPath, zSecure);
327 }
328 }
329
330
331
--- src/cgi.c
+++ src/cgi.c
@@ -314,17 +314,16 @@
314 if( g.zBaseURL!=0 && fossil_strncmp(g.zBaseURL, "https:", 6)==0 ){
315 zSecure = " secure;";
316 }
317 if( lifetime!=0 ){
318 blob_appendf(&extraHeader,
319 "Set-Cookie: %s=%t; Path=%s; max-age=%d; HttpOnly; SameSite=strict;"
320 " %s\r\n",
321 zName, lifetime>0 ? zValue : "null", zPath, lifetime, zSecure);
322 }else{
323 blob_appendf(&extraHeader,
324 "Set-Cookie: %s=%t; Path=%s; HttpOnly; SameSite=strict; %s\r\n",
 
325 zName, zValue, zPath, zSecure);
326 }
327 }
328
329
330

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button