- Overview
- How to Run the Demo
- FIDO2 MFA Usage Demo
- Important Classes and Their Functions
- How the Demo Works
- Visualizing Logs
- Future Work
- Troubleshooting
- Already Implemented
- Resources
$$$$$$$$\ $$$$$$\ $$$$$$$\ $$$$$$\ $$$$$$\ $$$$$$$\ $$$$$$\ $$$$$$\
$$ _____|\_$$ _|$$ __$$\ $$ __$$\ $$ __$$\ $$ __$$\ $$ __$$\ $$ __$$\
$$ | $$ | $$ | $$ |$$ / $$ |\__/ $$ | $$ | $$ |$$ / $$ |$$ / \__|
$$$$$\ $$ | $$ | $$ |$$ | $$ | $$$$$$ | $$$$$$$ |$$ | $$ |$$ |
$$ __| $$ | $$ | $$ |$$ | $$ |$$ ____/ $$ ____/ $$ | $$ |$$ |
$$ | $$ | $$ | $$ |$$ | $$ |$$ | $$ | $$ | $$ |$$ | $$\
$$ | $$$$$$\ $$$$$$$ | $$$$$$ |$$$$$$$$\ $$ | $$$$$$ |\$$$$$$ |
\__| \______|\_______/ \______/ \________| \__| \______/ \______/
This repository contains a Python-based demo that simulates FIDO2 authentication using a YubiKey-like hardware security token. The demo showcases the interaction between a client (browser), a relying party (web service), and a YubiKey in a typical two-factor authentication (2FA) flow.
The demo implements the core cryptographic challenge-response system used in FIDO2. In this system, a user logs into a website with a username and password (1FA) and authenticates using a YubiKey (MFA). This README explains the project's major components, how to run the demo, and key features such as MFA management, YubiKey interactions, and phishing-resistant authentication.
-
FIDO2 MFA Usage Demo: Demonstrates the phishing-resistant nature of FIDO2 by simulating both legitimate and phishing login attempts. The demo shows how authentication is successfully completed for the legitimate relying party while thwarting phishing attempts by detecting mismatches in the RP ID.
-
Cryptographic Challenge-Response: The system uses YubiKey’s challenge-response mechanism to securely authenticate users by validating a signed challenge with the legitimate relying party.
-
Debug and Display Flags: Explore detailed backend actions with flags like
-display_crypto_backend,-debug_mode,-debug_challenge, and-debug_yubikey. These allow you to see cryptographic operations and even edit values during runtime to test different scenarios.
This overview, along with the included examples, will help you understand how FIDO2 and YubiKey technology works and why it's an effective defense against phishing attacks.
-
Clone the repository:
git clone https://github.com/MFA-Phishing-MQP-WPI/Hardware-FIDO2-Implementation-Demo.git cd Hardware-FIDO2-Implementation-Demo -
Run the demo:
python3 demo.py
-
Command Line Options:
python3 demo.py --launch-from-save saved_states/presentation.dump- Bash (linux, cmd, mac)
'argon2-cffi', 'cryptography', 'colorama', 'readline', 'yubico-client', 'pyotp', 'qrcode', 'pillow', 'qrcode-terminal', 'qrcode'
- PowerShell (windows)
'argon2-cffi', 'cryptography', 'colorama', 'pyreadline', 'yubico-client', 'pyotp', 'qrcode', 'pillow', 'qrcode-terminal', 'qrcode'
These packages are automatically installed by running the demo if they aren't already available.
The FIDO2 MFA Usage Demo is a comprehensive demonstration of how YubiKey and FIDO2 prevent phishing attacks by verifying the RelyingParty (RP) ID during the authentication process. This demo allows you to explore how authentication works when using a legitimate service (login.microsoftonline.com) and how phishing attempts from an attacker (attacker.vm) are thwarted.
- Basic Run Command
To start the demo using the saved system state
presentation.dump, run the following command:python3 demo.py -display_crypto_backend --launch-from-save saved_states/presentation.dump
This will load the saved state where two Relying Parties (login.microsoftonline.com and attacker.vm) are set up, along with predefined user accounts such as PasswordOnly-User, LastPass-User, and Craig.
- Running with All Flags (
-all_flagsflag) For a more detailed exploration, use the-all_flagsto enable additional debug and display features. This runs the demo with all available flags:python3 demo.py -all_flags --launch-from-save saved_states/presentation.dump
- The
-all_flagsflag activates the following options:-display_crypto_backend: Displays detailed information about actions completed by the cryptographic backend, helping users understand how the encryption and signing processes work.-fancy_display_location: Displays RP name and username when login-context changes. Please note the text is large.-debug_mode: Prints the value of all private keys at the runtime start, which is useful for those interested in the cryptographic details.-debug_challenge: Allows you to edit the challenge values before they are sent to the YubiKey for authentication. This is especially useful for testing different scenarios, such as attempting to spoof the challenge from an incorrect Relying Party.-debug_yubikey: Enables editing of the YubiKey’s internal values, giving the user more control over the authentication process.
These flags allow users to examine the authentication flow in depth and modify key components at runtime to simulate phishing attacks and RP mismatches.
For accounts like PasswordOnly-User, AuthenticatorApp-User, and LastPass-User, which only require a password or password and MFA in non-FIDO2 form, you will be able to log in on both login.microsoftonline.com and the phishing site attacker.vm which simply acts as a middle man between the client and the "real" RP (login.microsoftonline.com).
For FIDO2-MFA-protected accounts like Secure-User, you will see that login works on login.microsoftonline.com but fails on attacker.vm. The Client will prevent the YubiKey from signing the Challenge from the phishing site, highlighting the phishing-resistant nature of FIDO2. Even if the attacker.vm changes the value of the Relying Party in the Challenge before passing it to the victim's Client, the YubiKey will then generate the wrong Private Key and incorrectly sign the Challenge leading to a decryption failure on the "real" Relying Party side. Blocking access to the attacker yet again.
| Username | Password Hash (base64) | Password Salt (base64) | MFA TYPE | Server-Side MFA Data |
|---|---|---|---|---|
| PasswordOnly-User | JGFyZ29uMmlkJHY9MTkkbT02NTUzNix0PT... | tepfX-Vap99Ea-7FmAYveadp... | NONE | No Data Available |
| AuthenticatorApp-User | JGFyZ29uMmlkJHY9MTkkbT02NTUzNix0PT... | 4sX_YM7F6Z11AAywzJ_MFicz... | AUTH APP | OTC_Secret=DB7XGAIEPNCXPPB4YWKGVXEY... |
| LastPass-User | JGFyZ29uMmlkJHY9MTkkbT02NTUzNix0PT... | hiDrdFyXh3hF62vJsGoW-Vb_... | OTP | YubiKeyID=cccccbrvuujr |
| Secure-User | JGFyZ29uMmlkJHY9MTkkbT02NTUzNix0PT... | aZC8rWCW29Mwdt3BR9Ix8n3D... | FIDO-2 | PublicKey=LS0tLS1CRUdJTiBQVUJMSUMgS... |
-debug_challenge:- This flag lets you intercept and edit the
Challengecreation process before it is sent to theYubiKeyfor authentication. - You can modify the values of the
Challenge, such as theRP ID, to see how theYubiKeygenerates aPrivate Keyand how theRelying Partyresponds when thesignaturedoes not match the legitimate site. - This feature is especially useful if you want to simulate what happens when a
Challengeis sent from a differentRelying Partyor user during runtime, giving you control over the authentication flow.
- This flag lets you intercept and edit the
-debug_yubikey:- With this flag, you can edit the values used inside the
YubiKeyitself. This lets you see how altering theYubiKey’s internal state would affect the authentication process. - By modifying the
YubiKey’s behavior or values during runtime, you can explore different security scenarios and understand how theYubiKeyprotects against tampered or incorrect inputs.
- With this flag, you can edit the values used inside the
The FIDO2 MFA Usage Demo showcases the power of YubiKey (or other hardware security tokens) and FIDO2 to protect against phishing attacks by preventing attestation challenges from unauthorized Relying Parties. By running the demo with the -all_flags flag and exploring the -debug_challenge and -debug_yubikey flags, you can see how the system detects and stops phishing attempts, even when credentials are stolen. This detailed exploration of YubiKey's anti-phishing mechanisms highlights why FIDO2 is a robust and secure MFA method.
Manages interactions between the user and the system, simulating user input and the hardware insertion process for YubiKeys.
Simulates a browser (e.g., Chrome) interacting with websites and performing actions such as logging in.
-
Client Connection:
- The client connects to a relying party (e.g., login.microsoft.com).
-
Account Registration:
- The user creates a new account by providing a username and password.
-
MFA Registration:
- The user adds MFA to their account by registering a YubiKey.
-
Login Process:
- The user logs in with their username and password (1FA). If MFA is required, the system requests the insertion of the user's YubiKey.
-
Challenge Generation:
- The relying party generates a cryptographic challenge, which is sent to the YubiKey for signing.
-
Challenge Signing:
- The YubiKey signs the challenge using its private key, and the signed response is sent back to the relying party.
-
MFA Validation:
- The relying party verifies the signature. If it’s correct, the user is granted a session token and successfully logged in.
-
RelyingParty: actions such as secure storage and authentication.
-
Errors: general errors.OperatingSystem: Interfacing with user.
-
Client: actions such as connection requests.
-
Warningsgeneral warnings.YubiKeyoperations, including cryptographic signing and challenge responses.
The backend logging system provides verbose output of the cryptographic operations, user actions, and system decisions.
- Additional secure account actions, such as sending emails or viewing secure data.
pip install argon2-cffi cryptography colorama