X Tutup
The Wayback Machine - https://web.archive.org/web/20240828180904/https://github.com/PowerShell/PowerShell/issues/24164
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

AMSI buffer normalization #24164

Open
random-npc-glitch opened this issue Aug 15, 2024 · 1 comment
Open

AMSI buffer normalization #24164

random-npc-glitch opened this issue Aug 15, 2024 · 1 comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group. WG-Security security related areas such as JEA

Comments

@random-npc-glitch
Copy link

random-npc-glitch commented Aug 15, 2024

Summary of the new feature / enhancement

I have noticed that AMSI scan buffers can contain escape characters and that aliases are not resolved to the base cmdlet name. Both of these are problematic for signature writers and seem best addressed from within the powershell code base itself.

Examples:

   logman start AMSITrace -p Microsoft-Antimalware-Scan-Interface Event1 -o AMSITrace.etl -ets
   powershell -c get-pro`cess
   powershell -c get-pro''cess
   powershell -c g`et-pro""cess
   powershell -c p`s
   powershell -c gp`s
   powershell -c "(('67 65 74 2D 70 72 6F 60 63 65 73' -split ' ' |ForEach-Object {[char][byte]\"0x$_\"}) -join '')+[char]0x73  | iex"
   logman stop AMSITrace -ets

Then run Get-AmsiEvent on the AMSITrace.etl output file
(https://gist.github.com/mgraeber-rc/1eb42d3ec9c2f677e70bb14c3b7b5c9c)

Content         : get-pro`cess
Content         : gp`s
 
(same for pwsh.exe)
pwsh -c gp`s
AppName         : PowerShell_C:\Program Files\PowerShell\7\pwsh.exe_7.4.4
Content         : gp`s

Vendor specific signature languages working on the content buffers can not know arbitrary aliases, implement full syntax parsers, or keep up with new language features.

Once a script is fully parsed and held as AST is there any framework to reconstruct the normalized source from that? Seems that could strip alias and escape char complexities.

Proposed technical implementation details (optional)

No response

@random-npc-glitch random-npc-glitch added Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group. labels Aug 15, 2024
@rhubarb-geek-nz
Copy link

rhubarb-geek-nz commented Aug 15, 2024

Quis custodiet ipsos custodes?

Should you also expand variable values, wildcards and symbolic links?

Let me know when AMSI integration is optional like script signature validation, ssl certificate validation and passwords over clear text http.

@iSazonov iSazonov added the WG-Security security related areas such as JEA label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group. WG-Security security related areas such as JEA
Projects
None yet
Development

No branches or pull requests

3 participants
X Tutup