Skip to content

Commit 7c13988

Browse files
committed
Avoid backtracking in Token#raw_params
Thanks to scyoon for the patch [CVE-2024-47887]
1 parent 8373fbf commit 7c13988

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

actionpack/lib/action_controller/metal/http_authentication.rb

+1-4
Original file line numberDiff line numberDiff line change
@@ -507,14 +507,11 @@ def rewrite_param_values(array_params)
507507
array_params.each { |param| (param[1] || +"").gsub! %r/^"|"$/, "" }
508508
end
509509

510-
WHITESPACED_AUTHN_PAIR_DELIMITERS = /\s*#{AUTHN_PAIR_DELIMITERS}\s*/
511-
private_constant :WHITESPACED_AUTHN_PAIR_DELIMITERS
512-
513510
# This method takes an authorization body and splits up the key-value
514511
# pairs by the standardized <tt>:</tt>, <tt>;</tt>, or <tt>\t</tt>
515512
# delimiters defined in +AUTHN_PAIR_DELIMITERS+.
516513
def raw_params(auth)
517-
_raw_params = auth.sub(TOKEN_REGEX, "").split(WHITESPACED_AUTHN_PAIR_DELIMITERS)
514+
_raw_params = auth.sub(TOKEN_REGEX, "").split(AUTHN_PAIR_DELIMITERS).map(&:strip)
518515
_raw_params.reject!(&:empty?)
519516

520517
if !_raw_params.first&.start_with?(TOKEN_KEY)

0 commit comments

Comments
 (0)