-
Notifications
You must be signed in to change notification settings - Fork 0
🛡️ Sentinel: [HIGH] API 키 인증의 DoS 취약점 수정 #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,8 +113,9 @@ async def require_api_key(request: Request, call_next): | |
| configured_keys = get_configured_api_keys() | ||
| if configured_keys and not (request.method == "GET" and request.url.path == "/"): | ||
| provided_key = request.headers.get("x-api-key", "") | ||
| provided_bytes = provided_key.encode("utf-8") | ||
| if not any( | ||
| hmac.compare_digest(provided_key, key) for key in configured_keys | ||
| hmac.compare_digest(provided_bytes, key.encode("utf-8")) for key in configured_keys | ||
|
Comment on lines
+116
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 API keys still sourced from env var
Was this helpful? React with 👍 or 👎 to provide feedback.
Comment on lines
+116
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift 런타임 API 키의 환경 변수 의존을 제거해야 합니다.
As per coding guidelines: 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| ): | ||
| return JSONResponse( | ||
| status_code=401, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Info: Fix avoids crash for all header bytes
request.headers.getreturns a latin-1 decoded string in Starlette, so any header bytes produce a valid string that.encode("utf-8")never rejects. TheTypeErrorcrash path is fully closed.Was this helpful? React with 👍 or 👎 to provide feedback.