Skip to content

🛡️ Sentinel: [MEDIUM] Fix CWE-617 Assert Vulnerabilities - #1264

Closed
seonghobae wants to merge 1 commit into
mainfrom
sentinel-fix-asserts-7291596528294298656
Closed

seonghobae wants to merge 1 commit into
mainfrom
sentinel-fix-asserts-7291596528294298656

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🚨 Severity: MEDIUM
💡 Vulnerability: assert statements were being used for critical invariants in llm_judge.py and judge_calibration.py. These statements are stripped out in optimized environments (e.g., when Python is run with the -O flag), which could lead to logic bugs and undefined behavior bypassing critical validity checks.
🎯 Impact: Using assert creates a CWE-617 vulnerability because logic flow is vulnerable to bypass during production runtime execution.
🔧 Fix: Replaced assert statements with if not condition: followed by raising RuntimeError, guaranteeing invariants are always strictly enforced regardless of the optimization flag.
✅ Verification: Ran uv sync --all-extras && uv run pytest tests/test_judge_calibration.py tests/test_llm_judge.py tests/test_llm_judge_modes.py tests/test_llm_judge_description_boundary.py and all tests passed successfully.


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


Open in Devin Review

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for unexpected missing calibration results.
    • Validation checks now remain active consistently across runtime configurations.
    • Added clearer runtime errors when required category anchors or counts are unavailable.

🚨 Severity: MEDIUM
💡 Vulnerability: `assert` statements were being used for critical invariants in `llm_judge.py` and `judge_calibration.py`. These statements are stripped out in optimized environments (e.g., when Python is run with the `-O` flag), which could lead to logic bugs and undefined behavior bypassing critical validity checks.
🎯 Impact: Using `assert` creates a CWE-617 vulnerability because logic flow is vulnerable to bypass during production runtime execution.
🔧 Fix: Replaced `assert` statements with `if not condition:` followed by raising `RuntimeError`, guaranteeing invariants are always strictly enforced regardless of the optimization flag.
✅ Verification: Ran `uv sync --all-extras && uv run pytest tests/test_judge_calibration.py tests/test_llm_judge.py tests/test_llm_judge_modes.py tests/test_llm_judge_description_boundary.py` and all tests passed successfully.
@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 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b32207f8-39d5-4c48-8de0-0d945344ba80

📥 Commits

Reviewing files that changed from the base of the PR and between 04d0bc2 and 57be153.

📒 Files selected for processing (2)
  • python/fast_mlsirm/judge_calibration.py
  • python/fast_mlsirm/llm_judge.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change replaces internal assertions with explicit RuntimeError checks for missing calibration results, category anchors, and invalid category counts.

Changes

Runtime validation

Layer / File(s) Summary
Replace assertion checks with RuntimeError validation
python/fast_mlsirm/judge_calibration.py, python/fast_mlsirm/llm_judge.py
Calibration methods now validate required results explicitly. Judge processing validates category anchors and category counts with RuntimeError checks.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 57be1

The PR replaces optimization-sensitive assertions with explicit runtime errors for invariant checks. This is a localized behavior-preserving hardening change, and no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the CWE-617 assert vulnerability fixes implemented in the pull request.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sentinel-fix-asserts-7291596528294298656

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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Copy link
Copy Markdown
Contributor Author

Closing as a same-scope duplicate of #1019 rather than creating competing writers on llm_judge.py / judge_calibration.py.

Fresh comparison at close time:

#1019 remains the single live writer for this mutable surface. No commits from #1264 are being merged or force-applied.

@seonghobae seonghobae closed this Aug 23, 2026
@google-labs-jules

Copy link
Copy Markdown

Closing as a same-scope duplicate of #1019 rather than creating competing writers on llm_judge.py / judge_calibration.py.

Fresh comparison at close time:

#1019 remains the single live writer for this mutable surface. No commits from #1264 are being merged or force-applied.

Understood. Acknowledging that this work is a duplicate of #1019 and stopping work on this task.

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