-
Notifications
You must be signed in to change notification settings - Fork 0
๐ก๏ธ Sentinel: [HIGH] ํค๋๋ฅผ ํตํ DoS ์ทจ์ฝ์ ํด๊ฒฐ #447
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1222,6 +1222,31 @@ def test_video_content_type_accepted_by_validator(self): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_auth_unicode_encode_error(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import os | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from starlette.requests import Request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import asyncio | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async def call_next(request): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return {"status": "ok"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| os.environ["CODEC_CARVER_API_KEYS"] = "valid_key" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| scope = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'type': 'http', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'method': 'POST', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'path': '/shrink', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'headers': [(b'x-api-key', 'invalid_key๐'.encode('utf-8'))], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'query_string': b'', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'client': ('127.0.0.1', 12345), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'server': ('127.0.0.1', 80), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request = Request(scope) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| response = asyncio.run(saas_web.require_api_key(request, call_next)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.assertEqual(response.status_code, 401) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| finally: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| del os.environ["CODEC_CARVER_API_KEYS"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1225
to
+1248
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. ๐ฉบ Stability & Availability | ๐ก Minor | โก Quick win ํ ์คํธ ํ ํ๊ฒฝ ๋ณ์์ ๊ธฐ์กด ๊ฐ์ ๋ณต์ํ์ญ์์ค. Line 1233์์ ๊ถ์ฅ ์์ import asyncio
+ from unittest.mock import patch
- os.environ["CODEC_CARVER_API_KEYS"] = "valid_key"
scope = {
...
}
request = Request(scope)
- try:
+ with patch.dict(os.environ, {"CODEC_CARVER_API_KEYS": "valid_key"}):
response = asyncio.run(saas_web.require_api_key(request, call_next))
self.assertEqual(response.status_code, 401)
- finally:
- del os.environ["CODEC_CARVER_API_KEYS"]๐ Committable suggestion
Suggested change
๐ค Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if __name__ == "__main__": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| unittest.main() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
๐ Security & Privacy | ๐ Major | ๐๏ธ Heavy lift
์ธ์ฆ ํค๋ฅผ credential registry/KV์์ ์ฝ๋๋ก ๋ง์ด๊ทธ๋ ์ด์ ํ์ญ์์ค.
Line 117์ UTF-8 ๋ฐ์ดํธ ๋ณํ์ non-ASCII ์ ๋ ฅ์
TypeError๋ฅผ ๋ง์ต๋๋ค. ๊ทธ๋ฌ๋get_configured_api_keys()๋saas_web.pyLine 97์์CODEC_CARVER_API_KEYS๋ฅผos.environ์์ ๊ณ์ ์ฝ์ต๋๋ค. ๋ฐํ์ API ํค๋ฅผ ํ๊ฒฝ ๋ณ์์์ ์ฝ์ง ๋ง๊ณ credential registry/KV์์ ์กฐํํ๋๋ก ๋ณ๊ฒฝํ์ญ์์ค. ๊ด๋ จ ํ ์คํธ๋ registry๋ฅผ ์ค์ ํ๋๋ก ๋ณ๊ฒฝํด์ผ ํฉ๋๋ค.As per coding guidelines,
saas_web.pymust source runtime API keys, database credentials, endpoints, and other secrets from the credential registry/KV rather than directly from environment variables; migrate API-key authentication away fromCODEC_CARVER_API_KEYSas a runtime environment-variable source.๐ค Prompt for AI Agents
Source: Coding guidelines