Skip to content

πŸ›‘οΈ Sentinel: [HIGH] hmac.compare_digest DoS 취약점 μˆ˜μ • - #519

Closed
seonghobae wants to merge 1 commit into
mainfrom
sentinel-fix-hmac-dos-9473386104271895083
Closed

πŸ›‘οΈ Sentinel: [HIGH] hmac.compare_digest DoS 취약점 μˆ˜μ •#519
seonghobae wants to merge 1 commit into
mainfrom
sentinel-fix-hmac-dos-9473386104271895083

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Verified succession

이 generated branch의 μœ νš¨ν•œ μš”κ΅¬μ‚¬ν•­μ€ non-ASCII raw API-key μž…λ ₯이 인증 λ―Έλ“€μ›¨μ–΄μ—μ„œ μ²˜λ¦¬λ˜μ§€ μ•Šμ€ μ˜ˆμ™Έλ₯Ό λ§Œλ“€μ§€ μ•Šκ³  401둜 κ±°μ ˆλ˜μ–΄μ•Ό ν•œλ‹€λŠ” κ²ƒμž…λ‹ˆλ‹€. Canonical #520 exact 9ee46273ad9e7023af23cf88e19e6ee808840334κ°€ 이 계약을 μ™„μ „ μŠΉκ³„ν•˜λ©΄μ„œ 더 κ°•ν•œ raw-ASGI/Unicode/duplicate-header 경계λ₯Ό μ œκ³΅ν•©λ‹ˆλ‹€.

#519 exact 7d90f2fbcecf118aa7c1f17f45c89e8cc0437891의 production deltaλŠ” request.headers.get()으둜 얻은 Starlette λ¬Έμžμ—΄ viewλ₯Ό .encode('utf-8')ν•œ λ’€ λΉ„κ΅ν•˜λŠ” λ°©μ‹μž…λ‹ˆλ‹€. κ·Έ 방식은 attacker μž…λ ₯의 TypeErrorλŠ” ν”Όν•˜μ§€λ§Œ raw UTF-8 configured Unicode credential을 Latin-1 λ¬Έμžμ—΄ viewλ₯Ό 거쳐 μž¬μΈμ½”λ”©ν•˜μ—¬ λ‹€λ₯Έ byte sequence둜 λ§Œλ“€ 수 μžˆμŠ΅λ‹ˆλ‹€. #520은 request.scope['headers']μ—μ„œ raw bytesλ₯Ό 직접 읽어 exactly-one X-API-Keyλ₯Ό μš”κ΅¬ν•˜κ³  configured UTF-8 bytes와 λΉ„κ΅ν•˜λ―€λ‘œ 이 νšŒκ·€λ₯Ό λ§Œλ“€μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

#519의 async regression이 μš”κ΅¬ν•˜λŠ” non-ASCII mismatchβ†’401은 #520의 tests/test_saas_web.py와 tests/test_api_key_unicode_contract.pyκ°€ μœ μ§€ν•˜λ©°, #520은 valid Unicode credential success와 duplicate-header rejectionκΉŒμ§€ μΆ”κ°€λ‘œ κ²€μ¦ν•©λ‹ˆλ‹€. #519의 .jules blanket "항상 string을 UTF-8 encode" κ·œμΉ™μ€ raw HTTP credential κ²½κ³„μ—μ„œλŠ” λΆ€μ •ν™•ν•΄ 별도 유효 deltaκ°€ μ•„λ‹™λ‹ˆλ‹€.

#520은 protected main@90717c6e9954bf3b7a351137995ebe89975e46c2λ₯Ό non-force둜 μ±„νƒν•œ exact 9ee46273..., behind_by=0이며 ν˜„μž¬ hosted checksλŠ” μƒˆ headμ—μ„œ queued/pendingμž…λ‹ˆλ‹€. λ”°λΌμ„œ #519의 λͺ¨λ“  유효 behavior/test contractλŠ” stronger canonical successor에 μŠΉκ³„λκ³ , μ•½ν•œ source/doc deltaλŠ” μ˜λ„μ μœΌλ‘œ μŠΉκ³„ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

@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 Sep 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

βš™οΈ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: d0fd882c-573a-41a0-bed0-626614ffac72

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between a8e4956 and 7d90f2f.

πŸ“’ Files selected for processing (3)
  • .jules/sentinel.md
  • saas_web.py
  • tests/test_saas_web.py

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 2 potential issues.

Devin Review

Comment thread tests/test_saas_web.py
Comment on lines +1230 to +1252
@unittest.skipUnless(
_HAS_FASTAPI, "fastapi not installed (optional integration dependency)"
)
class TestApiKeyAuthAsync(unittest.IsolatedAsyncioTestCase):
async def test_non_ascii_key_rejected_safely(self):
from starlette.requests import Request
import saas_web
import json

async def mock_call_next(request):
return "SUCCESS"

with patch.dict(os.environ, {"CODEC_CARVER_API_KEYS": "secret-key"}):
scope = {
"type": "http",
"method": "POST",
"path": "/shrink",
"headers": [(b"x-api-key", "non-ascii-Γ©".encode("utf-8"))],
}
request = Request(scope)
response = await saas_web.require_api_key(request, mock_call_next)
self.assertEqual(response.status_code, 401)
self.assertEqual(json.loads(response.body), {"error": "Invalid or missing API key"})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

πŸ” Direct execution skips regression test

Placing the class after unittest.main() excludes it when this module runs directly. The non-ASCII regression then receives no coverage.

Devin Review

Was this helpful? React with πŸ‘ or πŸ‘Ž to provide feedback.

Comment thread saas_web.py
provided_key_bytes = provided_key.encode("utf-8")
if not any(
hmac.compare_digest(provided_key, key) for key in configured_keys
hmac.compare_digest(provided_key_bytes, 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.

🟨 Runtime keys bypass credential registry

require_api_key still consumes environment-backed secrets through get_configured_api_keys. Runtime API keys bypass the mandatory encrypted credential registry and its managed lifecycle.

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