Files
document-haness/docs/clean-architecture-backend-template/tech-log-studio/security-policy-enforcement/case/case-grpc-policy-f02.md
T
DongHyeonkaandClaude Opus 5 b2963105a8 docs(keycloak-session-store): import the session-storage lab as a new project
The keycloak project ended with four open questions that design could not
settle. A two-VM lab was built to answer them by measurement, and this is
that material: 26 experiments, 125 raw command outputs, 22 browser captures.

Follows the import procedure in README.md.

  source/     the originating repository verbatim — 78 documents, 28 SVGs,
              8 manifests, plus .source-revision recording the commit
  final/      the SSOT
    document.md   729 lines written from the 29 experiment documents, not
                  concatenated: what was predicted, what was measured, and
                  where the measurement itself was wrong
    evidence/raw    125 outputs, flattened to <experiment>__<file> because
                    the originals collided (01-baseline.txt appeared three
                    times) and the audit only globs the top level
    evidence/meta   one per raw file; command and exitCode are null and the
                    README says why rather than inventing them
    evidence/browser  22 captures
    assets/       three diagrams through techviz
    .techviz/     their VizSpecs

A separate project rather than an addition to keycloak: the B-layer answers
that project's four questions, but the A, C and D layers are about cluster
failure, SSO and operations, and one document.md should hold one subject.
The four question records there can point here through 관계.

Recorded rather than papered over: only three of the 28 diagrams were
remade. The repository forbids hand-drawn SVG and forbids titles inside the
canvas; all 28 originals carry both, so converting them is redrawing, not
reformatting. They stay in source/ and the gap is written into the document.

verify-pipeline.py passes. audit-records.py reports no issues.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 22:51:59 +09:00

4.6 KiB

kind, slug, title, topic, project, status, sourceRevision, rootTreeNode, evidenceCapturedOn, assets, evidence, source, module, priority
kind slug title topic project status sourceRevision rootTreeNode evidenceCapturedOn assets evidence source module priority
CASE grpc-policy-f02 자격증명 회전이 비교 후 교체가 아니고, 배수 완료가 진행 중인 회전을 되돌릴 수 있다 security-policy-enforcement clean-architecture-backend-template 게시 전 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916 case:grpc-policy-f02 2026-09-01
key file
grpc-policy-f02 ../../../final/evidence/rendered/grpc-policy-f02.svg
key file
grpc-policy-f02-diagram ../../../final/assets/diagrams/grpc-policy-f02.svg
../../../final/evidence/raw/grpc-policy-f02.txt
원본 분석 절은 analysis/grpc/grpc-policy.md#L204 이다.
grpc-policy P2

자격증명 회전이 비교 후 교체가 아니고, 배수 완료가 진행 중인 회전을 되돌릴 수 있다

AtomicReference 를 쓰면서 두 메서드 모두 읽고 나서 조건 없이 쓴다. 두 회전이 같은 observed 를 읽으면 둘 다 승계 검사를 통과할 수 있고, 나중 set 이 앞의 것을 덮는다.

문제

AtomicReference 를 쓰면서 두 메서드 모두 읽고 나서 조건 없이 쓴다.

두 회전이 같은 observed 를 읽으면 둘 다 승계 검사를 통과할 수 있고, 나중 set 이 앞의 것을 덮는다.

결론

덮인 회전이 배수 대상으로 기록해 둔 세대가 상태에서 사라진다.

그 세대 위의 호출은 아무도 배수하지 않는다.

javadoc 이 이 상황을 이미 알고 있다 — 승계 검사의 존재 이유로 "the usual reason for one is two rotators racing" 를 든다.

검사는 있고 원자성이 없다.

completeDrain() 이 자기가 읽은 observed.current() 로 새 상태를 만든다.

읽기와 쓰기 사이에 회전이 일어나면, 그 회전이 활성화한 세대가 지워지고 이전 세대가 다시 현재가 된다.

즉 방금 교체된 자격증명이 되살아난다.

클래스의 존재 이유가 "in-flight 작업을 떨어뜨리지 않고 자격 자재를 교체하는 것" 인데, 이 경로는 교체 자체를 되돌린다.

검증 환경

OpenJDK : 21.0.12 java -version 으로 확인 Gradle : 9.0.0 src/gradle/wrapper/gradle-wrapper.properties 의 distributionUrl 로 확인 확인 방식 : AtomicReference 를 다루는 두 메서드의 읽기·쓰기 순서 대조 소스 수정 : x

재현 조건

원문은 analysis/grpc/grpc-policy.md#L204 에 있다.

본문

AtomicReference 를 쓰면서 두 메서드 모두 읽고 나서 조건 없이 쓴다.

두 연산이 겹치는 결과

:::evidence key="grpc-policy-f02-diagram" alt="회전과 배수 완료가 각자 읽은 상태와 조건 없는 set 을 지나 이전 세대가 현재가 되는 결과로 이어진다" caption="두 연산이 겹치는 결과" zoom="false" :::

두 회전이 같은 observed 를 읽으면 둘 다 승계 검사를 통과할 수 있고, 나중 set 이 앞의 것을 덮는다. 덮인 회전이 배수 대상으로 기록해 둔 세대가 상태에서 사라지고, 그 세대 위의 호출은 아무도 배수하지 않는다.

두 메서드가 읽고 쓰는 방식

:::evidence key="grpc-policy-f02" alt="분석 문서 analysis/grpc/grpc-policy.md 에서 이 기록의 근거 절을 그대로 잘라낸 15줄. 코드베이스를 측정한 것이 아니라 원본 판정이 무엇을 적었는지를 보여 준다." caption="analysis/grpc/grpc-policy.md 발췌 — 15줄" zoom="true" :::

javadoc 이 이 상황을 이미 알고 있다

승계 검사의 존재 이유로 "the usual reason for one is two rotators racing" 를 든다. 검사는 있고 원자성이 없다.

배수 완료가 회전을 되돌린다

completeDrain() 이 자기가 읽은 observed.current() 로 새 상태를 만든다. 읽기와 쓰기 사이에 회전이 일어나면, 그 회전이 활성화한 세대가 지워지고 이전 세대가 다시 현재가 된다 — 방금 교체된 자격증명이 되살아난다. 클래스의 존재 이유가 "in-flight 작업을 떨어뜨리지 않고 자격 자재를 교체하는 것" 인데, 이 경로는 교체 자체를 되돌린다.

수정

rotatecompareAndSet(observed, next) 가 실패하면 다시 읽어 판정하고, completeDrainupdateAndGet(s -> new State(s.current(), null, null)) 로 현재 값을 원자적으로 읽어 쓰면 된다. 후자는 한 줄이다. 같은 형태가 grpc-clientGrpcChannelRuntimeRegistry.rotate 에도 있다.

확인하지 못한 것

동시 회전과 동시 배수 완료를 실행으로 재현하지 않았다. 조건 없는 set 이라는 코드 형태로 판정했다.