Skip to content

๐Ÿ›ก๏ธ Sentinel: [MEDIUM] hmac.compare_digest์˜ ๋น„-ASCII ๋ฌธ์ž ์ฒ˜๋ฆฌ ์˜ค๋ฅ˜ (500 ์—๋Ÿฌ) ์ˆ˜์ • - #495

Closed
seonghobae wants to merge 7 commits into
mainfrom
jules-11981266730423604347-a86f1501
Closed

๐Ÿ›ก๏ธ Sentinel: [MEDIUM] hmac.compare_digest์˜ ๋น„-ASCII ๋ฌธ์ž ์ฒ˜๋ฆฌ ์˜ค๋ฅ˜ (500 ์—๋Ÿฌ) ์ˆ˜์ •#495
seonghobae wants to merge 7 commits into
mainfrom
jules-11981266730423604347-a86f1501

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Verified succession

Exact predecessor cbc5b2d386ca24049116ff3871134681d8a404ca๋Š” decoded API-key ๋ฌธ์ž์—ด์„ UTF-8 bytes๋กœ ๋ฐ”๊พธ๊ณ  emoji mismatchโ†’401 regression ๋ฐ ๊ฐ™์€ encoding ์ง€์นจ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. Canonical #520 exact cf730d007543ee828b7b8e77c9473288924047d4๋Š” raw ASGI X-API-Key bytes๋ฅผ configured UTF-8 key์™€ ์ง์ ‘ ๋น„๊ตํ•˜์—ฌ ๋™์ผ invalid non-ASCII rejection์„ ๋ณด์กดํ•˜๊ณ , valid Unicode credential success์™€ duplicate-header fail-closed๊นŒ์ง€ ๋” ๊ฐ•ํ•˜๊ฒŒ ๊ฒ€์ฆํ•ฉ๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ predecessor์˜ ์œ ํšจ behavior/test contract๋Š” #520์— ์™„์ „ ์Šน๊ณ„๋์Šต๋‹ˆ๋‹ค. decoded framework string ์žฌ์ธ์ฝ”๋”ฉ๊ณผ blanket encoding ์ง€์นจ์€ Unicode credential byte identity๋ฅผ ํ›ผ์†ํ•  ์ˆ˜ ์žˆ์–ด ๋ณ„๋„ ์œ ํšจ delta๊ฐ€ ์•„๋‹ˆ๋ฉฐ canonical guidance๋Š” raw-header boundary๋กœ ๊ต์ •ํ–ˆ์Šต๋‹ˆ๋‹ค. #520์€ protected main@90717c6e9954bf3b7a351137995ebe89975e46c2 ๋Œ€๋น„ behind_by=0์ธ non-force descendant์ž…๋‹ˆ๋‹ค.

hmac.compare_digest ํ•จ์ˆ˜๋Š” ASCII ๋ฒ”์œ„ ์™ธ์˜ ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์กŒ์„ ๋•Œ TypeError๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋ฉฐ, ์ด๋กœ ์ธํ•ด ์‚ฌ์šฉ์ž๊ฐ€ X-API-Key ํ—ค๋”์— ๋น„-ASCII ๋ฌธ์ž๋ฅผ ์ „์†กํ•˜๋ฉด 500 ์—๋Ÿฌ๊ฐ€ ๋ฐ˜ํ™˜๋˜์–ด DoS ๊ณต๊ฒฉ์˜ ์›์ธ์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ์ปค๋ฐ‹์€ ๋‘ ์ž…๋ ฅ ๋ฌธ์ž์—ด์„ ๋ชจ๋‘ utf-8 ๋ฐ”์ดํŠธ๋กœ ์ธ์ฝ”๋”ฉํ•œ ๋’ค์— hmac.compare_digest๋ฅผ ํ˜ธ์ถœํ•˜๋„๋ก ๊ฐœ์„ ํ•˜์—ฌ ์˜ค๋ฅ˜๋ฅผ ๋ฐฉ์ง€ํ•˜๊ณ  ์ •์ƒ์ ์œผ๋กœ 401 Unauthorized๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.
๊ด€๋ จ ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๋„ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
@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 28, 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: d04c4278-15c0-421a-9b38-93652c4ae55a

๐Ÿ“ฅ Commits

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

๐Ÿ“’ Files selected for processing (3)
  • .jules/sentinel.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 API ํ‚ค ์ž…๋ ฅ์ด 401 ์‘๋‹ต์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ํšŒ๊ท€ ํ…Œ์ŠคํŠธ์™€ ๊ด€๋ จ ๋ณด์•ˆ ํ•™์Šต ๋ฌธ์„œ๋ฅผ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.

Changes

API ํ‚ค ๊ฒ€์ฆ

Layer / File(s) Summary
UTF-8 API ํ‚ค ๋น„๊ต ๋ฐ ํšŒ๊ท€ ๊ฒ€์ฆ
saas_web.py, tests/test_saas_web.py, .jules/sentinel.md
require_api_key๊ฐ€ ์ œ๊ณต๋œ ํ‚ค์™€ ์„ค์ •๋œ ํ‚ค๋ฅผ UTF-8 ๋ฐ”์ดํŠธ๋กœ ๋ณ€ํ™˜ํ•œ ํ›„ hmac.compare_digest๋กœ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค. ๋น„ASCII API ํ‚ค ์š”์ฒญ์€ 401๊ณผ {"error": "Invalid or missing API key"}๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๋ณด์•ˆ ํ•™์Šต ๋ฌธ์„œ์— ์˜ˆ๋ฐฉ ์กฐ์น˜๋ฅผ ๊ธฐ๋กํ•ฉ๋‹ˆ๋‹ค.

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

Merge Risk: โšช Minimal ยท up to c3b28

The change makes non-ASCII X-API-Key values return HTTP 401 instead of HTTP 500 without altering the authentication boundary or deployment behavior. No actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

  • ContextualWisdomLab/codec-carver#303: ๋™์ผํ•œ require_api_key UTF-8 ์ธ์ฝ”๋”ฉ ์ˆ˜์ •๊ณผ ๋น„ASCII API ํ‚ค DoS ๋Œ€์‘์„ ๋‹ค๋ฃน๋‹ˆ๋‹ค.
  • ContextualWisdomLab/codec-carver#326: ๋™์ผํ•œ ์ˆ˜์ •, ํšŒ๊ท€ ํ…Œ์ŠคํŠธ, Sentinel ๋ฌธ์„œ๋ฅผ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.
  • ContextualWisdomLab/codec-carver#451: require_api_key์˜ UTF-8 API ํ‚ค ๋น„๊ต ์ˆ˜์ •์„ ๋‹ค๋ฃน๋‹ˆ๋‹ค.
๐Ÿšฅ Pre-merge checks | โœ… 4 | โŒ 1

โŒ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage โš ๏ธ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1โ€ฆ 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 ํ‚ค ์ฒ˜๋ฆฌ๋กœ ๋ฐœ์ƒํ•˜๋Š” hmac.compare_digest์˜ 500 ์˜ค๋ฅ˜ ์ˆ˜์ •์ด๋ผ๋Š” ์ฃผ์š” ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ๋ช…ํ™•ํ•˜๊ฒŒ ์š”์•ฝํ•ฉ๋‹ˆ๋‹ค.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
โœจ Finishing Touches ๐Ÿ’ก 2
๐Ÿ“ Generate docstrings ๐Ÿ’ก
  • Create stacked PR
  • Commit on current branch
๐Ÿ› ๏ธ Fix failing CI checks ๐Ÿ’ก
  • Create stacked PR
  • Commit on current branch
๐Ÿงช Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jules-11981266730423604347-a86f1501

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.

Devin Review

Comment thread saas_web.py

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: Env-based API key reading remains the documented anti-pattern

AGENTS.md marks the CODEC_CARVER_API_KEYS env read in get_configured_api_keys as a known deviation to migrate to the credential registry. This PR edits the auth path but leaves that runtime env read in place.

(Refers to this code)

Devin Review

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

