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

runtime: nash look for paths is unsafe #178

Open
i4ki opened this issue Feb 21, 2017 · 3 comments
Open

runtime: nash look for paths is unsafe #178

i4ki opened this issue Feb 21, 2017 · 3 comments

Comments

@i4ki
Copy link
Collaborator

i4ki commented Feb 21, 2017

Nash is using os/exec.LookPath of Go to look for paths of commands, but this implementation interprets "" (empty path) as "." in the variable $PATH and this could lead to unexpected behaviours and/or malicious code execution.

Better to create our own LookPath implementation being explicit about path names (ignoring empty paths on it).

@i4ki i4ki added the bug label Feb 21, 2017
@katcipis
Copy link
Member

Would it not be easier to just remove any "" before calling LookPath ? I agree with removing this oddity x_x

@i4ki
Copy link
Collaborator Author

i4ki commented Feb 21, 2017

There's more oddities that I just found... The LookPath implementation for windows uses the "." implicitly also (but there's no way to avoid in this case). This is weird and make nash works differently across operating systems.
When I saw os/exec.LookPath in godoc for the first time I thought it had the same semantics in all OS.. but no.

https://github.com/golang/go/blob/master/src/os/exec/lp_windows.go#L83
https://golang.org/pkg/os/exec/#LookPath

@katcipis
Copy link
Member

@tiago4orion well, given these last facts I agree with not using LookPath 👍

@i4ki i4ki removed the bug label Mar 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants