Blog | G5 Cyber Security

Secure Login: CIA Triad

TL;DR

This guide shows how to make your login system more secure by focusing on Confidentiality, Integrity, and Availability (the CIA triad). We’ll cover strong passwords, safe data storage, and keeping the system running.

1. Confidentiality: Protecting Passwords

Confidentiality means only authorised people can see your password. Never store passwords in plain text!

python
import bcrypt

hashed_password = bcrypt.hashpw(b'mysecretpassword', bcrypt.gensalt()) 
print(hashed_password)
  • Salting: Add a unique random value (the ‘salt’) to each password before hashing. This makes rainbow table attacks much harder. The salt should be stored with the hash.
  • Database Security: Protect your database! Limit access, encrypt data at rest and in transit, and regularly back it up.
  • 2. Integrity: Ensuring Data Isn’t Tampered With

    Integrity means making sure passwords haven’t been changed without permission.

    php
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    // Example of basic validation - more robust checks are needed!
    if (!preg_match('/^[a-zA-Z0-9]+$/', $username)) {
      die('Invalid username');
    }
    
  • Regular Audits: Check your logs for suspicious activity. Look for failed login attempts, unexpected changes to user accounts, or other anomalies.
  • 3. Availability: Keeping the System Online

    Availability means making sure users can log in when they need to.

    4. Multi-Factor Authentication (MFA)

    Add an extra layer of security beyond just a password.

    5. Password Policies

    Enforce strong password rules.

    Exit mobile version