hmac.compare_digest ํ•จ์ˆ˜๋Š” ASCII ๋ฒ”์œ„ ์™ธ์˜ ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์กŒ์„ ๋•Œ TypeError๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋ฉฐ, ์ด๋กœ ์ธํ•ด ์‚ฌ์šฉ์ž๊ฐ€ X-API-Key ํ—ค๋”์— ๋น„-ASCII ๋ฌธ์ž๋ฅผ ์ „์†กํ•˜๋ฉด 500 ์—๋Ÿฌ๊ฐ€ ๋ฐ˜ํ™˜๋˜์–ด DoS ๊ณต๊ฒฉ์˜ ์›์ธ์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ์ปค๋ฐ‹์€ ๋‘ ์ž…๋ ฅ ๋ฌธ์ž์—ด์„ ๋ชจ๋‘ utf-8 ๋ฐ”์ดํŠธ๋กœ ์ธ์ฝ”๋”ฉํ•œ ๋’ค์— hmac.compare_digest๋ฅผ ํ˜ธ์ถœํ•˜๋„๋ก ๊ฐœ์„ ํ•˜์—ฌ ์˜ค๋ฅ˜๋ฅผ ๋ฐฉ์ง€ํ•˜๊ณ  ์ •์ƒ์ ์œผ๋กœ 401 Unauthorized๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.
๊ด€๋ จ ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๋„ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
hmac.compare_digest ํ•จ์ˆ˜๋Š” ASCII ๋ฒ”์œ„ ์™ธ์˜ ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์กŒ์„ ๋•Œ TypeError๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋ฉฐ, ์ด๋กœ ์ธํ•ด ์‚ฌ์šฉ์ž๊ฐ€ X-API-Key ํ—ค๋”์— ๋น„-ASCII ๋ฌธ์ž๋ฅผ ์ „์†กํ•˜๋ฉด 500 ์—๋Ÿฌ๊ฐ€ ๋ฐ˜ํ™˜๋˜์–ด DoS ๊ณต๊ฒฉ์˜ ์›์ธ์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ์ปค๋ฐ‹์€ ๋‘ ์ž…๋ ฅ ๋ฌธ์ž์—ด์„ ๋ชจ๋‘ utf-8 ๋ฐ”์ดํŠธ๋กœ ์ธ์ฝ”๋”ฉํ•œ ๋’ค์— hmac.compare_digest๋ฅผ ํ˜ธ์ถœํ•˜๋„๋ก ๊ฐœ์„ ํ•˜์—ฌ ์˜ค๋ฅ˜๋ฅผ ๋ฐฉ์ง€ํ•˜๊ณ  ์ •์ƒ์ ์œผ๋กœ 401 Unauthorized๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.
๊ด€๋ จ ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๋„ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
hmac.compare_digest ํ•จ์ˆ˜๋Š” ASCII ๋ฒ”์œ„ ์™ธ์˜ ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์กŒ์„ ๋•Œ TypeError๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋ฉฐ, ์ด๋กœ ์ธํ•ด ์‚ฌ์šฉ์ž๊ฐ€ X-API-Key ํ—ค๋”์— ๋น„-ASCII ๋ฌธ์ž๋ฅผ ์ „์†กํ•˜๋ฉด 500 ์—๋Ÿฌ๊ฐ€ ๋ฐ˜ํ™˜๋˜์–ด DoS ๊ณต๊ฒฉ์˜ ์›์ธ์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ์ปค๋ฐ‹์€ ๋‘ ์ž…๋ ฅ ๋ฌธ์ž์—ด์„ ๋ชจ๋‘ utf-8 ๋ฐ”์ดํŠธ๋กœ ์ธ์ฝ”๋”ฉํ•œ ๋’ค์— hmac.compare_digest๋ฅผ ํ˜ธ์ถœํ•˜๋„๋ก ๊ฐœ์„ ํ•˜์—ฌ ์˜ค๋ฅ˜๋ฅผ ๋ฐฉ์ง€ํ•˜๊ณ  ์ •์ƒ์ ์œผ๋กœ 401 Unauthorized๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.
๊ด€๋ จ ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๋„ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
hmac.compare_digest ํ•จ์ˆ˜๋Š” ASCII ๋ฒ”์œ„ ์™ธ์˜ ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์กŒ์„ ๋•Œ TypeError๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋ฉฐ, ์ด๋กœ ์ธํ•ด ์‚ฌ์šฉ์ž๊ฐ€ X-API-Key ํ—ค๋”์— ๋น„-ASCII ๋ฌธ์ž๋ฅผ ์ „์†กํ•˜๋ฉด 500 ์—๋Ÿฌ๊ฐ€ ๋ฐ˜ํ™˜๋˜์–ด DoS ๊ณต๊ฒฉ์˜ ์›์ธ์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ์ปค๋ฐ‹์€ ๋‘ ์ž…๋ ฅ ๋ฌธ์ž์—ด์„ ๋ชจ๋‘ utf-8 ๋ฐ”์ดํŠธ๋กœ ์ธ์ฝ”๋”ฉํ•œ ๋’ค์— hmac.compare_digest๋ฅผ ํ˜ธ์ถœํ•˜๋„๋ก ๊ฐœ์„ ํ•˜์—ฌ ์˜ค๋ฅ˜๋ฅผ ๋ฐฉ์ง€ํ•˜๊ณ  ์ •์ƒ์ ์œผ๋กœ 401 Unauthorized๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.
๊ด€๋ จ ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๋„ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
hmac.compare_digest ํ•จ์ˆ˜๋Š” ASCII ๋ฒ”์œ„ ์™ธ์˜ ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์กŒ์„ ๋•Œ TypeError๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋ฉฐ, ์ด๋กœ ์ธํ•ด ์‚ฌ์šฉ์ž๊ฐ€ X-API-Key ํ—ค๋”์— ๋น„-ASCII ๋ฌธ์ž๋ฅผ ์ „์†กํ•˜๋ฉด 500 ์—๋Ÿฌ๊ฐ€ ๋ฐ˜ํ™˜๋˜์–ด DoS ๊ณต๊ฒฉ์˜ ์›์ธ์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ์ปค๋ฐ‹์€ ๋‘ ์ž…๋ ฅ ๋ฌธ์ž์—ด์„ ๋ชจ๋‘ utf-8 ๋ฐ”์ดํŠธ๋กœ ์ธ์ฝ”๋”ฉํ•œ ๋’ค์— hmac.compare_digest๋ฅผ ํ˜ธ์ถœํ•˜๋„๋ก ๊ฐœ์„ ํ•˜์—ฌ ์˜ค๋ฅ˜๋ฅผ ๋ฐฉ์ง€ํ•˜๊ณ  ์ •์ƒ์ ์œผ๋กœ 401 Unauthorized๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.
๊ด€๋ จ ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๋„ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
hmac.compare_digest ํ•จ์ˆ˜๋Š” ASCII ๋ฒ”์œ„ ์™ธ์˜ ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์กŒ์„ ๋•Œ TypeError๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋ฉฐ, ์ด๋กœ ์ธํ•ด ์‚ฌ์šฉ์ž๊ฐ€ X-API-Key ํ—ค๋”์— ๋น„-ASCII ๋ฌธ์ž๋ฅผ ์ „์†กํ•˜๋ฉด 500 ์—๋Ÿฌ๊ฐ€ ๋ฐ˜ํ™˜๋˜์–ด DoS ๊ณต๊ฒฉ์˜ ์›์ธ์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ์ปค๋ฐ‹์€ ๋‘ ์ž…๋ ฅ ๋ฌธ์ž์—ด์„ ๋ชจ๋‘ utf-8 ๋ฐ”์ดํŠธ๋กœ ์ธ์ฝ”๋”ฉํ•œ ๋’ค์— hmac.compare_digest๋ฅผ ํ˜ธ์ถœํ•˜๋„๋ก ๊ฐœ์„ ํ•˜์—ฌ ์˜ค๋ฅ˜๋ฅผ ๋ฐฉ์ง€ํ•˜๊ณ  ์ •์ƒ์ ์œผ๋กœ 401 Unauthorized๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.
๊ด€๋ จ ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๋„ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
@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