Skip to content

Commit 19e49f0

Browse files
jhawthorntenderlove
authored andcommitted
Forbid control characters in attributes
This commit restricts the characters accepted in ATTRIBUTE_CHAR, forbidding control characters and fixing a ReDOS vulnerability. This also now should fully follow the RFCs. RFC 2231, Section 7 specifies: attribute-char := <any (US-ASCII) CHAR except SPACE, CTLs, "*", "'", "%", or tspecials> RFC 2045, Appendix A specifies: tspecials := "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / <"> "/" / "[" / "]" / "?" / "=" RFC 822, Section 3.3 specifies: CTL = <any ASCII control ; ( 0- 37, 0.- 31.) character and DEL> ; ( 177, 127.) SPACE = <ASCII SP, space> ; ( 40, 32.) [CVE-2022-44572]
1 parent ea39e49 commit 19e49f0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/rack/multipart.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module Multipart
2121
MULTIPART_CONTENT_DISPOSITION = /Content-Disposition:.*;\s*name=(#{VALUE})/ni
2222
MULTIPART_CONTENT_ID = /Content-ID:\s*([^#{EOL}]*)/ni
2323
# Updated definitions from RFC 2231
24-
ATTRIBUTE_CHAR = %r{[^ \t\v\n\r)(><@,;:\\"/\[\]?='*%]}
24+
ATTRIBUTE_CHAR = %r{[^ \x00-\x1f\x7f)(><@,;:\\"/\[\]?='*%]}
2525
ATTRIBUTE = /#{ATTRIBUTE_CHAR}+/
2626
SECTION = /\*[0-9]+/
2727
REGULAR_PARAMETER_NAME = /#{ATTRIBUTE}#{SECTION}?/

0 commit comments

Comments
 (0)