Skip to content

๐Ÿ›ก๏ธ Sentinel: [HIGH] ๋น„ ASCII ํ—ค๋”๋กœ ์ธํ•œ DoS ์ทจ์•ฝ์  ์ˆ˜์ • - #434

Open
seonghobae wants to merge 2 commits into
developfrom
fix-hmac-non-ascii-12033426029127814609
Open

๐Ÿ›ก๏ธ Sentinel: [HIGH] ๋น„ ASCII ํ—ค๋”๋กœ ์ธํ•œ DoS ์ทจ์•ฝ์  ์ˆ˜์ •#434
seonghobae wants to merge 2 commits into
developfrom
fix-hmac-non-ascii-12033426029127814609

Conversation

@seonghobae

@seonghobae seonghobae commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

๐Ÿšจ Severity: HIGH
๐Ÿ’ก Vulnerability: Authorization ํ—ค๋”์— ๋น„ ASCII ๋ฌธ์ž๊ฐ€ ํฌํ•จ๋  ๊ฒฝ์šฐ hmac.compare_digest()์—์„œ TypeError๊ฐ€ ๋ฐœ์ƒํ•˜์—ฌ 500 Internal Server Error๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” DoS ์ทจ์•ฝ์ ์ด ๋ฐœ๊ฒฌ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
๐ŸŽฏ Impact: ์•…์˜์ ์ธ ์‚ฌ์šฉ์ž๊ฐ€ ํŠน์ˆ˜ ๋ฌธ์ž๊ฐ€ ํฌํ•จ๋œ ์ธ์ฆ ํ—ค๋”๋ฅผ ์ „์†กํ•˜์—ฌ ์„œ๋น„์Šค์— ์˜ˆ๊ธฐ์น˜ ์•Š์€ ์˜ค๋ฅ˜๋ฅผ ์œ ๋ฐœํ•˜๊ณ  ๋ฆฌ์†Œ์Šค๋ฅผ ๊ณ ๊ฐˆ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๐Ÿ”ง Fix: hmac.compare_digest()๋กœ ๋น„๊ตํ•˜๊ธฐ ์ „์— ์ž…๋ ฅ๊ฐ’์„ .encode('utf-8')์„ ํ†ตํ•ด ๋ฐ”์ดํŠธ ๋ฐฐ์—ด๋กœ ์ธ์ฝ”๋”ฉํ•˜๋„๋ก ์ˆ˜์ •ํ•˜์—ฌ ์˜ˆ์™ธ๋ฅผ ๋ฐฉ์ง€ํ–ˆ์Šต๋‹ˆ๋‹ค.
โœ… Verification: tests/test_auth.py์— ๋น„ ASCII ์ธ์ฆ ํ—ค๋”๋ฅผ ์ „์†กํ•˜์—ฌ 401 ์—๋Ÿฌ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š”์ง€ ํ™•์ธํ•˜๋Š” ํ…Œ์ŠคํŠธ(test_parse_rejects_non_ascii_bearer_without_500)๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ๋ชจ๋“  ํ…Œ์ŠคํŠธ๊ฐ€ ํ†ต๊ณผํ•˜๋Š”์ง€ ํ™•์ธํ–ˆ์Šต๋‹ˆ๋‹ค.


PR created automatically by Jules for task 12033426029127814609 started by @seonghobae

Summary by CodeRabbit

  • ๋ฒ„๊ทธ ์ˆ˜์ •

    • ๋น„ASCII ๋ฌธ์ž๊ฐ€ ํฌํ•จ๋œ ์ธ์ฆ ํ—ค๋” ์ฒ˜๋ฆฌ ์ค‘ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์„œ๋ฒ„ ์˜ค๋ฅ˜๋ฅผ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.
    • ์ž˜๋ชป๋œ ์ธ์ฆ ์š”์ฒญ์ด 500 ์˜ค๋ฅ˜ ๋Œ€์‹  401 Unauthorized ์‘๋‹ต์œผ๋กœ ์ •์ƒ ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.
    • ๊ธฐ์กด ์ธ์ฆ ์‹คํŒจ ์‘๋‹ต๊ณผ WWW-Authenticate ํ—ค๋” ๋™์ž‘์€ ์œ ์ง€๋ฉ๋‹ˆ๋‹ค.
  • ํ…Œ์ŠคํŠธ

    • ๋น„ASCII ์ธ์ฆ ํ† ํฐ์— ๋Œ€ํ•œ ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ ๊ฒ€์ฆ์„ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.

