
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
A tiny, no-frills library for integrating MFA into your app's authentication and provisioning flows.
A tiny, no-frills library for integrating MFA into your app's authentication and provisioning flows.
To add MFA for one of your users, you need to generate (or derive) an MFA secret for that user.
The simplest way to do this in Node.js is via crypto.randomBytes()
, but you're free to choose your favorite PRNG.
You'll need to store this secret safely, because you'll need it every time the user needs to authenticate with MFA.
import { randomBytes } from 'crypto';
const mfaSecret = randomBytes(32);
Once you have the user's MFA secret, you'll need to present them with a QR code to scan into their Authenticator app.
How you generate the QR code is up to you, but the content of that QR code is a special URL you get via this library's provision()
function.
import { provision } from '@twuni/mfa';
const mfaProvisioningUrl = provision({
issuer: 'ACME Widgets, Inc.',
secret: mfaSecret,
subject: 'alice@example.com'
});
// "otpauth://totp/alice%40example.com?issuer=ACME+Widgets%2C+Inc.&secret=..."
Once the user has been presented with a QR code to scan for that URL, make sure you ask them to verify by asking them for their MFA code right away:
import { verify } from '@twuni/mfa';
try {
verify(mfaSecret, mfaCode);
// MFA verification succeeded!
} catch (error) {
// ...verification failed, code did not match!
}
If verify()
does not throw an error, then MFA succeeded and you can turn on MFA for that user.
Typically, you want to ask the user to provide an MFA code after successfully logging in with their usual credentials.
Just integrate the same verify()
step as above in the last step of the provisioning flow.
You can use the challenge()
function to generate an MFA code for a user, which you can send to them via whichever communication channel the user prefers for MFA. The verify()
step is the same as before.
import { challenge } from '@twuni/mfa';
const mfaCode = challenge(mfaSecret);
// "123004"
You can use the challenge()
function, as above, to generate MFA codes for other apps, too, if you know their MFA secrets.
You can use this to automate MFA challenge/response protocols and/or build an MFA authenticator right into your app.
FAQs
A tiny, no-frills library for integrating MFA into your app's authentication and provisioning flows.
We found that @twuni/mfa demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.