Repository navigation
Description
Hello all,
Thank you for making Concourse! Recently I encountered the following issue.
Bug Report
The Concourse Web is crashing if the the --session-signing-key command line argument is not provided.
Steps to reproduce
Start a concourse worker.
Start concourse web without the --session-signing-key argument:
/home/concourse/bin/concourse web
--basic-auth-username concourse
--basic-auth-password password
--tsa-host-key /home/concourse/keys/tsa_host_key
--tsa-authorized-keys /home/concourse/keys/authorized_worker_keys
--postgres-data-source postgres://dbuser:[email protected]/atc
--external-url https://myconcourse.mydomain.net
--log-level debug
Right after the worker connects the ATC crashes with the following output
{"timestamp":"1523622119.463756800","source":"tsa","message":"tsa.listening","log_level":1,"data":{}}
{"timestamp":"1523622119.464857578","source":"atc","message":"atc.syncer.starting-pipeline","log_level":0,"data":{"pipeline":"pipeline-simple","session":"46"}}
{"timestamp":"1523622119.465244055","source":"atc","message":"atc.syncer.pipeline-simple:radar.start","log_level":1,"data":{"session":"46.1"}}
{"timestamp":"1523622119.466743231","source":"atc","message":"atc.syncer.pipeline-simple:scheduler.start","log_level":1,"data":{"interval":"10s","session":"46.2"}}
{"timestamp":"1523622119.467194796","source":"atc","message":"atc.syncer.pipeline-simple:scheduler.tick.lock.acquire.acquired","log_level":0,"data":{"id":[2,1],"pipeline":"pipeline-simple","session":"46.2.1.1.1"}}
{"timestamp":"1523622119.468015909","source":"atc","message":"atc.build-tracker.track.start","log_level":0,"data":{"session":"47.1"}}
{"timestamp":"1523622119.469220400","source":"atc","message":"atc.listening","log_level":1,"data":{"debug":"127.0.0.1:8079","http":"0.0.0.0:8080"}}
{"timestamp":"1523622119.486688614","source":"atc","message":"atc.syncer.pipeline-simple:scheduler.tick.lock.release.released","log_level":0,"data":{"id":[2,1],"pipeline":"pipeline-simple","session":"46.2.1.1.2"}}
{"timestamp":"1523622119.487082005","source":"atc","message":"atc.build-tracker.track.done","log_level":0,"data":{"session":"47.1"}}
{"timestamp":"1523622121.367581367","source":"tsa","message":"tsa.connection.keepalive","log_level":1,"data":{"remote":"127.0.0.1:42098","session":"1","type":"keepalive"}}
{"timestamp":"1523622121.367898941","source":"tsa","message":"tsa.connection.channel.channel-request","log_level":1,"data":{"remote":"127.0.0.1:42098","session":"1.1","type":"exec"}}
{"timestamp":"1523622121.368175030","source":"tsa","message":"tsa.connection.tcpip-forward.forwarding-tcpip","log_level":1,"data":{"remote":"127.0.0.1:42098","requested-bind-addr":"0.0.0.0:7777","session":"1.2"}}
{"timestamp":"1523622121.368370533","source":"tsa","message":"tsa.connection.channel.forward-worker.forwarded-tcpip","log_level":1,"data":{"bound-port":36459,"remote":"127.0.0.1:42098","session":"1.1.1"}}
{"timestamp":"1523622121.368850470","source":"tsa","message":"tsa.connection.tcpip-forward.forwarding-tcpip","log_level":1,"data":{"remote":"127.0.0.1:42098","requested-bind-addr":"0.0.0.0:7788","session":"1.3"}}
{"timestamp":"1523622121.369001627","source":"tsa","message":"tsa.connection.channel.forward-worker.forwarded-tcpip","log_level":1,"data":{"bound-port":45397,"remote":"127.0.0.1:42098","session":"1.1.1"}}
{"timestamp":"1523622121.369395971","source":"tsa","message":"tsa.connection.channel.forward-worker.register.start","log_level":1,"data":{"remote":"127.0.0.1:42098","session":"1.1.1.5","worker-address":"127.0.0.1:36459","worker-platform":"linux","worker-tags":""}}
{"timestamp":"1523622121.373899698","source":"tsa","message":"tsa.connection.channel.forward-worker.register.done","log_level":1,"data":{"remote":"127.0.0.1:42098","session":"1.1.1.5","worker-address":"127.0.0.1:36459","worker-platform":"linux","worker-tags":""}}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x59a547]
goroutine 152 [running]:
crypto/rsa.SignPKCS1v15(0x1306dc60, 0xc420098270, 0x0, 0x5, 0xc42021dea0, 0x20, 0x20, 0x1, 0xc4206bfa90, 0x50, ...)
/usr/local/go/src/crypto/rsa/pkcs1v15.go:235 +0x77
github.com/dgrijalva/jwt-go.(*SigningMethodRSA).Sign(0xc420112c20, 0xc4206bfa90, 0x50, 0x19b4e60, 0x0, 0xc42052db60, 0x1b87244, 0x3, 0xc420a32f38)
/tmp/build/9674af12/concourse/src/github.com/dgrijalva/jwt-go/rsa.go:95 +0x160
github.com/dgrijalva/jwt-go.(*Token).SignedString(0xc4209ad950, 0x19b4e60, 0x0, 0xc42052db30, 0xc4209ad950, 0x3472dc7cd6e, 0x13e98f40)
/tmp/build/9674af12/concourse/src/github.com/dgrijalva/jwt-go/token.go:55 +0x90
github.com/concourse/tsa.(*tokenGenerator).GenerateSystemToken(0xc42000e718, 0x1b9752b, 0xe, 0x0, 0x1306d3e0)
/tmp/build/9674af12/concourse/src/github.com/concourse/tsa/token_generator.go:31 +0x1fb
github.com/concourse/tsa.(*heartbeater).register(0xc4209bb200, 0x130a3000, 0xc420a070e0, 0x0)
/tmp/build/9674af12/concourse/src/github.com/concourse/tsa/heartbeater.go:138 +0x665
github.com/concourse/tsa.(*heartbeater).Run(0xc4209bb200, 0xc42096be00, 0xc42096be60, 0x48000001c0850348, 0x9d0348d33148cb31)
/tmp/build/9674af12/concourse/src/github.com/concourse/tsa/heartbeater.go:75 +0x96
github.com/tedsuo/ifrit.(*process).run(0xc4203ba780)
/tmp/build/9674af12/concourse/src/github.com/tedsuo/ifrit/process.go:71 +0x45
created by github.com/tedsuo/ifrit.Background
/tmp/build/9674af12/concourse/src/github.com/tedsuo/ifrit/process.go:49 +0x107
If the additional parameter:
--session-signing-key /home/concourse/keys/session_signing_key
is provided the ATC runs as expected
Analysis
I believe this is a bug, because the --session-signing-key is not marked as a required option and the function loadOrGenerateSigningKey in atccmd/command.go is supposed to generate a key pair in case the user did not provide any.
I don't see any error indicating that the automatic session key generation failed.
The executable is started as user 'concourse' and the key directory has the following files in it:
$ ls /home/concourse/keys/ -alh
total 32K
drwx------ 2 concourse concourse 4.0K Apr 13 13:40 .
drwxr-xr-x 5 concourse concourse 4.0K Apr 13 14:37 ..
lrwxrwxrwx 1 concourse concourse 35 Apr 13 13:40 authorized_worker_keys -> /home/concourse/keys/worker_key.pub
-rw------- 1 concourse concourse 1.7K Apr 13 13:40 session_signing_key
-rw-r--r-- 1 concourse concourse 408 Apr 13 13:40 session_signing_key.pub
-rw------- 1 concourse concourse 1.7K Apr 13 13:40 tsa_host_key
-rw-r--r-- 1 concourse concourse 408 Apr 13 13:40 tsa_host_key.pub
-rw------- 1 concourse concourse 1.7K Apr 13 13:40 worker_key
-rw-r--r-- 1 concourse concourse 408 Apr 13 13:47 worker_key.pub
The following can also be handy:
- Concourse version: 3.10.0
- Deployment type (BOSH/Docker/binary): binary
Activity
If a session signing key is generated, store it in the command
vito commentedon May 24, 2018
This should be fixed by vmware-archive/bin#43
wagdav commentedon Jul 5, 2018
Thanks for fixing this!