r/PowerShell • • Aug 20 '26

Information PSA: Never use a wildcard in an install-module command.

Mean and nasty people are filling the repository with almost-right spelling of the real modules.

Just check the output of this command: Find-Module Microsoft.Graph.auth*

There are currently 1 real one and 25 malicious ones

115 Upvotes

50 comments sorted by

89

u/dodexahedron Aug 20 '26

It's wild that MS doesn't at least protect names starting with stuff like...oh...I don't know.... Microsoft.Graph, even just for trademark purposes, let alone name squatters.

11

u/Fallingdamage Aug 21 '26

Ive had a habit lately of checking the PS Gallery website first for a module to see who the publisher is..

16

u/dodexahedron Aug 21 '26

Just pipe the result of the find-module to fl *. Everything visible on the website is there, and more.

Find-Module SomeTotallySusModule | Format-List *

And if there is a project site or repo for the package, the links will be clickable in the terminal anyway, for your deeper investigation needs.

9

u/420GB Aug 21 '26

Microsoft has already solved that, you're supposed to download their first-party modules from their Microsoft Artifact Registry and not the PowerShell Gallery community repository: https://learn.microsoft.com/en-us/powershell/gallery/powershellget/supported-repositories?view=powershellget-3.x#microsoft-artifact-registry-mar

15

u/dodexahedron Aug 21 '26 edited Aug 21 '26

Yes. Sorta. In a very Microsoft way...

"Solved" is doing heavy lifting there, as that is not only a preview, but also not part of 99.9% of existing production powershell (any edition, any platform) installs, and is not registered by default (yet), unless you have manually installed the psresourceget 1.3.0-preview1 or later prerelease module. You can use it with earlier versions, but it isn't registered by default until that one.

There are TONS of systems out there that will likely never see that version of the module, as even the current LTS powershell (7.6) shipped with 1.1, including 7.6.5.

And they have done an awful job of getting the word out, on top of that, to help users of older versions at LEAST register the new repo.

Besides...
It shouldn't have taken a completely separate distribition point to enforce at LEAST their own name prefix reservation as a bare minimum measure. They already have trademark law on their side for that. Why not just prohibit people from publishing tjings starting with Microsoft. to at least pretend to care? It's straight-up negligent.

And, with both registered, names existing in psgallery but not MAR will still show up and be installable if you don't explicitly distrust psgallery. Which most people probably won't because of useful modules there. What you are offered is the union of all sources, with priority used to pick the winner for name collisions.

5

u/MadBoyEvo Aug 21 '26

We could just move psgallery to nuget.org and it would solve a lot of problems and give us features we need. They already have things like name protection so MS packages could be protected.

1

u/dodexahedron Aug 21 '26

Totally.

Though it's not like adding those capabilities to PSGallery should be much more than an afternoon of work in terms of dev time, testing, staging, and possibly even limited A/B testing in production, considering how trivial and common those functions are. It would take more time to decide which specific enhancements to make, honestly. No reason it cant be designed, reviewed, approved, developed, tested, and implemented in a week, even for a software giant.

PSGallery is already a nuget feed, so the index and API don't even need changing. They just need to bolt on even rudimentary rule enforcement, and ideally a couple more search filters, too, while they're at it (like publisher), which is also trivial.

Give the work to a summer intern or something. Even a naive implementation of any of that would be sufficient and better than the status quo.

😩😩😩

1

u/BlackV Aug 23 '26

psgallery is legacy legacy code they are actively building its replacement/planning its move

1

u/dodexahedron Aug 29 '26

MAR is also targeted at containers. It isn't meant to be a generic replacement (yet), and doesnt even have much in it anyway, despite existing for quite a while at this point.

1

u/BlackV Aug 29 '26

Yeah it'll be a while

26

u/PDQ_Brockstar Aug 20 '26

Great PSA. Looks like all the malicious modules were last updated 8/16.

It might be a loosing battle, but I'd like to think that reporting them on PSGallery's site is useful.

8

u/Thotaz Aug 20 '26

Whenever I install modules it's always a two step process, first I run Find-Module *XYZ*, then I copy the exact name and run Install-Module <Ctrl+V>. I hope I'd be aware enough to question all the similar looking modules, and that I don't make a typo in the original search.

1

u/BlackV Aug 20 '26

same but find/install-psresource

0

u/charleswj Aug 21 '26

I was today (well, actually a couple months ago) days old when I learned that even existed

2

u/BlackV Aug 21 '26

