Skip to content

fix(auth): reject non-ASCII API keys without a 500 - #555

Draft
seonghobae wants to merge 1 commit into
mainfrom
fix/api-key-nonascii-boundary
Draft

fix(auth): reject non-ASCII API keys without a 500#555
seonghobae wants to merge 1 commit into
mainfrom
fix/api-key-nonascii-boundary

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

문제

require_api_key가 user-controlled X-API-Key를 Python str 그대로 hmac.compare_digest()에 넘기면 non-ASCII 값에서 TypeError가 발생할 수 있어 인증 실패가 401이 아니라 application 500으로 번질 수 있습니다.

변경

  • 비교 양쪽을 UTF-8 bytes로 정규화한 뒤 hmac.compare_digest()를 사용합니다.
  • non-ASCII invalid header가 예외 대신 기존 401 JSON contract로 끝나는 regression을 보존합니다.

범위 정리

이 successor는 predecessor #553의 유효 auth semantic delta와 regression test만 승계합니다. #553 후속 commit의 httpx2/httpcore2 dependency 제거는 인증 결함과 인과관계가 없고 별도 canonical dependency-security lane(#550)과 충돌하므로 포함하지 않습니다. source-neutral rebuild commit과 과도한 [MEDIUM] DoS framing도 승계하지 않습니다. 원격 DoS 영향도는 별도 load evidence 없이 주장하지 않습니다.

검증

  • base: main@47c6fd27de13b0da37a7db64697b869941909351
  • semantic head: 7f85b60fd0b8c1f2247766d89ea06754df970185
  • base→head changed files는 saas_web.py, tests/test_saas_web.py 두 개뿐입니다.
  • hosted exact-head checks와 current-head independent review가 끝날 때까지 Draft를 유지합니다.

Rollback

인증 비교를 기존 str 경계로 되돌리면 non-ASCII header 예외가 재발할 수 있으므로, 회귀가 있을 경우 bytes normalization 방식을 대체 구현으로 고치되 401 regression은 유지합니다.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant