Issue Task Closed

#109739Fix SameSite=None handling and ensure correct cookie removal attributes

TYPO3 GmbH TYPO3com 05/01/26, 09:32 updated 10/06/26, 16:00

Description

This patch fixes incorrect handling of cookie attributes in the core HTTP cookie service, ensuring valid SameSite behavior and consistent cookie removal.

## Fix:
#### 1. Invalid SameSite=None handling on non-HTTPS

SameSite=None cookies require the Secure flag and must only be used over HTTPS.
The previous implementation could force the Secure flag even on non-HTTPS requests, resulting in cookies being ignored by browsers.

This patch ensures:
- SameSite=None is only used on HTTPS requests
- fallback to SameSite=Strict on non-HTTPS requests
- Secure flag is only set when the request is HTTPS

#### 2. Incorrect cookie removal semantics

Cookie removal did not consistently preserve important attributes such as:
- domain / hostOnly
- Secure flag
- HttpOnly flag
- SameSite policy

Since browsers require exact attribute matching for deletion, this could result in cookies not being removed properly.

This patch ensures cookie removal uses consistent attributes, preventing stale cookies.

This issue was automatically created from https://github.com/TYPO3/typo3/pull/632

Reviews 1

History 23

  1. Georg Ringer commented and changed status Under Review Closed <span data-processor="relativetime" data-value="2026-10-06T16:00:24+00:00" > 10/06/26, 16:00 </span>

    Closing: the cookie removal attributes were already fixed with #107895, and silently downgrading a configured SameSite=None to Strict on HTTP would hide a misconfiguration and reverse its intent rather than fix it.