-
Notifications
You must be signed in to change notification settings - Fork 118
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
Support npm auth-and-writes
2FA setting
#93
Comments
this approach would concern me a bit. considering a worm like was attempted with eslint, the environment variables could be stolen just as easily as the token. while this is a creative way to make this work, i'd really hesitate to expose the 2fa secret to anything other than my 2fa app, such as google authenticator or authy because of opening up the account to further risk. imho, i think a better approach would be to have the ability to require 2fa for |
i'm actually interested in thoughts that the npm security team might have in this area. @evilpacket, would you or someone from you team be willing to discuss this use case in more detail? i think it would be a big help those of use that publish automatically from a non-interactive CI service to make sure we are considering what your team might already have in mind. (is there a better place for that conversation than this issue thread?) |
I didn't know you could limit the source IP with In the proposal above nothing would change if you don't enable 2FA Finally the point of enabling 2FA with As a recap:
So the solution 2 is still a lot better as it protect you if your password is compromised. This is what happened to the ESLint contributor. And this is a lot more likely to happens than having Travis variables compromised as users tends to have weak passwords and re-use the same one everywhere. |
agreed, but the difficulty of using the token is significantly reduced. while it is not difficult to run on a travis instance, it does take more work than just using the token on the attacker's machine. it also puts the attacker at more risk of being discovered using the stolen token. even beyond all of that though, the attacker needs to somehow know what the cidr restriction of the token is, which would require them to have tracked where they stole the token from (i just verified that
this would be what I would probably do due to the risk of possibly exposing the 2fa secret. however, the reason i raised the question was that it seems to me like a severe enough risk, even if unlikely (though the eslint worm could have easily grabbed this info if it was looking for it), that we may not want to enable/encourage the potential of the leak.
yes and no. as mentioned above, the attacker would somehow have to know what CIDRs are allowed for the token (hard), have access to run on an instance within the restriction (simple for travis, but maybe impossible in other cases), and actually run on said instance (more work and potentially higher risk for the attacker).
2fa for this gets better if we can convince npm to allow enabling 2fa for |
i've started an RFC related to the token 2fa rules i mentioned above. still needs work, but wanted to add visibility here. feel free to provide thoughts there if it will help here. |
Would you accept a PR to add an option for The implementation of the server can, e.g., send a push notification to a mobile phone, and the phone can then respond with the OTP if the user permits that. I know a sample server is in the works, I don't know when it's going public, but I'd like to start testing it :) A more flexible approach could be an option for |
Getting back to this - there is now a PoC server for remote OTP requests: https://github.com/nearform/optic How it works:
All secrets always stay on the client (i.e. your phone). You can try it out, I've deployed it here (no SLA): https://optic.goodnight.to
I'm more than happy to answer any questions or jump on a call to give a quick demo and build a PR to support the concept. This brings a true 2FA for fully automated There's gotchas and caveats and more work to be done, but I figure it's a start? |
not suggesting that this is a problem for all use cases, but i would still find this a step backward. a big part of the value of semantic-release for me is that it can publish new versions while i'm sleeping, etc. needing to interact even to approve/reject removes the ability to automate to that level. |
I very much agree with your suggestion to have tokens which are non-2FA (or rather to limit their use to a CIDR range)! However, that is not always enough. There's different levels of security required for different contexts. There's also different ways to implement this (e.g. you could have a 2FA service which automatically responds with an OTP without a user interaction). |
Opened a PR for Still not sure how to assert in tests that |
Follow-up to #92.
It should be possible to support npm auth-and-writes level of two-factor-authentication by generating the OTP on the CI with a tool like otplib.
Users would have to enable npm 2FA via command line and on the step where the QRCode is displayed, copy the secret key displayed below it (Something like
Or enter code: XXXXXXXX....
).The secret would have to be added on the CI as a secured environment variable (e.g.
NPM_2FA_SECRET
).The only constraint is that if 2FA is already enabled, there is no way to retrieve the secret key. So users would have to disable 2FA and re-enable it via CLI to obtain a new secret key.
Then the plugin would generate the OTP with:
And call
npm publish
with the--otp
option.We would also need to implement #11 and make sure that if the
auth-and-writes
option is enabled the environment variableNPM_2FA_SECRET
is set. Unfortunately it doesn't seems there is a way to verify ifNPM_2FA_SECRET
is correct, as all thenpm
command that requires an OTP are things that makes changes server side, so we can't use them to test.The text was updated successfully, but these errors were encountered: