Skip to content

Fix Regexp::TimeoutError SQL injection bypass#258

Open
marksmith wants to merge 9 commits intomainfrom
return-attack-on-regexp-timeout-error
Open

Fix Regexp::TimeoutError SQL injection bypass#258
marksmith wants to merge 9 commits intomainfrom
return-attack-on-regexp-timeout-error

Conversation

@marksmith
Copy link
Copy Markdown
Collaborator

@marksmith marksmith commented Mar 23, 2026

Since Ruby 3.2, if Regexp.timeout is set, regular expression matching is aborted after Regexp.timeout by raising Regexp::TimeoutError. Since Rails 8.0, Regexp.timeout is set to 1 second by default. This change treats a Regexp::TimeoutError during SQL injection detection as an attack.

Summary by Aikido

Security Issues: 0 Quality Issues: 0 Resolved Issues: 0

⚡ Enhancements

  • Added regexp_with_timeout helper and applied configurable internal regex timeouts

🐛 Bugfixes

  • Treated Regexp::TimeoutError during SQL injection detection as attack

🔧 Refactors

  • Replaced string RUBY_VERSION comparisons with Gem::Version based checks

More info

for detecting numbers and comma-separated list of numbers.
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Around numbers and in comma-separated lists of numbers.
@marksmith marksmith force-pushed the return-attack-on-regexp-timeout-error branch from caa4afc to 1e13f60 Compare March 23, 2026 16:46
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.

3 participants