it will eventually replace install-module, etc, but I don't imagine its any time soon

right now it a tiny amount faster to download so I'm happy with that

1

u/MonkeyNin Aug 21 '26

2

u/BlackV Aug 21 '26

I found that suffered the same issue with module dependency where the dependent modules would be repeated several times, so it didn't save me much

It's been a while though

15

u/JSChronicles Aug 20 '26

Yeah this has been a known thing forever for pretty much any language.. you always explicitly install via the full name.

That still doesn't stop people from package takeovers though which is a whole other problem. Check out npm for fun stuff

4

u/RikiWardOG Aug 21 '26

Dude npm has been a shitshow

5

u/dodexahedron Aug 21 '26

npm: Nefarious Package Monger

7

u/I_see_farts Aug 20 '26

Interesting, all those are posted by the same person on 8/16/26.

I'm looking at the code for one now... yikes!

The GitHub repo that it downloaded from has been deleted. Got the ol' 404 error.

4

u/Secret_Account07 Aug 21 '26

Save me a few clicks, friend. What did the code do?

I think we all have a general idea, but just curious.

13

u/I_see_farts Aug 21 '26
  • Created a new runspace
  • Checked if it was Mac, Linux, Windows or WSL
  • Uploads something to a French IP address
  • Obfuscated GitHub repo behind a numerical -bxor array
  • Downloaded main.exe then ran it in a hidden window

I couldn't download whatever it was and upload to Virustotal because the GitHub was taken down.

3

u/BlackV Aug 21 '26

nice work

2

u/I_see_farts Aug 21 '26 edited Aug 21 '26

Is there any legitimate use for a -bxor on a numerical array?

I've only seen it used to obfuscate web addresses in sketchy code.

Edit: Thanks!

4

u/BlackV Aug 21 '26

I mean I guess there could be a legitimate reason for it.....

I can't say Ive ever seen one

1

u/dodexahedron Aug 21 '26

Any time I have a legitimate need for bitwise ops that goes beyond like 1 or 2 isolated flag/enum manipulations, I either rethink what I'm doing to eliminate that need or do that part (or quite often the whole cmdlet) in c#.

I truly loathe the PowerShell syntax for that.

1

u/BlackV Aug 21 '26

Deffo valid

1

u/Mr_ToDo Aug 21 '26

Right up there with mshta

It can be used for good, but it favours use by evil

Out of curioucity since google results for it are always flooded with malware troubleshooting, I tried instead to look for .hta's on my pc. Seems that the Think BIOS Configurator is made in that... interesting

1

u/BlackV Aug 21 '26

Ouch, it's always the OEMs that hang on to it, always

6

u/Cadder Aug 21 '26

Silly as it may sound, I've never even assumed this was possible, let alone desirable. Install modules specifically by name. 🤷‍♂️

3

u/800oz_gorilla Aug 21 '26

they are typo squatting. it's not "just install them by name" but make extra certain you typed it right.

1

u/Cadder Aug 22 '26

Obviously. get- , cut & paste > retype

1

u/800oz_gorilla Aug 22 '26

it's obvious to you but if you have other people on your team, it may not be obvious to them that's why I was calling it out.

hope he's post is a great reminder to bring them up and make sure people havent installed a malicious mod by accident

2

u/TipIll3652 Aug 22 '26

Lol yeah I didn't think you could even use wildcards for this. I guess it's one of those things I just have never thought about.

3

u/800oz_gorilla Aug 21 '26

this is a great PSA, but to tack on: they are clearly typo squatting. installing it manually by full name only works if you aren't so rushed you fat finger it.

1

u/Mr_ToDo Aug 21 '26

works if you aren't so rushed you fat finger it.

As can happen to anyone if typing things out by hand

1

u/800oz_gorilla Aug 21 '26

right, just mentioning it because I have a few admins who make regular typos.

3

u/purplemonkeymad Aug 21 '26

Huh interesting, apparently the PSResourceGet module has different results for that wildcard search:

PS > Microsoft.PowerShell.PSResourceGet\Find-PSResource Microsoft.Graph.auth*

Name                           Version Prerelease Repository Description
----                           ------- ---------- ---------- -----------
Microsoft.Graph.Authentication 2.39.0             PSGallery  Microsoft Graph PowerShell Authentication Module.

PS > PowerShellGet\Find-PSResource Microsoft.Graph.auth*

