New npm Flaws Let Attackers Better Target Packages for Account Takeover
Two flaws in npm allowed any user to discover whether another user had enabled two-factor authentication and whether an organisation enforced it, by adding the user as a maintainer or by reading profile data. An attacker could use this to target maintainers without 2FA for account takeover and then poison packages.
Published on blog.aquasec.com
For the past few years, cybercriminals have been hijacking popular npm packages by taking over maintainers’ accounts. As part of our research at Team Nautilus, we discovered two flaws in the npm platform related to two-factor authentication (2FA).
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the npm website exposed maintainers' 2FA status and organisation enforcement flags to other users without proper access control.
Impact
An attacker could identify maintainers without 2FA and target them for account takeover, potentially poisoning popular packages and affecting many users; the report notes that 32% of top-35 packages remained at risk from dependencies' owners.
What the attacker needed
An npm account; ability to publish a package; no special privileges
The fix
The issues were fixed: npm stopped showing a maintainer's 2FA status and removed the enforced_tfa and isStaff fields from profile data.
How it was found
- Create and publish an npm package.
- Open the package access settings page.
- Add the target npm user as a maintainer.
- Observe the user's 2FA status in the maintainer window.
- Alternatively, request a user or organisation profile page.
- Extract the enforced_tfa and isStaff values from the page's context data.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Two-factor authentication (2FA) is a second check, like a code from your phone, on top of your password. npm is a huge library of code packages that developers reuse. The report found that npm accidentally revealed which package owners had not turned on 2FA, so an attacker could focus on the weakest accounts and try to take them over.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.