-
Notifications
You must be signed in to change notification settings - Fork 251
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
Security: Move $GOPATH/bin to end of $PATH #99
Comments
stevegt
added a commit
to stevegt/goenv
that referenced
this issue
Oct 8, 2019
stevegt
added a commit
to stevegt/goenv
that referenced
this issue
Oct 8, 2019
Closed
|
I just noticed that myself recently, and I'm wondering if that's a recent change or if I somehow missed it when writing #100. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This one's related to the INSTALL.md refactoring in #98, but I'm entering it as a separate issue because it's a pretty bad security vulnerability that probably needs to be dealt with sooner.
We ought to be telling users to put $GOPATH/bin at the end of $PATH, not the beginning. Right now, in text inherited from the
pyenv
INSTALL.md, we're telling users to put $GOPATH/bin at the beginning. By doing that, we're potentially allowing anyone with a github ID to silently supersede any standard UNIX/Linux utility on machines using goenv.In my case, I recently installed an innocent package, and noticed a while later that
goenv init -
was failing. After a very confusing afternoon of troubleshooting, I finally realized, with some disbelief, that thissort
at the bottom ofgoenv-commands
was returning empty stdout regardless of stdin: https://github.com/syndbg/goenv/blob/256f7c85e56dde3ee64aa268737bc07f1484ac1f/libexec/goenv-commands#L44 It turned out that the package I'd earlier installed had dropped a binary namedsort
into $GOPATH/bin. The whole saga is described in gory detail over in emirpasic/gods#123. Thankfully, @emirpasic responded quickly and accepted my pull request, but many packages aren't going to be that well-maintained.In retrospect, this vulnerability is pretty obvious, but it didn't hit me until now just what Go's decentralized package distribution means when coupled with the way
go get
silently adds things to your $PATH. A malicious package could do quite a lot of damage and/or go undetected for a long time.For reference, the Go docs have $GOPATH/bin at the end of $PATH: https://tip.golang.org/doc/code.html#GOPATH
The text was updated successfully, but these errors were encountered: