Project

General

Profile

Actions

Bug #11134

closed

Set samesite header for cookies correctly

Added by Marc Egger over 3 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Carsten Rose
Target version:
Start date:
08.09.2020
Due date:
07.12.2021
% Done:

0%

Estimated time:
Discuss:
Prio Planung:
Vote:

Description

Firefox warnt, dass das qfq cookie bald abgelehnt wird, weil das samesite attribute nicht richtig gesetzt wurde.

Ab PHP 7.3 kann der default in php.ini festgelegt werden.

Todo:
  • Default samesite in QFQ setzen, allenfalls in den settings konfigurierbar machen

info zu samesite : "allows you to declare if your cookie should be restricted to a first-party or same-site context. " (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite)
samesite in php setzen : https://stackoverflow.com/a/51128675

Firefox warning : Cookie “qfq” will be soon rejected because it has the “SameSite” attribute set to “None” or an invalid value, without the “secure” attribute. To know more about the “SameSite“ attribute, read https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite

Actions #1

Updated by Marc Egger over 3 years ago

  • Status changed from New to Priorize
Actions #2

Updated by Carsten Rose over 3 years ago

  • Tracker changed from Support to Bug
Actions #3

Updated by Marc Egger about 3 years ago

  • Priority changed from Normal to High

Laut https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
sollten unsere Cookies jetzt schon abgelehnt werden, falls samesite nicht richtig gesetzt ist. Bis jetzt hatten wir jedoch keine probleme

Actions #4

Updated by Carsten Rose almost 3 years ago

  • Status changed from Priorize to New
  • Priority changed from High to Normal
  • Target version changed from next5 to next7

Laut dem SO Beitrag kann PHP das erst ab Version >=7.3. Ubuntu 18.04 hat noch PHP 7.2 (stattdessen muesste man Apache oder nginx entpsrechend ein rewrite konfigurieren).

Wenn die Browser kein Problem machen: wir warten bis Ubunt 20.04 Standard bei uns ist.

Actions #5

Updated by Marc Egger almost 3 years ago

  • Due date set to 01.09.2021

Bei Duedate erreicht:

Ist Ubuntu 20.04 schon Standard bei uns?

JA: Samesite in php.ini festlegen

NEIN: Duedate verschieben.

Actions #6

Updated by Marc Egger almost 3 years ago

  • Status changed from New to Priorize
Actions #7

Updated by Marc Egger over 2 years ago

  • Status changed from Priorize to In Progress
Actions #8

Updated by Marc Egger over 2 years ago

  • Due date changed from 01.09.2021 to 24.09.2021
  • Status changed from In Progress to New
  • Assignee changed from Marc Egger to Carsten Rose
  • Target version changed from next7 to 21.12.0
Actions #9

Updated by Enis Nuredini over 2 years ago

  • Due date changed from 24.09.2021 to 07.12.2021
  • Assignee changed from Carsten Rose to Enis Nuredini
  • Wie in T3: check ob PHP (>=7.3) das supported
  • wenn ja: check ob es bereits aktiv ist (php.ini) - wenn nein: setzen
Actions #10

Updated by Carsten Rose over 2 years ago

  • Target version changed from 21.12.0 to 355
Actions #11

Updated by Enis Nuredini over 2 years ago

  • Status changed from New to Priorize
Actions #12

Updated by Enis Nuredini about 2 years ago

  • Status changed from Priorize to ToDo
Actions #13

Updated by Enis Nuredini about 2 years ago

  • Status changed from ToDo to In Progress
Actions #14

Updated by Enis Nuredini about 2 years ago

Aktuelle Situation und Umsetzung von mir:
session_set_cookie_params() Parameter mussten so ergänzt werden dass das Samesite Attribut mitgegeben wird bei PHP V. < 7.3.
Durch eine IF Abfrage der PHP V. werden nun die Parameter auch unter >= 7.3 ebenfalls korrekt gesetzt.

Fact: Mit der Methode session_get_cookie_params() kann das Samesite Attribut nur unter PHP V. >= 7.3 abgeholt werden. Ältere Versionen geben alle Attribute mit Ausnahme von Samesite zurück.

Nach dem Session start wird üblicherweise noch der setcookie() ausgeführt.
Hier funktioniert der bisherig verwendete setcookie() unter PHP <7.3 nicht mehr, falls Samesite gesetzt werden sollte.
Es existiert die Alternative header() Methode, bei dem die Möglichkeit besteht den Samesite mitzugeben. Eine IF Abfrage ist implementiert um zwischen den PHP Versionen zu unterscheiden. Bei PHP >= 7.3 wird setcookie() verwendet, da dort auch das Samesite mitgegeben werden kann.

Nun erscheint die oben genannte Warnung (Samesite) nicht mehr im Firefox! Testen konnte ich es nur unter PHP V 7.2.

Achtung bei folgenden Warnungen:
"Cookie “qfq” will be soon treated as cross-site cookie against “http://webwork16.math.uzh.ch/...” because the scheme does not match. "

Diese haben nicht direkt etwas mit dem Samesite header zu tun, welcher als Warnung so erscheint:
"Cookie “qfq” will be soon rejected because it has the “SameSite” attribute set to “None” or an invalid value, without the “secure” attribute. To know more about the “SameSite“ attribute, read https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite index.php"

Die cross-site cookie Warnungen werden getriggert weil Firefox auch die Cookies von anderen Webseiten, die im Browser Speicher hinterlegt sind und unter der gleichen URL ("localhost:Port number") aufgerufen werden, anzeigt. Diese Warnungen verschwinden wenn die Cookies der betroffenen URL im Browser entfernt werden (in meinem Fall: ' webwork16.math.uzh.ch' ).

Hier gibt es noch eine Diskussion zu dem Thema Cross-Site Cookie:
https://stackoverflow.com/questions/63297970/cookie-phpsessid-will-be-soon-treated-as-cross-site-cookie-against-file-beca

Wurde Commited und Merge Request wurde gemacht.

Actions #15

Updated by Enis Nuredini about 2 years ago

  • Assignee changed from Enis Nuredini to Carsten Rose
Actions #16

Updated by Enis Nuredini about 2 years ago

  • Status changed from In Progress to Ready to sync (develop)
Actions #17

Updated by Carsten Rose almost 2 years ago

  • Target version changed from 355 to 22.5.0
Actions #18

Updated by Carsten Rose almost 2 years ago

  • Status changed from Ready to sync (develop) to Closed
Actions

Also available in: Atom PDF