Code Monkey home page Code Monkey logo

ethereum-2fa's Introduction

Ethereum Two Factor Authentication

Simple contract for two factor authentication to online services via Ethereum transactions. Note this concept has security and usability flaws, and is therefore merely a demonstration of a basic smart contract and testing with truffle.

Basic Functionality Story

  1. User logs in to example.com with username-password.
  2. example.com asks the user to send a transaction to their 2FA contract, and starts waiting for an Authenticated event. (Note: events before this login are ignored). A reasonable timeout should be set to account for fees and network congestion — after which this login is rejected if no Authenticated event is heard for this user's Ethereum address.
  3. User sends a transaction (does not send ETH, only calls the contract function and pays the gas fee) to the example.com 2FA contract.
  4. example.com sees an Authenticated event on the contract, and provided it is within the timeout and was created by the user's Ethereum address, allows the login.
  5. User is authenticated.

Critical Issues with Blockchain 2FA

Note this is not a serious suggestion, and is merely a demonstration of a very basic smart contract. Reasons that 2FA through Ethereum contracts is an awful idea:

  • It does not add any real security. If an attacker already has your password, if they also know your public Ethereum address, they could simply listen to the blockchain for 2FA activity on your address and attempt their login around the same time (in the hope for a second login attempt in succession).
  • Every 2FA would cost the user at least the minimum network fee, and may be subject to high fees or slow confirmations due to network congestion.
  • The usability of this system would likely be worse than a typical 2FA system such as one-time-passwords provided by 1Password, Google Authenticator, or Authy.

Getting Started

Dependencies:

  • Node v7.6+
  • Ethereum TestRPC
  • Truffle
# Install Truffle and the Ethereum TestRPC dev tools.
npm install -g truffle ethereumjs-testrpc

# Install local dependencies
npm install

# Start the ethereum testrpc
testrpc

# In a new terminal window, run the truffle tests
truffle test

© Copyright 2017 by Liam Gray — Released under the ISC licence.

ethereum-2fa's People

Contributors

hoxxep avatar codemedici avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.