Get a Pentest and security assessment of your IT network.

Cyber Security

Secure Biometric Login

TL;DR

This guide shows you how to securely handle biometric authentication data against a server. We’ll focus on not storing the actual biometric data, but instead using it to create a secure key for verification.

Steps

  1. Understand the Risks
    • Storing raw biometric data (fingerprints, face scans) is a huge security risk. If your server is hacked, that data is compromised.
    • Biometric data can’t be easily changed if stolen – unlike passwords.
  2. Choose a Biometric Method
    • Consider the user experience and security level needed. Fingerprint scanners are common, but facial recognition or voice biometrics might be suitable.
    • The method will determine how you get an initial biometric reading from the device.
  3. Client-Side Processing: Create a Biometric Template
  4. This happens on the user’s device (phone, laptop). Never send raw biometric data to your server.

    • Use a secure library or API provided by the operating system (e.g., Android BiometricPrompt, Apple LocalAuthentication). These libraries handle the complex biometric processing and security aspects.
    • The library will create a template from the biometric data. This template is a mathematical representation of the unique features – not the actual image or scan.
  5. Server-Side: Generate a Unique Key
  6. When the user first registers, you need to link their biometric template to a secure key on your server.

    • Generate a strong, random secret key for each user. This is used for verification later.
    • Hash the biometric template using a strong cryptographic hash function (e.g., SHA-256) along with a unique salt specific to that user. This creates a secure identifier.
    • Store the hashed template and the secret key in your database, associated with the user’s account.
    • # Example (Python - using hashlib for demonstration only)
      import hashlib
      salt = 'your_unique_salt'
      hashed_template = hashlib.sha256((biometric_template + salt).encode()).hexdigest()
      
  7. Authentication Process
    1. Client-Side: Capture Biometric Data Again
      • Use the same biometric method as registration.
      • Create a new biometric template from the captured data using the secure library.
    2. Send Hashed Template to Server
      • Hash the new template on the client-side, using the same salt as during registration.
      • Send only this hashed template to your server.
    3. Server-Side: Verify the Hash
      • Retrieve the stored hashed template for the user from the database.
      • Compare the received hash with the stored hash. If they match, authentication is successful.
      • # Example (Python)
        if hashlib.sha256((received_hash + salt).encode()).hexdigest() == stored_hashed_template:
          # Authentication successful!
        else:
          # Authentication failed.
        
    4. Use the Secret Key
      • Once authentication is confirmed, use the user’s secret key to encrypt/decrypt sensitive data or grant access to resources. Do not expose the secret key directly to the client.
  8. Security Considerations
    • Salt Uniqueness: Each user must have a unique salt. This prevents rainbow table attacks.
    • Key Storage: Protect your database containing the secret keys with strong encryption and access controls.
    • Transport Layer Security (TLS): Always use HTTPS to encrypt communication between the client and server.
    • Rate Limiting: Implement rate limiting on authentication attempts to prevent brute-force attacks.
    • Regular Updates: Keep your biometric libraries and cryptographic functions up to date to address security vulnerabilities.
Related posts
Cyber Security

Zip Codes & PII: Are They Personal Data?

Cyber Security

Zero-Day Vulnerabilities: User Defence Guide

Cyber Security

Zero Knowledge Voting with Trusted Server

Cyber Security

ZeroNet: 51% Attack Risks & Mitigation