@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.

Copilot AI review requested due to automatic review settings July 26, 2026 21:02
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 21 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c6f1f1bc-7bee-4270-be84-cf3f0b755e7a

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between fd30f65 and 2d49757.

โ›” Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
๐Ÿ“’ Files selected for processing (1)
  • .trivyignore
๐Ÿ“ Walkthrough

Walkthrough

Authorization ํ† ํฐ ๋น„๊ต๋ฅผ UTF-8 ๋ฐ”์ดํŠธ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ณ€๊ฒฝํ•˜๊ณ , ๋น„ASCII ํ—ค๋” ์ž…๋ ฅ์ด 500 ๋Œ€์‹  401์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ…Œ์ŠคํŠธ์™€ ์ทจ์•ฝ์  ๋Œ€์‘ ๊ธฐ๋ก์„ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.

Changes

Authorization ์ธ์ฆ ๊ฐ•ํ™”

Layer / File(s) Summary
ํ† ํฐ ๋น„๊ต ๋ฐ ๋น„ASCII ์ž…๋ ฅ ๊ฒ€์ฆ
src/newsdom_api/main.py, tests/test_auth.py, .jules/sentinel.md
Authorization ํ† ํฐ์„ UTF-8 ๋ฐ”์ดํŠธ๋กœ ์ƒ์ˆ˜์‹œ๊ฐ„ ๋น„๊ตํ•˜๊ณ , ๋น„ASCII bearer ์ž…๋ ฅ์— ๋Œ€ํ•ด 401 Unauthorized์™€ Unauthorized ์ƒ์„ธ ๋ฉ”์‹œ์ง€๋ฅผ ๊ฒ€์ฆํ•˜๋ฉฐ ๊ด€๋ จ ์ทจ์•ฝ์  ๋Œ€์‘์„ ๋ฌธ์„œํ™”ํ–ˆ์Šต๋‹ˆ๋‹ค.

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

Suggested reviewers: copilot

๐Ÿšฅ Pre-merge checks | โœ… 5
โœ… Passed checks (5 passed)
Check name Status Explanation
Title check โœ… Passed ๋น„ ASCII ํ—ค๋”๋กœ ์ธํ•œ DoS ์ทจ์•ฝ์  ์ˆ˜์ •์ด๋ผ๋Š” ํ•ต์‹ฌ ๋ณ€๊ฒฝ์„ ๋ช…ํ™•ํžˆ ๋‹ด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
Description check โœ… Passed ํ•ต์‹ฌ ์š”์•ฝ๊ณผ ๊ฒ€์ฆ ๋‚ด์šฉ์€ ์ถฉ๋ถ„ํ•˜์ง€๋งŒ, ํ…œํ”Œ๋ฆฟ์˜ Git Flow target๊ณผ Notes ์„น์…˜์€ ํฌํ•จ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.
Docstring Coverage โœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
โœจ Finishing Touches
๐Ÿงช Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-hmac-non-ascii-12033426029127814609

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

๐Ÿค– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.jules/sentinel.md:
- Line 93: Update the โ€œ2024-05-15 - DoS via non-ASCII headers in HMAC
comparisonโ€ heading in sentinel.md by adding a blank line before the heading and
another blank line after the vulnerability description, satisfying markdownlint
MD022 without changing the content.
๐Ÿช„ Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

