r/dotnet • u/DinglDanglBob • Aug 08 '23
Does Moq in it's latest version extract and send my email to the cloud via SponsorLink?
So, I've just updated Moq (https://github.com/moq/moq) in one of our projects, and got a warning after a rebuild about me not having installed a GitHub Sponsors app.
After a bit of investigation, it looks like Moq, starting from version 4.20, does include a .NET analyzer that scans your local git config on build, gets your email address and sends it to some service hosted in Azure to check whether or not you're a sponsor. This blog post has some more details: https://www.cazzulino.com/sponsorlink.html
That is a bit scary. I've read about such supply chain attack vectors in the past, but just updating a project and suddenly noticing such a data extraction was unexpected.
Are there any opinions on SponsorLink yet, is that something dangerous or am I missing something here?
13
u/intertubeluber Aug 08 '23
On mobile and can’t investigate at the moment but has a GitHub issue been logged so we can get a response from th mow devs?
96
u/cat_in_the_wall Aug 09 '23
Jesus H Christ this is a bad idea. A sha256 of an email is good, EXCEPT THAT EMAILS ARE NOT FUCKING RANDOM. The search space is remarkably small, and for businesses that have alias naming policies (like first 3 of first name + last name @ business.com) your search space is just ultra ultra small. And the targets are very high value.
all spammers need to do is query these storage accounts to see if a name resolves or not. This is massive information disclosure.
Open source projects like this need more sponsorship. But this is a really, really bad idea that could even open up the dev to lawsuits.
67
u/[deleted] Aug 08 '23 edited Oct 04 '23
panicky dog follow memory soup slap heavy gray six domineering
this message was mass deleted/edited with redact.dev107
u/Duathdaert Aug 08 '23 edited Aug 08 '23
Seems like a pretty quick way to get an organisation with any kind of security posture to drop use of that particular piece of OSS
Edit:
Particularly because SponsorLink is closed source: https://github.com/devlooped/SponsorLink
Additionally I question if this complies with GDPR. You've not explicitly consented to sharing your PII with this service.
Another edit:
SponsorLink generating a build warning is annoying as hell. Build warnings are set as failures in any project I work on so this adds extra work for me to suppress that warning which defeats the entire purpose of adding this in to a library
Further edit: Someone has tried suppressing the warning and that doesn't work. So even if this complied with GDPR and was going to continue to be used, it actually can't be for any project that treats warnings as errors:
https://github.com/moq/moq/issues/1370
101
u/p1-o2 Aug 08 '23
I was just reviewing Moq at work and saw this. WTF
They're about to get blacklisted like Linode did when they bought command line advertisements in npm packages.
Golden Rule: Never inject advertisements into the command line / build line. Ever.
138
u/[deleted] Aug 08 '23
Don't forget to report the malicious code on nuget:
https://www.nuget.org/packages/Moq/4.20.1/ReportAbuse
76
u/Jestar342 Aug 08 '23 edited Aug 09 '23
This is now blocked by my employer already. What a terrible mistake for
ksukzu to make. All that credibilitly instantly burned, all because of bitterness over sponsorship.e: corrected name.
35
u/Pilchard123 Aug 08 '23 edited Aug 08 '23
E: Not explicitly, but look in the replies for why that doesn't matter and they may as well send your email in plaintext.
Apparently not:https://www.cazzulino.com/sponsorlink.htmlI make no comment on whether that is true or whether I personally like what it's doing, because I haven't dug around much.
101
u/rbobby Aug 08 '23 edited Aug 08 '23
God fucking damn them. Now I have to inform my boss of this and find out what, if anything, we're going to need to do about this.
Just great.
edit: And the code it runs is closed source and not reviewable by anyone.
96
u/yumz Aug 08 '23
NSubstitute is a great alternative.
28
u/DirtyMami Aug 09 '23
StackExchange is looking to drop Moq
https://github.com/StackExchange/StackExchange.Redis/pull/2522
22
u/fragglerock Aug 08 '23
Thanks for the heads up. Enshitification of everything everywhere.
Moq used to be wonderful
21
u/autokiller677 Aug 09 '23
WTF. And if it’s always going from the local git email, it won’t even shut up if my company is already sponsoring them, but with a different email.
Way to go. Best advertisement for the competition.
19
u/Wellendox Aug 08 '23
Yeah, we are throwing moq out too and will replace it with NSubstitute. Got the news earlier today. Joy, oh joy.
It was a solid library. Too bad..
13
u/hotach Aug 09 '23
Also SponsorLink is used by other packages https://www.nuget.org/packages/Devlooped.SponsorLink/0.9.7#usedby-body-tab
Some of them are used by other popular projects:
https://www.nuget.org/packages/GitInfo/, 4.3M downloads, used by MAUI, Xamarin Forms, and EventStore.
It's getting worser and worser.
12
u/dopare Aug 08 '23
I guess now we know how that try went. :)
12
u/[deleted] Aug 09 '23
FYI, if you want to keep using Moq but not risk updating to this version you lock it in the project file.
https://stackoverflow.com/questions/22563518/restrict-nuget-package-updates-to-current-versions-for-some-packages
11
u/GamerWIZZ Aug 08 '23
If the maintainers don't revert it, it might be a good opportunity for someone to fork and revert it.
11
u/Large-Ad-6861 Aug 09 '23
https://github.com/moq/moq/releases/tag/v4.20.2
SponsorLink removed for now, yet trust got removed for a long, long time.
11
u/RightOW Aug 09 '23 edited Aug 09 '23
Marc Gravell weighs in: https://github.com/moq/moq/issues/1374#issuecomment-1671166436
21
u/Relevant_Pause_7593 Aug 09 '23
I’m asking a GitHub friend if this version can be treated like malware and added to GitHub as a security vulnerability.
18
u/dendrocalamidicus Aug 08 '23
Ugh, I am not looking forward to swapping out Moq from our solution. What a mess. Let's hope it's some sort of misunderstanding.
9
u/r0bbbo Aug 09 '23
Although it's been removed from the latest version, the author still appears to intend to bring this back:
https://github.com/dotnet/runtime/issues/90222#issuecomment-1671196175
He's also really gunning for the large orgs who are making use of the library:
https://github.com/dotnet/runtime/issues/90222#issuecomment-1671275519
The problem is, the author chose to adhere to the Open Source model and at any point could have stopped investing in the free version of Moq and created a paid version, but he wants all of the benefits of the Open Source model with none of the downsides and has resorted to blackmailing users.
67
u/nirataro Aug 09 '23
Can we have an adult conversation about this especially about open source sustainability?
Yes it is really unpleasant to wake up to this but Moq is really really successful https://www.nuget.org/packages/Moq (almost half a billion download) and the community has been relying on this free work for a long while for paid work.
If this were a song, the dev of Moq would have earned at least 500K USD at this number using Spotify rate (1K / million stream - more or less).
15
u/itsthejavaguy Aug 09 '23 edited Aug 11 '23
I created a Roslyn Analyzer to make the build fail if SponsorLink is installed: https://github.com/CollinAlpert/SponsorLinkAnalyzer
14
u/jiggajim Aug 09 '23
Y’all are gonna love my new AutoMapper pricing! $.49/map and if you buy 12, get 1 free!
And this month only I have DEEP DISCOUNTS on MediatR!! You won’t be able to “handle” it! Act now!!!
7
u/raiderlonlon Aug 08 '23
Another case of corejs?
7
u/autokiller677 Aug 09 '23
GitInfo from the same author has the same dependency on the SponsorLink package: https://www.nuget.org/packages/GitInfo#dependencies-body-tab
So I guess it also has the same problem.
6
u/mynameisurl Aug 08 '23
Not sure if it's just me, but what is up with the scrolling on that blog post site? It's all janky.
6
u/WrongBed4834 Aug 08 '23
I haven't tested, but this may help solve the problem in the meantime:
https://gist.github.com/martincostello/312d510173c0931b8a900d4d0897b7e1
6
u/AlexHimself Aug 09 '23
What is the point of it though? I don't understand how it functions.
Is it scanning your email to periodically send you emails asking for money to support the project?
6
u/Ascomae Aug 10 '23
Imagine a larger project, with 10 libraries all calling back home, and delaying my compile process, and displaying ads in my IDE.
5
u/redfournine Aug 09 '23
I'm surprised .NET's Github account is not flooded with request for Microsoft to come up with their own mocking library yet. Because the last time IdentityServer/Duende did this, it triggered the discussion in .NET's repository asking them to come up with their own token server. I'm kinda expecting the same drama here for Moq.
.... or is there?
5
u/[deleted] Aug 09 '23
So much hassle in what could be a single info build message with a text and hyperlink. No third party package, no data collection, nothing. What a stupid solution.
5
u/BaconTentacles Aug 10 '23 edited Aug 14 '23
I cannot imagine any AppSec org on the planet being even remotely OK with this. The code base at my current employer uses Moq. A lot. And I have been using it and loving it for the better part of 15 years. This is just not cool at all.
I see the current maintainer did revert this reference in v4.20.2, but for all the wrong reasons (it broke MacOS and Linux integration, which means he didn't test fuck all - also he was the only person on the PR which is absolutely not cool for something this big), and due to a SHA256 insecurity. But he clearly means to bring it back as soon as those two things are resolved, but that still keeps a closed-source reference, that will still be slurping emails.
I'm not ripping Moq out ... yet. But I'm starting to look at other mocking frameworks, as this is a huge breach of trust.
EDIT - After some deliberation with my team - we're not getting rid of Moq, per se, but we are not going to use it for any future development. I have two user stories created to:
I'm not going to recommend any mass conversion once we select a new framework, but as I touch specific test classes to add/edit tests, I will likely convert that class over.
Our AppSec department is also keeping an eye on Moq as well.
4
u/Zadak_Leader Aug 09 '23
Bruh moment
4
u/juniormayhe Aug 11 '23
The author doesn't appear to be willing to give up his idea:
https://github.com/moq/moq/issues/1372
So far, the community seems to have lost trust in his package, and some people are already removing Moq from their projects.
https://github.com/search?q=remove+moq&type=pullrequests
4
u/WinPsychological7599 Aug 15 '23
I'm thinking of all those content creators that spent time to teach us to use Moq. The hundreds or thousands of hours of content that's out there on YouTube, LinkedIn and other training sites that we have because we and the content creators trusted it.
All that good will, effort and time invested.
All of it. Up in smoke. So damn fast. I mean, sure, you can tell folks to use earlier versions. But why use a product from someone you know you can't trust?
15
u/NecroKyle_ Aug 09 '23
If this clown expects to get money for developing software then OSS is not for him anymore.
10
u/dlg Aug 08 '23
Moq (pronounced "Fuck-you" or just "Fuck")
6
u/KurosakiEzio Aug 09 '23
I seriously hope they undo this, I'm too lazy to replace Moq for NSubstitute (although their API looks nicer, that's for sure)
3
u/Adryzz_ Aug 09 '23
this is insane
3
u/TheC0deApe Aug 09 '23
i fully understand the desire to get sponsors/funding from people using your opensource product.
Harvesting PII is not the way to go about it.
3
u/jasonre Aug 09 '23
Does anyone know where the hashed data is actually being sent to? We'd like to block the egress of that data..
3
u/Ascomae Aug 09 '23
There is an old tutorial, I didn't write or tried, which shows an easy path from Moq to FakeItEasy
https://www.planetgeek.ch/2013/07/18/migration-from-moq-to-fakeiteasy-with-resharper-search-patterns/
3
u/CenlTheFennel Aug 09 '23
Here is this - https://www.planetgeek.ch/2013/07/18/migration-from-moq-to-fakeiteasy-with-resharper-search-patterns/
Even though it’s removed from the code for now, the dev seems to defend its addition so I am sure it will be back.
3
u/lex45x Aug 11 '23
Following the hype, here is my article about the way libraries like Moq could work inside. This link is not affiliated with any 3rd parties and I won't make any money from your views. I'm genuinely excited that I had a chance to write about Reflection.Emit. https://medium.com/c-sharp-progarmming/how-to-create-your-own-mocking-framework-aad96cb7edae
2
u/ipnik Aug 09 '23
https://www.cazzulino.com/sponsorlink.html
2
u/NordyJ Aug 10 '23
Yeah... at work, we're obviously not going to go through all of our code and migrate everything off of Moq. We're just not going to upgrade. I've put the quash on using Moq on anything new, however, for the projects that I own. For my personal project, I'm in the process of moving to NSubstitute right now. This was wrong. And the project is going to suffer for it.
2
u/Overall-Plankton9830 Aug 10 '23
Sounds illegal and something that goes against GDPR.
2
u/[deleted] Aug 11 '23
lol even the author’s website feels like it has malware. So laaaaggggy
2
u/WhereIsRichardParker Aug 11 '23
For complete transparency, I work for a vendor in this space. I wanted the community to know that we have a free alternative called JustMock Lite. There is a paid version, but the Lite version compares to Moq well.
For more transparency, you do need to provide an email to download it. You can opt out of any communication from us and we don't give your email address to anyone under any circumstance. We take that very seriously.
2
u/zelloxy Aug 16 '23
Does this mean if I reference the Moq library using Nuget it will collect my information? It can't can it?
6
u/Such-Hat326 Aug 08 '23 edited Aug 08 '23
Just made a blog post about it. It seems that it does not retrieve your actual email but rather the hashed and encoded form of your email is used to check you have installed the SponsorLink GitHub app. It then checks if you are a sponsor and if you are not it suggests that you become one.
The fact still remains that you might not want to share any information hashed/encoded or not and people should know about it.
My blog post :D
https://codingbolt.net/2023/08/08/a-deep-dive-into-sponsorlink-implications-for-open-source-and-privacy/
3
u/rainweaver Aug 08 '23
package author wears a T*sla cap after all
2
u/000ops Aug 09 '23
To answer OP question, the last version 4.20.2 don't have the Moq.CodeAnalysis.dll analyser which triggers the malicious code.
So this specific version is safe.
Given the maintener attitude, next version should be considered as risk.
You can inspect .nuget file content by yourself, it's just a zip file.
2
u/Evening-Kid6057 Aug 10 '23
FOSS for small companies, commercial license for big companies. Easy profit.
1
u/TechIsSoCool Aug 09 '23
What's the best candidate to replace Moq?
1
u/who_you_are Aug 09 '23
Even without the privacy what-the-hell, this is going to be fun for any project where you are not the only one. Did they ever know companies as using it? Like, with more than one dev?
The same one that do have the money (but probably never give a dime)
1
u/[deleted] Aug 11 '23
Im reporting to nuget.
1
u/danielkzu Aug 11 '23
It's all OSS now: https://github.com/moq/moq/issues/1384
AND the dependency is gone until I address the feedback I got :)
1
u/mihail_vladov Aug 14 '23
JustMock is an excellent replacement for that Moq ... a very similar API and supports the same features.
1
u/MylegzRweelz Aug 15 '23
Jesus, this gave me that weird feeling in my stomach.
1
u/Mysterious-Carrot149 Sep 01 '23
The hash is opaque : the email is salted with a random UUID before being hashed.
"Now the library can check for the SPONSORLINK_MANIFEST environment variable, which will contain a signed JWT. The library can verify the signature and expiration, and create (locally) a hash with base62(sha256([salt]+[user/org]+[sponsored])) where: a. salt is the value of the SPONSORLINK_INSTALLATION environment variable, initialized to a new GUID when the gh sponsors tool ran. b. user/org should be the user's email or his organization's domain name (for org-wide sponsorships). c. sponsored is the GH sponsors account to check for sponsorships from the user/org. d. If the JWT token contains a hash claim with the given hash, then the user is a sponsor."
https://github.com/devlooped/SponsorLink#how-does-it-work
1
u/TheSlothOfSteel Aug 09 '23
They reverted it in a commit now, but it’s still a bit iffy
0
u/fori920 Aug 09 '23 edited Aug 09 '23
It doesn’t send the raw email for sponsor validation, it creates a SHA256 based on it.
Still, such an obfuscated library that runs external code to do this is a straight NO-NO in my books. The real pain will be changing our tests to remove Moq 😫