Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rekey panic with pgp-keys defined but not set #7485

Closed
Xianic opened this issue Sep 17, 2019 · 3 comments
Closed

rekey panic with pgp-keys defined but not set #7485

Xianic opened this issue Sep 17, 2019 · 3 comments
Labels
bug Used to indicate a potential bug good-first-issue

Comments

@Xianic
Copy link

Xianic commented Sep 17, 2019

Describe the bug
index out of range when rekeying with zero keys

To Reproduce
Steps to reproduce the behavior:

  1. Run a single instance of vault locally with a file backend
  2. Run initialize the vault with vault operator init -key-threshold=1 -key-shares=1
  3. Unseal the vault as normal
  4. Run vault operator rekey -init -key-threshold=2 -key-shares=0 -pgp-keys=
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/hashicorp/vault/helper/pgpkeys.ReadPGPFile(0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/gopath/src/github.com/hashicorp/vault/helper/pgpkeys/flag.go:100 +0x83a
github.com/hashicorp/vault/helper/pgpkeys.ParsePGPKeys(0xc00050f000, 0x1, 0x1, 0x1, 0xc00050f000, 0x1, 0x1, 0x0)
	/gopath/src/github.com/hashicorp/vault/helper/pgpkeys/flag.go:88 +0x357
github.com/hashicorp/vault/helper/pgpkeys.(*PubKeyFilesFlag).Set(0xc0005a0130, 0x7ffcbc678208, 0x0, 0x0, 0x0)
	/gopath/src/github.com/hashicorp/vault/helper/pgpkeys/flag.go:54 +0xd5
flag.(*FlagSet).parseOne(0xc0002af860, 0x1, 0x0, 0x0)
	/goroot/src/flag/flag.go:906 +0x37b
flag.(*FlagSet).Parse(0xc0002af860, 0xc0000b4030, 0x4, 0x4, 0x2effdc0, 0x2c60aa0)
	/goroot/src/flag/flag.go:925 +0x62
github.com/hashicorp/vault/command.(*FlagSets).Parse(0xc000495ec0, 0xc0000b4030, 0x4, 0x4, 0xc0000bc001, 0xc00067dcd0)
	/gopath/src/github.com/hashicorp/vault/command/base.go:432 +0x4d
github.com/hashicorp/vault/command.(*OperatorRekeyCommand).Run(0xc0005a0100, 0xc0000b4030, 0x4, 0x4, 0xc0001e2d00)
	/gopath/src/github.com/hashicorp/vault/command/operator_rekey.go:226 +0x63
github.com/hashicorp/vault/vendor/github.com/mitchellh/cli.(*CLI).Run(0xc000279400, 0xc000279400, 0xc0000bc3c0, 0xc0000bc0c0)
	/gopath/src/github.com/hashicorp/vault/vendor/github.com/mitchellh/cli/cli.go:255 +0x207
github.com/hashicorp/vault/command.RunCustom(0xc0000b4010, 0x6, 0x6, 0xc000274410, 0x0)
	/gopath/src/github.com/hashicorp/vault/command/main.go:177 +0x5e4
github.com/hashicorp/vault/command.Run(0xc0000b4010, 0x6, 0x6, 0xc0000a0058)
	/gopath/src/github.com/hashicorp/vault/command/main.go:87 +0x48
main.main()
	/gopath/src/github.com/hashicorp/vault/main.go:10 +0x62

Expected behavior
An error explaining that -key-shares=0 makes no sense

Environment:

  • Vault Server Version (retrieve with vault status): 1.1.3
  • Vault CLI Version (retrieve with vault version): Vault v1.1.3 ('9bc820f700f83a7c4bcab54c5323735a581b34eb')
  • Server Operating System/Architecture: Ubuntu 19.04

Vault server configuration file(s):

ui = true

backend "file" {
  path = "store"
}

listener "tcp" {
  tls_disable = 1
}
@chrishoffman chrishoffman added this to the 1.3 milestone Sep 17, 2019
@chrishoffman chrishoffman added bug Used to indicate a potential bug good-first-issue labels Sep 17, 2019
@jefferai
Copy link
Member

It's actually not key-shares=0 that is the problem, it's the empty list at the end of pgp-keys.

@jefferai jefferai changed the title rekey panic with -key-shares=0 rekey panic with pgp-keys defined but not set Sep 18, 2019
@aivinog1
Copy link

@chrishoffman Hello, can I take this issue? I'm new in Go, but this issue is pretty clear for me.

aivinog1 added a commit to aivinog1/vault that referenced this issue Sep 27, 2019
@jefferai jefferai modified the milestones: 1.3, 1.2.4 Sep 27, 2019
gedigi added a commit to gedigi/vault that referenced this issue Oct 2, 2019
chrishoffman pushed a commit that referenced this issue Oct 9, 2019
@chrishoffman
Copy link
Contributor

Fixed by #7526

chrishoffman pushed a commit that referenced this issue Oct 9, 2019
chrishoffman added a commit that referenced this issue Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to indicate a potential bug good-first-issue
Projects
None yet
Development

No branches or pull requests

4 participants