96 lines
11 KiB
Markdown
96 lines
11 KiB
Markdown
---
|
|
title: official-doc / MDN — Set-Cookie SameSite Attribute (Strict / Lax / None Semantics)
|
|
source_type: official-doc
|
|
url: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie
|
|
archive_url: http://web.archive.org/web/20260723032604/https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie
|
|
related_branches: [feature-keycloak-bff-csrf-samesite-defense]
|
|
related_projects: []
|
|
tags: [official-doc, keycloak-patterns, security, auth, http]
|
|
created: 2026-07-23
|
|
---
|
|
|
|
# official-doc / MDN — Set-Cookie SameSite Attribute (Strict / Lax / None Semantics)
|
|
|
|
> Layer: `raw/` — 외부 자료(공식 문서)의 **원문 발췌·출처 기록**.
|
|
> 본 템플릿은 `raw/official-docs/` 와 `raw/company-tech-blogs/` 두 폴더가 공유.
|
|
> 검증된 요약은 `/ingest` 후 `wiki/concepts/`에 `source-summary-template` 형식으로 별도 작성. 원본은 raw에 영구 보관.
|
|
|
|
## source_type 허용값
|
|
|
|
`official-doc` — 공식 레퍼런스 (MDN Web Docs, `Set-Cookie` HTTP 응답 헤더의 `SameSite` attribute 섹션).
|
|
|
|
## Parent / 활용 branch (필수, 최소 1개+)
|
|
|
|
| Branch | 이 자료가 정당화하는 결정 |
|
|
|---|---|
|
|
| [[raw/branch-notes/feature-keycloak-bff-csrf-samesite-defense]] | D2 — AP3 BFF `SESSION` 쿠키에 어떤 `SameSite` 값(`Strict` / `Lax` / `None`)을 CSRF 방어로 설정할지 결정하는 근거. 이 자료는 `Strict`/`Lax`/`None` 각각의 정확한 전송 semantics(언제 cross-site 요청에 쿠키가 실리고 안 실리는지), `SameSite` 미지정 시 브라우저 기본값(`Lax`), `None` 사용 시 `Secure` 필수 요건을 verbatim 으로 확보한다. |
|
|
|
|
## 출처 / Source
|
|
|
|
- 원본 URL: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie/SameSite (요청된 원본 URL — **404**, 아래 "왜 저장했는지" 참조)
|
|
- 실제 확인 URL(사용): https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie (`SameSite` 는 이 통합 `Set-Cookie` reference 문서의 하위 섹션, anchor `#samesitesamesite-value` / `#strict` / `#lax` / `#none`)
|
|
- 아카이브 URL: http://web.archive.org/web/20260723032604/https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie
|
|
- 저자 / 조직: MDN Web Docs (Mozilla), 커뮤니티 편집 공식 웹 플랫폼 레퍼런스
|
|
- 발행일: 페이지에 명시된 발행일 없음 (MDN 은 지속 갱신되는 living reference)
|
|
- 마지막 확인일: 2026-07-23
|
|
|
|
## 왜 저장했는지 / Why archived
|
|
|
|
사용자가 요청한 원본 URL `.../Set-Cookie/SameSite` 은 standalone 페이지가 아니라 **404** 를 반환한다(리다이렉트 아님 — `curl -I -L` 확인, HTTP 404 그대로). MDN 최신 정보 구조에서 `SameSite` 는 별도 페이지가 아니라 `Set-Cookie` 헤더 reference 문서 안의 하위 attribute 섹션으로 통합되어 있다. 이 페이지의 `SameSite=<samesite-value>` 섹션(그 안의 `Strict`/`Lax`/`None` sub-definition)을 대신 archive 했다 — `feature-keycloak-bff-csrf-samesite-defense` branch 의 D2(AP3 BFF SESSION 쿠키의 SameSite 값 선택)를 정당화하는 1차 공식 근거.
|
|
|
|
## 핵심 인용 / Key quotes (verbatim, 5문장)
|
|
|
|
> [§SameSite → Strict] "Send the cookie only for requests originating from the same site that set the cookie."
|
|
|
|
> [§SameSite → Lax] "Send the cookie only for requests originating from the same site that set the cookie, and for cross-site requests that meet both of the following criteria:"
|
|
|
|
> [§SameSite → Lax, 두 번째 기준] "The request uses a safe method: in particular, this excludes POST, PUT, and DELETE."
|
|
|
|
> [§SameSite → None] "Send the cookie with both cross-site and same-site requests.
|
|
> The Secure attribute must also be set when using this value."
|
|
|
|
> [§SameSite → Lax, 기본값 각주] "Some browsers use Lax as the default value if SameSite is not specified: see Browser compatibility for details."
|
|
|
|
## Claims Extracted / 추출된 주장
|
|
|
|
| Claim ID | Claim (이 자료가 직접 말하는 것) | Evidence quote | Strength | Applies to | Does not prove |
|
|
|---|---|---|---|---|---|
|
|
| MDN-SAMESITE-C1 | `SameSite=Strict` 쿠키는 그 쿠키를 설정한 것과 **같은 site 로부터 발생한 요청에만** 전송된다 — cross-site 요청(최상위 탐색 포함)에는 절대 실리지 않는다. | [§Strict] "Send the cookie only for requests originating from the same site that set the cookie." | `official-reference` | 세션 쿠키에 `SameSite=Strict` 를 적용했을 때의 cross-site 완전 차단 semantics 확인 | 어떤 상황에서 `Strict` 를 써야 하는지(UX trade-off, 외부 링크로 진입 시 로그아웃처럼 보이는 문제)는 이 문장이 직접 다루지 않음 |
|
|
| MDN-SAMESITE-C2 | `SameSite=Lax` 쿠키는 same-site 요청에는 항상 전송되고, cross-site 요청 중에서는 **두 기준을 모두 만족**하는 경우에만 전송된다(다른 기준은 "top-level navigation" — C3 은 그중 하나인 safe method 기준). | [§Lax] "Send the cookie only for requests originating from the same site that set the cookie, and for cross-site requests that meet both of the following criteria:" | `official-reference` | `Lax` 가 조건부로만 cross-site 전송을 허용한다는 원칙 확인 | "top-level navigation" 자체의 상세 정의(예: `fetch()`/`<img>`/`<iframe>` 은 제외, 링크 클릭/`document.location`/`<form>` 제출은 포함)는 이 인용 자체에는 없음(같은 페이지 다른 문단에 있으나 별도 Claim 으로 분리하지 않음 — 메모 참조) |
|
|
| MDN-SAMESITE-C3 | `SameSite=Lax` cross-site 허용 기준 중 하나는 "safe" HTTP method 사용이며, `POST`/`PUT`/`DELETE` 는 명시적으로 **제외**된다 — 즉 cross-site `POST` 요청에는 `Lax` 쿠키가 (기본값이 아닌 명시적 `Lax` 로) 실리지 않는다. | [§Lax] "The request uses a safe method: in particular, this excludes POST, PUT, and DELETE." | `official-reference` | cross-site state-changing 요청(POST 기반 CSRF 공격 벡터)에 명시적 `SameSite=Lax` 쿠키가 실리지 않는다는 근거 | 브라우저가 기본값으로 `Lax` 를 적용할 때는 "더 관대한 버전"이 적용되어 예외가 있음(C5 의 각주 참조) — C3 의 배제는 **명시적으로 설정된** `Lax` 에 대한 서술이지, 기본값-`Lax` 의 permissive 예외까지 부정하지 않는다 |
|
|
| MDN-SAMESITE-C4 | `SameSite=None` 쿠키는 cross-site 와 same-site 요청 모두에 전송되며, 이 값을 사용할 때는 `Secure` attribute 도 **반드시 함께 설정**해야 한다. | [§None] "Send the cookie with both cross-site and same-site requests.\nThe Secure attribute must also be set when using this value." | `official-reference` | `None` 이 CSRF 방어 목적으로는 사용할 수 없는 값이며(cross-site 무조건 전송), 사용 시 `Secure` 가 필수 요건임을 확인 | `Secure` 누락 시 브라우저가 정확히 어떻게 처리하는지(무시/거부 등 구현별 동작)는 이 문장 자체가 규정하지 않음 |
|
|
| MDN-SAMESITE-C5 | `SameSite` attribute 를 명시하지 않으면 일부 브라우저는 `Lax` 를 기본값으로 취급한다. | [§Lax, 기본값] "Some browsers use Lax as the default value if SameSite is not specified: see Browser compatibility for details." | `official-reference` | `SameSite` 를 생략했을 때의 브라우저 기본 동작(전부는 아니고 "일부 브라우저"라는 단서 포함) | 모든 브라우저가 동일하게 기본값을 적용한다는 뜻은 아님 — 원문이 "Some browsers" 라고 명시하며 Browser compatibility 표를 별도로 참조하라고 안내(이 표 자체는 이번 fetch 범위 밖) |
|
|
|
|
### Strength 허용값
|
|
|
|
- `official-standard` — RFC, 표준 사양, 언어/프로토콜 표준
|
|
- `official-vendor-doc` — Spring, Keycloak, AWS, Google 등 공식 벤더 문서
|
|
- `official-reference` — 공식 reference/API 문서
|
|
- `company-case-study` — 대기업/실무 기술 블로그의 특정 사례
|
|
- `engineering-blog` — 개인/팀 블로그의 엔지니어링 해설
|
|
- `tutorial` — 튜토리얼/가이드. 일반화 금지
|
|
- `needs-confirmation` — 원문만으로는 적용 판단 불가
|
|
|
|
## Usage Boundaries / 적용 경계
|
|
|
|
- 이 자료가 직접 증명하는 것:
|
|
- `MDN-SAMESITE-C1`: `Strict` 는 same-site 요청에만 쿠키를 전송함(cross-site 완전 차단).
|
|
- `MDN-SAMESITE-C2`/`C3`: `Lax` 는 "top-level navigation" + "safe method(GET 등, POST/PUT/DELETE 제외)" 두 기준을 모두 만족하는 cross-site 요청에만 조건부로 쿠키를 전송함.
|
|
- `MDN-SAMESITE-C4`: `None` 은 cross-site 포함 모든 요청에 쿠키를 전송하며 `Secure` 가 필수임.
|
|
- `MDN-SAMESITE-C5`: `SameSite` 미지정 시 일부 브라우저가 `Lax` 를 기본값으로 적용함.
|
|
- 이 자료가 증명하지 않는 것:
|
|
- 기본값(암묵적) `Lax` 가 적용될 때의 "더 관대한 버전"(2분 이내 설정된 쿠키는 cross-site `POST` 에도 실림)의 정확한 브라우저별 구현 범위 — 원문에 언급은 있으나 이번 발췌 5개 인용에는 포함하지 않음(메모 참조).
|
|
- AP3 BFF 세션 쿠키에 실제로 `Strict` 를 선택해야 하는지 `Lax` 를 선택해야 하는지에 대한 권고 — 이 문서는 **각 값의 semantics 만** 정의하며, OIDC redirect 콜백처럼 top-level cross-site 진입이 필요한 흐름과의 상호작용은 branch-note 의 별도 D2 결정 근거(예: OIDC 표준 문서)와 함께 판단해야 함.
|
|
- 내 프로젝트에 적용하려면 추가 확인이 필요한 것:
|
|
- AP3 BFF 의 실제 쿠키 설정 코드(Set-Cookie 헤더 생성 위치)에서 `SameSite`/`Secure` 값이 이 semantics 대로 설정되는지 로컬 검증 필요.
|
|
|
|
## 메모 / Notes
|
|
|
|
- 원문에는 `Lax` 의 "top-level navigation" 정의에 대한 추가 설명 문단(예: `fetch()`/`<img>`/`<script>`/`<iframe>` 은 제외, 링크 클릭·`document.location`·`<form>` 제출은 포함)과, 기본값 `Lax` 가 적용될 때의 "더 관대한 버전"(2분 이내 설정된 쿠키는 `POST` 에도 포함) 각주가 더 있다. 이번 발췌는 branch D2 결정에 직접 필요한 5개 핵심 문장만 verbatim 으로 확보했다 — 두 세부 사항이 실제로 필요해지면(예: OAuth2/OIDC redirect 콜백이 top-level navigation 인지 판단해야 할 때) 같은 페이지를 재방문해 추가 Claim 을 이 문서에 append 할 것.
|
|
- (미검증, 인용 아님) top-level navigation 기준 때문에 OIDC Authorization Code redirect(브라우저 최상위 이동 + GET)는 `Lax` 쿠키가 실리는 경우로 보이지만, 이는 이 raw 문서의 인용이 직접 증명하지 않으므로 branch-note 의 D2 본문에서 별도로 검증해야 한다.
|
|
|
|
## Related / 관련
|
|
|
|
- `raw/official-docs/csrf-prevention-owasp-official` — (검토 후보, 아직 raw 부재) OWASP CSRF Prevention Cheat Sheet — SameSite 는 defense-in-depth 이지 유일한 방어가 아니라는 논지의 근거 후보
|
|
- 이 자료를 인용한 wiki 요약: (아직 생성 안 됨)
|