โ„น๏ธ Review info
โš™๏ธ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 581717bd-4a70-4da1-a73f-9814e4e80391

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 04491c0 and fd30f65.

๐Ÿ“’ Files selected for processing (3)
  • .jules/sentinel.md
  • src/newsdom_api/main.py
  • tests/test_auth.py

Comment thread .jules/sentinel.md
**Vulnerability:** The `_safe_upload_filename` function used `filename.replace`, `PurePosixPath`, and `re.sub` on unbounded client input, making it vulnerable to ReDoS or CPU/memory exhaustion (DoS) when fed extremely long strings.
**Learning:** Even fast standard library functions like `PurePosixPath` and string replacements can cause significant lag when chained on strings in the megabytes. String processing operations should always bound their inputs first if the input is untrusted and can be arbitrarily large.
**Prevention:** Cap the length of client-provided filename strings early by slicing them (e.g. `filename = filename[-512:]`) before doing more complex string parsing or regex replacements, especially when only the basename suffix is relevant.
## 2024-05-15 - DoS via non-ASCII headers in HMAC comparison

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ“ Maintainability & Code Quality | ๐ŸŸก Minor | โšก Quick win

์ œ๋ชฉ ์•ž๋’ค์— ๋นˆ ์ค„์„ ์ถ”๊ฐ€ํ•˜์„ธ์š”.

markdownlint์˜ MD022 ๊ฒฝ๊ณ ๋ฅผ ํ•ด๊ฒฐํ•˜๋ ค๋ฉด ์ƒˆ ์ œ๋ชฉ ์•ž๊ณผ ์ทจ์•ฝ์  ์„ค๋ช… ๋’ค์— ๋นˆ ์ค„์„ ์ถ”๊ฐ€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์ˆ˜์ • ์˜ˆ์‹œ
+ 
 ## 2024-05-15 - DoS via non-ASCII headers in HMAC comparison
+
 **Vulnerability:** The API crashed with a 500 Internal Server Error when a non-ASCII string was provided in the `Authorization` header, because `hmac.compare_digest()` raises a `TypeError` for non-ASCII inputs.
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## 2024-05-15 - DoS via non-ASCII headers in HMAC comparison
## 2024-05-15 - DoS via non-ASCII headers in HMAC comparison
๐Ÿงฐ Tools
๐Ÿช› markdownlint-cli2 (0.23.0)

[warning] 93-93: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Above

(MD022, blanks-around-headings)


[warning] 93-93: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

๐Ÿค– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.jules/sentinel.md at line 93, Update the โ€œ2024-05-15 - DoS via non-ASCII
headers in HMAC comparisonโ€ heading in sentinel.md by adding a blank line before
the heading and another blank line after the vulnerability description,
satisfying markdownlint MD022 without changing the content.

Source: Linters/SAST tools

Copilot AI 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.

Pull request overview

This PR hardens the optional bearer-auth gate on POST /parse by preventing a TypeError crash when the Authorization header contains non-ASCII characters, eliminating a potential DoS vector in the auth check.

Changes:

  • Encode both the provided and expected bearer strings to UTF-8 bytes before calling hmac.compare_digest().
  • Add a regression test ensuring non-ASCII Authorization input returns 401 Unauthorized (not 500).
  • Document the vulnerability/learning/prevention entry in the Sentinel log.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/newsdom_api/main.py Makes bearer token comparison robust to non-ASCII header values by comparing UTF-8 bytes.
tests/test_auth.py Adds a regression test covering non-ASCII Authorization input to ensure a 401 response.
.jules/sentinel.md Records the vulnerability and prevention guidance for future reference.

๐Ÿ’ก Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings July 26, 2026 21:06

Copilot AI 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.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Comment thread .trivyignore
Comment on lines +23 to +26
# CVE-2026-61632 applies to pymdown-extensions via mkdocs-material.
# An upstream fix is not yet available for this vulnerability.
# Revisit by 2026-10-31 or when an upstream patch is available.
CVE-2026-61632
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.

2 participants