Verified Commit 4fa7c12d authored by Hercules Merscher's avatar Hercules Merscher 🌴
Browse files

fix: Header construction vulnerability

parent ba58737b
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -123,10 +123,12 @@ module Labkit
          parsed = URI.parse(endpoint)

          headers = {}
          # add basic auth header only when both user and password are setup correctly
          user = parsed.user
          password = parsed.password
          headers["Authorization"] = "Basic #{Base64.strict_encode64("#{user}:#{password}")}" if user.present? && password.present?
          if user.present? && password.present?
            credentials = Base64.strict_encode64("#{CGI.unescape(user)}:#{CGI.unescape(password)}")
            headers["Authorization"] = "Basic #{credentials}"
          end

          headers
        end