Actions
Misc #22502
openClarify whether compiling an untrusted string into a Regexp is supported
Misc #22502:
Clarify whether compiling an untrusted string into a Regexp is supported
Status:
Open
Assignee:
-
Description
Proposal¶
Decide whether compiling an untrusted string into a Regexp is a supported use case, and document the decision.
- If it's not supported:
- Document it in
Regexp.newand doc/security/security.rdoc, likeMarshal.loadandeval. - Treat memory corruption bugs that only untrusted patterns can trigger as normal bugs.
- Document it in
- If it's supported:
Background¶
- Ruby 4.0.9, 3.4.12, and 3.3.13 fixed Regexp compilation bugs that led to RCE on GitLab. GitLab assigned CVEs to them, but we haven't requested CVEs for Ruby itself. See the
announcement. - The current documentation is not clear about it:
- The CVE-2022-28738 advisory says "in general, it is considered unsafe to create and use a Regexp object generated from untrusted input", but we still assigned a CVE to it. We did the same for CVE-2024-27282.
- The Regexp documentation mentions untrusted sources only for DoS, and recommends
Regexp.timeout.
- It's not only
Regexp.newand/#{...}/.String#matchandString#match?also compile a String argument, e.g."str".match?(user_input).
Actions