Skip to content

Dockerhub returns 401 for newly granted token when load balancing to clock-skewed server #22158

Closed

Description

@liggitt

Output of docker version:

Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      darwin/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64

Output of docker info:

Containers: 31
Images: 137
Server Version: 1.9.1
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 199
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.13-boot2docker
Operating System: Boot2Docker 1.9.1 (TCL 6.4.1); master : cef800b - Fri Nov 20 19:33:59 UTC 2015
CPUs: 1
Total Memory: 1.956 GiB
Name: default
ID: USC4:JH4X:YRFN:JF4R:DWLE:PFJQ:7LCM:JRW2:YSFT:QFAY:PQD4:R5EN
Debug mode (server): true
 File Descriptors: 19
 Goroutines: 38
 System Time: 2016-04-19T15:40:41.84081311Z
 EventsListeners: 0
 Init SHA1: 
 Init Path: /usr/local/bin/docker
 Docker Root Dir: /mnt/sda1/var/lib/docker
Labels:
 provider=virtualbox

Additional environment details (AWS, VirtualBox, physical, etc.):

Steps to reproduce the issue:

  1. Request a token from dockerhub (GET https://auth.docker.io/token?scope=repository%3Alibrary%2Fmysql%3Apull&service=registry.docker.io)
  2. Immediately use the token to make an API request

Describe the results you received:
A 401 response is sometimes returned

Describe the results you expected:
Tokens are immediately usable

Additional information you deem important (e.g. issue happens only occasionally):

  1. The JWT tokens returned from dockerhub have a nbf (not before) set to exactly the current timestamp of the granting server
  2. If that token is immediately used against dockerhub and is load-balanced to a server with a clock skewed in the past, the token is rejected
  3. Test case at https://gist.github.com/liggitt/e7d06dc1cbc9d44034f762c5654c6fff

Activity

  1. liggitt commented on Apr 19, 2016

    @liggitt
    Author

    Either of the following fixes would work:

    1. Create the JWT with a nbf far enough in the past to account for clock-skew between the servers in the auth domain
    2. Allow for clock skew when validating the nbf in a presented JWT.
  2. thaJeztah commented on Apr 19, 2016

    @thaJeztah
    Member

    @LiGgit can you report this through [email protected]? Docker Hub is handled by a different team, so unfortunately there's nothing we can do in this repo.

    Thanks for reporting though!

  3. liggitt commented on Apr 19, 2016

    @liggitt
    Author

    ok, will report there

  4. thaJeztah commented on Apr 19, 2016

    @thaJeztah
    Member

    Thanks @liggitt 👍

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions