`proxycfg.State.Watch` not protected against multiple invocations
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
https://github.com/hashicorp/consul/blob/20eefeea117dcd23e30dab942acd2cf007024d9e/agent/proxycfg/state.go#L93-L109
This overwrites the current ctx and cancel function, executes the `run` method in a go routine and returns a chan.
The problem is that if Watch is called multiple times we could:
1. Lose the current ctx/cancel and potentially leak some go routines
2. Completely break everything related to this `proxycfg.State`. They will be sharing some internal chans so it would be possible for neither instance of the go routine running to get a complete view of the proxy configuration and never think its configuration is valid.
At this point this is all purely theoretical but we may want to prevent this in the future.
Contributor guide
Assessment
This issue has not been assessed yet.