Skip to content

Commit 6af501a

Browse files
eliotsykesandrew
authored andcommitted
Avoid variable_size_secure_compare private method (#465)
1 parent d464ecd commit 6af501a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,9 @@ You may want to password protect that page, you can do so with `Rack::Auth::Basi
439439
Split::Dashboard.use Rack::Auth::Basic do |username, password|
440440
# Protect against timing attacks:
441441
# - Use & (do not use &&) so that it doesn't short circuit.
442-
# - Use `variable_size_secure_compare` to stop length information leaking
443-
ActiveSupport::SecurityUtils.variable_size_secure_compare(username, ENV["SPLIT_USERNAME"]) &
444-
ActiveSupport::SecurityUtils.variable_size_secure_compare(password, ENV["SPLIT_PASSWORD"])
442+
# - Use digests to stop length information leaking
443+
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(username), ::Digest::SHA256.hexdigest(ENV["SPLIT_USERNAME"])) &
444+
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(password), ::Digest::SHA256.hexdigest(ENV["SPLIT_PASSWORD"]))
445445
end
446446

447447
# Apps without activesupport

0 commit comments

Comments
 (0)