Skip to content

Conversation

@koic
Copy link
Member

@koic koic commented Jan 8, 2026

Motivation and Context

Replace regex patterns with lookahead/lookbehind assertions to prevent catastrophic backtracking on Ruby 3.1 and earlier.

This issue only affects Ruby 3.1 and earlier. Since it does not occur on Ruby 3.2+, it is not an issue in the current stable release (0.4.0), which does not include #206.

How Has This Been Tested?

Ensure the regex patterns complete within 1 second for a 50,000-character input that would otherwise trigger superlinear backtracking.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

## Summary

Replace regex patterns with lookahead/lookbehind assertions to prevent
catastrophic backtracking on Ruby 3.1 and earlier.

This issue only affects Ruby 3.1 and earlier. Since it does not occur on Ruby 3.2+,
it is not an issue in the current stable release (0.4.0), which does not include modelcontextprotocol#206.

## Regression Testing

Ensure the regex patterns complete within 1 second for a 50,000-character input
that would otherwise trigger superlinear backtracking.
@koic koic merged commit 6b18ca4 into modelcontextprotocol:main Jan 9, 2026
10 checks passed
@koic koic deleted the avoid_redos_in_ruby_3_1_and_earlier branch January 9, 2026 16:16
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