Name                           Version  Prerelease Repository Description
----                           -------  ---------- ---------- -----------
Microsoft.Graph.Authentication 2.39.0.0            PSGallery  Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authenication  1.0.0.0             PSGallery  Small helpers
Microsoft.Graph.Authentiation  1.0.0.0             PSGallery  Practical module
Microsoft.Graph.Authenticaiton 1.0.0.0             PSGallery  Portable toolkit
Microsoft.Graph.Authenticatiom 1.0.0.0             PSGallery  Modern tools
Microsoft.Graph.Authenticaton  1.0.0.0             PSGallery  Lightweight automation helpers
Microsoft.Graph.Authentiction  1.0.0.0             PSGallery  Small automation helpers
Microsoft.Graph.Authetication  1.0.0.0             PSGallery  Useful extensions
Microsoft.Graph.Authebtication 1.0.0.0             PSGallery  Smart extensions
Microsoft.Graph.Authemtication 1.0.0.0             PSGallery  Lightweight toolkit
Microsoft.Graph.Authenrication 1.0.0.0             PSGallery  Quick tools
Microsoft.Graph.Authenyication 1.0.0.0             PSGallery  Modern runtime utils
Microsoft.Graph.Authentucation 1.0.0.0             PSGallery  Reliable framework helpers
Microsoft.Graph.Authentocation 1.0.0.0             PSGallery  Useful system utilities
Microsoft.Graph.Authentixation 1.0.0.0             PSGallery  Clean utilities
Microsoft.Graph.Authentivation 1.0.0.0             PSGallery  Handy automation helpers
Microsoft.Graph.Authenticstion 1.0.0.0             PSGallery  Lightweight utilities
Microsoft.Graph.Authenticarion 1.0.0.0             PSGallery  Smart automation helpers
Microsoft.Graph.Authenticayion 1.0.0.0             PSGallery  Compact core helpers
Microsoft.Graph.Authenticatuon 1.0.0.0             PSGallery  Small framework helpers
Microsoft.Graph.Authenticatoon 1.0.0.0             PSGallery  Smart toolkit
Microsoft.Graph.Authenticatiin 1.0.0.0             PSGallery  Quick system utilities
Microsoft.Graph.Authenticatipn 1.0.0.0             PSGallery  Practical automation helpers
Microsoft.Graph.Authenticatiob 1.0.0.0             PSGallery  Modern runtime utils
Microsoft.Graph.Authwntication 1.0.0.0             PSGallery  Efficient tools
Microsoft.Graph.Authrntication 1.0.0.0             PSGallery  Handy core helpers

3

u/SolidKnight Aug 21 '26

Install-Module * -Force -Scope AllUsers

1

u/BlackV Aug 21 '26

Ha safe as houses

1

u/evolutionxtinct Aug 21 '26

Good to know! I think we sometimes take this for granted

1

u/NFX_7331 Aug 23 '26

Damn thought PSG was official enough that they would check what gets uploaded, atleast to some degree but this is pretty bananas.

And why would they not copy the current version and descpription that the legit one got, seems stupid.

0

u/BlackV Aug 20 '26 edited Aug 21 '26

LAWL, great idea by the hackers

yet another reason MS will be moving their modules to ACR (soontm )

people need to stop using install-Module Microsoft.Graph (so you don't get 1 million modules) and install specific scoped modules, don't be lazy

validate your input, validate your sources, be explicit in your installs, security 101

this applies to npm, winget, chocolaty, psgallery, and the million other repos out there

Edit: come on, be honest it's a well documented and "solved" problem with module pinning (name/fqdn/version)

0

u/panzerbjrn Aug 21 '26

This would be fine if the error message when you do something you're not scoped for told you what scope you needed, and offered to activate it for you.

1

u/BlackV Aug 21 '26

panzerbjrn
This would be fine if the error message when you do something you're not scoped for told you what scope you needed, and offered to activate it for you.

Er... I'm not sure what you mean? What your are not scoped for? And auto activate?

if you use (for example) connect-mggraph it tells you the command is not available, you'd could then use find-command to find modules that matched that command, you could then check those models for the right one

If you already have the modules the get-command would return where the command is located

But I'm not 100% sure that is what you're asking

-1

u/panzerbjrn Aug 22 '26

And that is why your response is just dumb.

2

u/BlackV Aug 22 '26 edited Aug 22 '26

panzerbjrn
And that is why your response is just dumb.

Please explain why

and what you mean by your are not scoped for? And auto activate?

-4

u/xueimelb Aug 20 '26

You mean I should be precise in the software I install? Never would have crossed my mind. /s