authelia: panic: runtime error: index out of range [-1]

Bug Report

Description

Crash at a random point; no certain way for reproducing it. Service has been stable for ages, looks like it’s a one-off. Possible notable bit is the issue occurred after drone, running on the same docker host, was added to the environment. Relevant bypass rule in Auhtelia:

  networks:
    - name: internal
      networks:
        - 172.19.0.0/16
        - 172.17.0.0/16

  rules:
    - domain:
        - mydomain.com
        - "*.mydomain.com"
      policy: bypass
      networks:
        - internal

Expected Behaviour

N/A

Reproduction Steps

N/A

Additional Information

Docker image id: 564d45bfafad (tracking latest; image inspect at the bottom) Logs at the time of service crash:

time="2021-08-27T10:45:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:45:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:46:27+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:46:27+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:46:27+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:46:27+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:46:27+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:46:27+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:46:27+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:46:27+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:46:27+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:46:27+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:07+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
time="2021-08-27T10:47:47+02:00" level=debug msg="Check authorization of subject username= groups= ip=172.19.0.1 and object https://drone.mydomain.com/rpc/v2/stage (method )."
panic: runtime error: index out of range [-1]

goroutine 15040 [running]:
math/rand.(*rngSource).Uint64(...)
math/rand/rng.go:249
math/rand.(*rngSource).Int63(0xc000121500, 0x4917bffa6fbf717b)
math/rand/rng.go:234 +0x98
github.com/savsgio/gotils/bytes.Rand(0xc0000c6780, 0x20, 0x20, 0xc0000c6780, 0x0, 0x0)
github.com/savsgio/gotils@v0.0.0-20210617111740-97865ed5a873/bytes/bytes.go:19 +0xad
github.com/fasthttp/session/v2.(*Config).defaultSessionIDGenerator(...)
github.com/fasthttp/session/v2@v2.4.1/config.go:33
github.com/fasthttp/session/v2.(*Session).Get(0xc00051a000, 0xc0004b8580, 0x1275f00, 0x7, 0x9cbbcb6400000000)
github.com/fasthttp/session/v2@v2.4.1/session.go:156 +0x204
github.com/authelia/authelia/v4/internal/session.(*Provider).GetSession(0xc00041c450, 0xc0004b8580, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
github.com/authelia/authelia/v4/internal/session/provider.go:78 +0x75
github.com/authelia/authelia/v4/internal/middlewares.(*AutheliaCtx).GetSession(0xc0001d2900, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
github.com/authelia/authelia/v4/internal/middlewares/authelia_context.go:161 +0x90
github.com/authelia/authelia/v4/internal/handlers.verifyAuth(0xc0001d2900, 0xc00013a1b0, 0x0, 0x0, 0xc00045b058, 0x1, 0x1, 0x154991776108, 0x30, 0xc000342ea0, ...)
github.com/authelia/authelia/v4/internal/handlers/handler_verify.go:423 +0x18f
github.com/authelia/authelia/v4/internal/handlers.VerifyGet.func1(0xc0001d2900)
github.com/authelia/authelia/v4/internal/handlers/handler_verify.go:475 +0x327
github.com/authelia/authelia/v4/internal/middlewares.AutheliaMiddleware.func1.1(0xc0004b8580)
github.com/authelia/authelia/v4/internal/middlewares/authelia_context.go:51 +0x166
github.com/fasthttp/router.(*Router).Handler(0xc000263c00, 0xc0004b8580)
github.com/fasthttp/router@v1.4.1/router.go:414 +0x7c3
github.com/authelia/authelia/v4/internal/middlewares.LogRequestMiddleware.func1(0xc0004b8580)
github.com/authelia/authelia/v4/internal/middlewares/log_request.go:14 +0xe2
github.com/authelia/authelia/v4/internal/middlewares.StripPathMiddleware.func1(0xc0004b8580)
github.com/authelia/authelia/v4/internal/middlewares/strip_path.go:21 +0xd0
github.com/valyala/fasthttp.(*Server).serveConn(0xc000124900, 0x2a241e0, 0xc0000a8050, 0x0, 0x0)
github.com/valyala/fasthttp@v1.28.0/server.go:2239 +0x14a2
github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc0004f8960, 0xc00025a280)
github.com/valyala/fasthttp@v1.28.0/workerpool.go:223 +0xba
github.com/valyala/fasthttp.(*workerPool).getCh.func1(0xc0004f8960, 0xc00025a280, 0x1112180, 0xc00025a280)
github.com/valyala/fasthttp@v1.28.0/workerpool.go:195 +0x35
created by github.com/valyala/fasthttp.(*workerPool).getCh
github.com/valyala/fasthttp@v1.28.0/workerpool.go:194 +0x11f
$ docker image inspect 564d45bfafad
[
    {
        "Id": "sha256:564d45bfafad973de93720ac066a1ad88d5e2d8b9173ddb452cc0dff6339ba10",
        "RepoTags": [
            "authelia/authelia:latest"
        ],
        "RepoDigests": [
            "authelia/authelia@sha256:956a7577adeb3d430bb1fc00b08baa8aecddec3949dd767363a43fcc6465d34a"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2021-08-11T01:51:12.03904675Z",

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

You are welcome to test the authelia/authelia:fix-fasthttp-session-id image.