-
Notifications
You must be signed in to change notification settings - Fork 16
Powershell command injection updates #278
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! One comment, but that's not blocking!
class CmdletBindingParam extends CriticalSource { | ||
CmdletBindingParam(){ | ||
exists(Attribute a, Function f | | ||
a.getName() = "CmdletBinding" and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably to case insensitive matching since I'm sure PowerShell happily accepts cMdlEtBinDinG
. But I'll fix that in another since we don't have an API for this on Attribute
yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed this here.
exists(Function f, Attribute a, Parameter p | | ||
p = f.getAParameter() and | ||
p.getAnAttribute() = a and | ||
a.getName() = ["ValidateScript", "ValidateSet", "ValidatePattern"] and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again: I'll do another PR to make this case insensitive. Thanks for adding this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here.
@@ -34,12 +34,19 @@ module CommandInjection { | |||
class FlowSourceAsSource extends Source { | |||
FlowSourceAsSource() { | |||
this instanceof SourceNode and | |||
not this instanceof EnvironmentVariableSource | |||
not this instanceof EnvironmentVariableSource and | |||
not this instanceof InvokeWebRequest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we only remove it when it's given a constant string literal as a source? Or do you think it's better to totally remove it like you're doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think totally remove it. It could be a case if there's flow from user input -> InvokeWebRequest -> command call, but that's more of an SSRF vuln first, which we can model as a separate query
Couple of changes in this one suggested by @ewilloner