virtual-insanity
← 리포트 목록

token_rotation_guide

2026-04-24 github

260424 — GitHub/Copilot token rotation guide

결론

GitHub/Copilot 토큰 회전 스크립트 작성 완료.

  • 스크립트: /Users/ron/.hermes/workspace/scripts/admin/rotate_github_token.py
  • dry-run 검증: PASS
  • 값 출력: 없음. fingerprint/prefix/path/scope만 출력.
  • ~/.openclaw remote: 없음 → 현재 repo 기준 외부 push 흔적 없음.

1) 현재 토큰 현황

이번 history 노출에서 핵심이었던 토큰 2개 외에, 현재 active auth-profile에는 신규/추가 토큰도 보인다. 따라서 폐기는 “history 노출 2개”만이 아니라 active token 전체 기준으로 보는 게 안전하다.

핵심 active/exposed 토큰

fingerprint prefix GitHub API scope 주요 위치 파일 수 우선순위
53b3cfbac4e657c4 gho_ OK gist, read:org, repo OpenClaw agent backup/main 계열 3 P0 — repo scope
5b1006b0da2138ff ghu_ OK 빈 scope 응답 OpenClaw legacy agent 6개 + history 다수 6 active / history 9 paths P0
e362c365a9f37b0c ghu_ OK 빈 scope 응답 OpenClaw 현재 active agent 16개 16 P0
c54db51cb134fd0f github_pat_ OK 빈 scope 응답 /Users/ron/.hermes/auth/profiles/github-copilot.json, /Users/ron/.openclaw/auth/profiles/github-copilot.json 2 P0

테스트/문서용으로 보이는 무효 토큰

아래는 GitHub API 401이거나 test/redaction 문서에 있는 예시형 토큰이다. 폐기 대상보다는 secret scan 예외/fixture 정리가 적절하다.

  • ae8754608195aafbghp_, OpenClaw test file, API 401
  • 46eb12352e801d0bghp_, Hermes test file, API 401
  • daf86f709d92c7a2ghp_, Hermes test file, API 401
  • 35092908ccd08f13gho_, Hermes test file, API 401
  • 기타 github_pat_ redaction test fixtures — API 401

2) 사용처와 영향

auth-profiles.json 계열

사용처:

  • agents/*/agent/auth-profiles.json
  • OpenClaw/Hermes agent runtime provider auth loader
  • workspace/src/providers/github-copilot-token.ts
  • workspace/src/agents/models-config.providers.ts
  • workspace/src/agents/pi-embedded-runner/run.ts
  • workspace/src/agents/pi-embedded-runner/compact.ts

폐기 영향:

  • 해당 agent의 github-copilot/* 모델 호출 실패 가능.
  • 새 토큰 적용 후 agent/gateway 재시작 또는 auth reload 필요 가능.

~/.hermes/auth/profiles/github-copilot.json / ~/.openclaw/auth/profiles/github-copilot.json

사용처:

  • 공용 GitHub Copilot auth profile로 보임.
  • Hermes/OpenClaw 양쪽에서 proxy/provider fallback 시 참조 가능.

폐기 영향:

  • GitHub Copilot 기반 provider 호출 전반 영향 가능.
  • 가장 먼저 새 토큰을 반영해야 하는 파일군.

3) GitHub에서 폐기/재발급 절차

  1. GitHub 접속: https://github.com/settings/tokens
  2. Fine-grained token이면: https://github.com/settings/personal-access-tokens
  3. 토큰 목록에서 아래 기준으로 매칭
  4. prefix: gho_, ghu_, github_pat_
  5. last used / created date / scope
  6. scope repo, gist, read:org가 보이면 53b3cf... 후보 우선
  7. 기존 token revoke
  8. 새 token 발급
  9. 가능하면 repo scope 제거
  10. Copilot/auth 용도면 최소 scope로 재발급
  11. 만료일 짧게 설정
  12. 새 token을 clipboard에 복사

4) 자동 갱신 스크립트

목록 확인

python3 ~/.hermes/workspace/scripts/admin/rotate_github_token.py --list

값은 출력하지 않고 아래 형태로만 나온다.

fingerprint=... prefix=ghu_ paths=... github_ok=True login=... scopes=...

dry-run

stdin 방식 권장. token이 shell history에 남지 않는다.

pbpaste | python3 ~/.hermes/workspace/scripts/admin/rotate_github_token.py \
  --fingerprint 5b1006b0 \
  --new-token-stdin \
  --dry-run

실제 적용

pbpaste | python3 ~/.hermes/workspace/scripts/admin/rotate_github_token.py \
  --fingerprint 5b1006b0 \
  --new-token-stdin

각 수정 파일은 자동 백업된다.

<file>.bak-rotate-github-YYYYMMDD_HHMMSS

특정 토큰별 예시

# history 다수 노출 ghu_ 토큰
pbpaste | python3 ~/.hermes/workspace/scripts/admin/rotate_github_token.py --fingerprint 5b1006b0 --new-token-stdin --dry-run

# repo scope 포함 gho_ 토큰
pbpaste | python3 ~/.hermes/workspace/scripts/admin/rotate_github_token.py --fingerprint 53b3cfba --new-token-stdin --dry-run

# 현재 active agent 16개에 있는 ghu_ 토큰
pbpaste | python3 ~/.hermes/workspace/scripts/admin/rotate_github_token.py --fingerprint e362c365 --new-token-stdin --dry-run

# Hermes/OpenClaw 공용 github-copilot profile token
pbpaste | python3 ~/.hermes/workspace/scripts/admin/rotate_github_token.py --fingerprint c54db51c --new-token-stdin --dry-run

5) 검증 결과

스크립트 검증:

python3 -m py_compile rotate_github_token.py
PASS

목록 스캔:

unique_tokens=13

실제 유효 토큰:

53b3cfbac4e657c4 scope=gist, read:org, repo
5b1006b0da2138ff scope=<empty>
e362c365a9f37b0c scope=<empty>
c54db51cb134fd0f scope=<empty>

Dry-run 예시:

target_fingerprint=5b1006b0da2138ff old_prefix=ghu_<redacted>
new_token=ghu_<redacted>
mode=DRY_RUN changed_files=6

6) 외부 push 안전 점검

cd ~/.openclaw && git remote -v
<empty>

판정:

  • 현재 OpenClaw repo에는 remote가 없다.
  • GitHub 외부 push 가능성은 낮다.
  • 단, 로컬 backup/archive/worktree에는 복제되어 있으므로 revoke는 여전히 필요하다.

7) 권장 순서

  1. 53b3cf...repo scope 포함이라 최우선 revoke/재발급.
  2. c54db51... — Hermes/OpenClaw 공용 github-copilot profile로 보이므로 운영 영향 크다. 새 토큰 준비 후 교체.
  3. e362c365... — 현재 active agent 16개.
  4. 5b1006b0... — legacy/history 다수 + active 6개.
  5. 이후 git filter-repo 또는 BFG로 OpenClaw history rewrite.

8) 주의

  • --new-token '<TOKEN>' 직접 인자 방식은 shell history/process list에 남을 수 있다. --new-token-stdin 권장.
  • 새 token은 GitHub API /user로 검증하며, login mismatch면 적용 차단한다.
  • scope는 GitHub 응답 헤더 기준이다. Fine-grained token은 scope 헤더가 비어 보일 수 있으므로 GitHub UI에서 권한/만료일을 반드시 확인해야 한다.
  • 실제 적용 후에는 관련 agent/gateway 재시작 또는 auth reload가 필요할 수 있다.

9) 자체평가

  • 정확성: 4.5/5 — 현재 active token까지 재스캔해 history 2개 외 추가 유효 토큰을 식별.
  • 완성도: 4.4/5 — 자동 회전 스크립트와 가이드는 완료, 실제 revoke/교체는 해리 새 토큰 발급 후 수행.
  • 검증: 4.5/5 — GitHub API scope 확인, py_compile, list/dry-run 확인.
  • 최소 변경: 4.7/5 — 신규 admin 스크립트/보고서만 작성. secret 값/설정 변경 없음.

종합: 4.5/5

DONE