Skip to content

🛡️ Sentinel: [MEDIUM] API 키 검증 시 비-ASCII 문자 처리 예외 수정 - #474

Closed
seonghobae wants to merge 4 commits into
mainfrom
sentinel/fix-hmac-non-ascii-4997172601991374763
Closed

🛡️ Sentinel: [MEDIUM] API 키 검증 시 비-ASCII 문자 처리 예외 수정#474
seonghobae wants to merge 4 commits into
mainfrom
sentinel/fix-hmac-non-ascii-4997172601991374763

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Verified succession

Exact predecessor 01e04f2fb9424f9f3b49799e6c5b16ad297fc645의 유효 delta는 non-ASCII API-key mismatch→401 behavior/test와 Unreleased CHANGELOG의 보안 수정 traceability입니다. Canonical #520 exact cf730d007543ee828b7b8e77c9473288924047d4가 raw ASGI header bytes에서 이 behavior를 보존하고 configured Unicode success·duplicate-header fail-closed를 더 강하게 검증하며 CHANGELOG에도 current contract를 기록합니다.

#474의 decoded framework string UTF-8 재인코딩과 blanket .jules encoding 지침은 Unicode credential raw byte identity를 훼손할 수 있어 별도 유효 delta가 아닙니다. 따라서 유효 behavior/test/documentation intent는 #520에 완전 승계됐고 #520은 protected main@90717c6e9954bf3b7a351137995ebe89975e46c2 대비 behind_by=0인 non-force descendant입니다.

@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f531409-28fd-43f0-9a0a-712c4af57dc5

📥 Commits

Reviewing files that changed from the base of the PR and between a8e4956 and 108df09.

📒 Files selected for processing (4)
  • .jules/sentinel.md
  • CHANGELOG.md
  • saas_web.py
  • tests/test_saas_web.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

require_api_key가 API 키를 UTF-8 바이트로 변환하여 비교합니다. 비ASCII X-API-Key 헤더는 401 응답과 표준 오류 JSON을 반환합니다. 변경 사항을 테스트, 변경 로그, 보안 학습 문서에 반영했습니다.

Changes

API 키 인증

Layer / File(s) Summary
UTF-8 API 키 비교 및 회귀 검증
saas_web.py, tests/test_saas_web.py, CHANGELOG.md, .jules/sentinel.md
require_api_key가 API 키를 UTF-8 바이트로 변환해 비교합니다. 비ASCII X-API-Key 헤더가 401 응답과 Invalid or missing API key 오류를 반환하는지 검증합니다. 수정 내용을 변경 로그와 보안 학습 문서에 기록합니다.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 108df

The PR makes a localized change to safely compare API keys containing non-ASCII characters, with test verification reported. No actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (2 skipped: 2 unsupported.) Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 비ASCII API 키 검증 예외 수정이라는 주요 변경 사항을 정확하고 구체적으로 요약합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sentinel/fix-hmac-non-ascii-4997172601991374763

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.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

Comment thread saas_web.py
provided_key = request.headers.get("x-api-key", "")
if not any(
hmac.compare_digest(provided_key, key) for key in configured_keys
hmac.compare_digest(provided_key.encode("utf-8"), key.encode("utf-8")) for key in configured_keys

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Header re-encoded through latin-1 then utf-8

Starlette decodes header values with latin-1, so provided_key (saas_web.py:115) then .encode("utf-8") does not reproduce the client's raw bytes for values above 0x7F. Harmless here since configured ASCII keys round-trip identically, but the comparison is not against the raw header bytes.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@seonghobae seonghobae closed this Sep 3, 2026
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