Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

detect when external command running is vulnerable to option injection #15

Open
pabs3 opened this issue Aug 20, 2021 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@pabs3
Copy link

pabs3 commented Aug 20, 2021

I noticed that gokart supports checking for command injection. Another related thing is when injecting command-line parameters allows you to inject parameters that get interpreted as options. Some options change the behaviour of commands in suboptimal ways, but some options to some commands can result in arbitrary code execution. The canonical paper about this type of attack is Back To The Future: Unix Wildcards Gone Wild by Leon Juranic of DefenseCode. It would be great if gokart could support detecting option injection.

@dickyford dickyford added the enhancement New feature or request label Aug 21, 2021
@isp1r0
Copy link
Contributor

isp1r0 commented Aug 24, 2021

@pabs3 Many thanks for the suggestion and link! We're definitely interested adding more capabilities to our analyzers, especially ones that are suggested by the community. We started diving into some examples from https://gtfobins.github.io/#+shell and realized this would be better sourced from within the community.

Our intuition is that Option Injection will be prevalent when devs have a need to shell out and most likely occur where Go standard libraries have limited functionality as compared to standard cmd utilities, such as using find() to search within directories rather than using the path module.

Do you have any suggestions for these cases in Go where this anti-pattern is commonly found? Code examples would favored but any pointers, hints or links appreciated as well :)

@pabs3
Copy link
Author

pabs3 commented Aug 26, 2021 via email

@isp1r0
Copy link
Contributor

isp1r0 commented Aug 30, 2021

Hey @pabs3 - thanks for the details here! It's a super interesting thread and love that you've continued to pursue this capability.

After some further investigation, I believe we can add a check for this once we've gotten a more flexible (and accurate) way of identifying Sinks with respect to the parameters being passed in.

Currently we're identifying all function parameters to a given vulnerable function as tainted when we really want to perform specific checks, i.e. second parameter to a exec.Command should only be treated as tainted if the first has a parameter with something like "-sh". In a similar fashion, we could look for an "rsync" or other option-injectable command and IFF we see that as the first parameter would be look for user-controllable data going to a subsequent parameter...

BTW: we released a new version of GOKart last Friday with remote repo scanning and some output options. I've found it pretty sweet for scanning repos in a nice frictionless fashion. Check it out if you get a chance!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants