🛡️ Sentinel: [CRITICAL] hmac.compare_digest를 통한 API 키 DoS 취약점 수정 - #295
🛡️ Sentinel: [CRITICAL] hmac.compare_digest를 통한 API 키 DoS 취약점 수정#295seonghobae wants to merge 1 commit into
Conversation
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Warning Review limit reached
Next review available in: 6 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Mitigates a DoS condition in the FastAPI API-key middleware by ensuring hmac.compare_digest receives byte inputs (avoiding TypeError on non-ASCII header values), and records the incident/mitigation in the Sentinel security log.
Changes:
- Encode both the provided
X-API-Keyheader value and configured keys as UTF-8 bytes before callinghmac.compare_digest. - Document the vulnerability and prevention guidance in
.jules/sentinel.md.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| saas_web.py | Hardens API key comparison against non-ASCII inputs by comparing bytes via hmac.compare_digest. |
| .jules/sentinel.md | Adds a Sentinel entry describing the DoS vector and the byte-encoding prevention rule. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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 | ||
| ): |
| 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 | ||
| ): |
|
Superseded by canonical PR #361, which implements the same non-ASCII API-key comparison fix and consolidates credential access, owned result storage, retention cleanup, and regression evidence. Closing this duplicate. |
Understood. Acknowledging that this work is now obsolete and stopping work on this task. |
🚨 Severity: CRITICAL
💡 Vulnerability: hmac.compare_digest TypeError 발생으로 인한 DoS (CWE-400)
🎯 Impact: 악의적인 사용자가 X-API-Key 헤더에 non-ASCII 문자를 포함하여 요청을 보낼 경우 TypeError가 발생하여 500 Internal Server Error를 유발하고, 서비스 거부(DoS) 공격이 가능합니다.
🔧 Fix: 제공된 키와 구성된 키 모두를
utf-8로 인코딩한 바이트 객체로 변환하여hmac.compare_digest에 전달함으로써 non-ASCII 문자에 대한 처리 오류를 방지했습니다.✅ Verification: pytest 테스트를 실행하여 정상적으로 동작하는지 확인했습니다.
PR created automatically by Jules for task 15036794377237530148 started by @seonghobae