Moq 4.20.0 and 4.20.1 on NuGet added SponsorLink, which sent a hash of the developer's git email to a server during builds, in August 2023.
The package maintainer added it, not an outside attacker. Version 4.20.2 removed the dependency.
What happened
A trusted package started to collect data from developers when they compiled.
- Moq added the sub-dependency
Devlooped.SponsorLink. - It ran
git config --get user.emailin a separate process and hashed the email with SHA-256. - It sent the result to
https://cdn.devlooped.com/sponsorlink. - It ran at build time as a .NET analyzer, with no setting to turn it off.
- It skipped CI systems when it saw variables such as
CI,TF_BUILD,TRAVISandJENKINS_URL.
According to Checkmarx, versions 4.20.0 and 4.20.1 came out on 8 August 2023. Developers reported the behavior on 9 August.
Affected versions
- Moq 4.20.0 and 4.20.1, released on 8 August 2023.
- Last version before the change: 4.18.4.
- Reverted in 4.20.2.
Indicators of compromise
- Package reference:
Devlooped.SponsorLinkin a project or inpackages.lock.json. - Moq version 4.20.0 or 4.20.1.
- Outbound request to
cdn.devlooped.com/sponsorlinkduring a build on a developer machine. - A
git configprocess started by the build.
How to check
List the Moq version and the SponsorLink package in each solution. Any hit means the build possibly sent the hash.
dotnet list package --include-transitive | grep -iE "moq|sponsorlink"
Search the NuGet cache for the package.
ls ~/.nuget/packages | grep -i sponsorlink
What to do now
- Move to Moq 4.20.2 or a version before 4.20.0, such as 4.18.4. Check that
Devlooped.SponsorLinkis gone from the lockfile. - Delete the SponsorLink package from the NuGet cache.
- Block Moq 4.20.0 and 4.20.1 in your package feed.
- Ask your privacy officer if a hashed email counts as personal data in your case.
Frequently asked questions
What did the maintainer say?
Daniel Cazzulino said the real email is never sent and the hash uses SHA-256 then Base62 encoding. Full emails were stored only after a user installed the SponsorLink GitHub app.
Who uses Moq?
Snyk and BleepingComputer name Microsoft PowerToys and Jellyfin. Snyk reports 10,356 downloads of 4.20.0 in under 24 hours.
Sources
Send this page to the person who looks after AI at your company.