Skip to content

Line break in long base64 Authorization header causing 401 #64

Description

@Kl0ven

Hi,

I have a registry with a long password and i always get UNAUTHORIZED Error. Here are my finding :
Using caveman debuging, I modify the file lib/helper.rb

def generateHeaders(config, session, headers={}, login={})
    username = login[:username] || session[:username] || config.registry_username
    password = login[:password] || session[:password] || config.registry_password
    if username
      headers['Authorization'] = "Basic #{base64_docker_auth(username, password)}"
      print base64_docker_auth(username, password) # printing the base64 encoded
    end
    return headers
  end

When restart the app, I find in the logs a line break in th bas64 encoded. The line feed is exactly a 60 char

12:42:15 web.1  | 172.31.204.196 - - [01/Sep/2021:12:42:15 +0000] "GET /containers HTTP/1.1" 200 797 0.0679
12:42:16 web.1  | 172.31.204.196 - - [01/Sep/2021:12:42:16 +0000] "GET /api/registryinfo HTTP/1.1" 200 202 0.0052
12:42:16 web.1  | 172.31.204.196 - - [01/Sep/2021:12:42:16 +0000] "GET /api/registryinfo HTTP/1.1" 200 202 0.0034
12:42:16 web.1  | dGhpc19pc19hX3VzZXJuYW1lOnRoaXNfaXNfYV92ZXJ5X2xvbmdfcGFzc3dv
12:42:16 web.1  | YXJkX21vcmVfdGhhbl82MA==Error talking to the docker registry!

I don't know ruby but it looks like strict_encode64(bin) does not do what it's supposed to, by including line feed.
Any idea ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions