diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb
index 8b43b6068900e238f8f3d6c695641404b24945f0..6d87df17e757461ce897252945d9a20e0ba65385 100644
--- a/lib/gitlab/backend/grack_auth.rb
+++ b/lib/gitlab/backend/grack_auth.rb
@@ -109,6 +109,8 @@ def current_ref
       else
         input = @request.body.read
       end
+      # force utf-8 encoding
+      input.encode!('UTF-8', 'UTF-8', invalid: :replace, undef: :replace, replace: '')
       # Need to reset seek point
       @request.body.rewind
       /refs\/heads\/([\w\.-]+)/.match(input).to_a.last