Skip to content

Commit

Permalink
Avoid backtracking in Token#raw_params
Browse files Browse the repository at this point in the history
Thanks to scyoon for the patch

[CVE-2024-47887]
  • Loading branch information
jhawthorn committed Oct 15, 2024
1 parent 8373fbf commit 7c13988
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -507,14 +507,11 @@ def rewrite_param_values(array_params)
array_params.each { |param| (param[1] || +"").gsub! %r/^"|"$/, "" }
end

WHITESPACED_AUTHN_PAIR_DELIMITERS = /\s*#{AUTHN_PAIR_DELIMITERS}\s*/
private_constant :WHITESPACED_AUTHN_PAIR_DELIMITERS

# This method takes an authorization body and splits up the key-value
# pairs by the standardized <tt>:</tt>, <tt>;</tt>, or <tt>\t</tt>
# delimiters defined in +AUTHN_PAIR_DELIMITERS+.
def raw_params(auth)
_raw_params = auth.sub(TOKEN_REGEX, "").split(WHITESPACED_AUTHN_PAIR_DELIMITERS)
_raw_params = auth.sub(TOKEN_REGEX, "").split(AUTHN_PAIR_DELIMITERS).map(&:strip)
_raw_params.reject!(&:empty?)

if !_raw_params.first&.start_with?(TOKEN_KEY)
Expand Down

0 comments on commit 7c13988

Please sign in to comment.