Skip to content

Ash007dev/IronVault

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽ–๏ธ IronVault - Tactical Credentials System

A comprehensive cybersecurity demonstration platform featuring military-grade encryption, digital signatures, multi-factor authentication, WebAuthn/Passkeys, and role-based access control.

Course License Python Next.js


๐Ÿ“‘ Table of Contents


๐Ÿ” Overview

IronVault is a secure credential management system designed to demonstrate enterprise-level security concepts in a military-themed context. The platform showcases real-world implementations of cryptographic protocols, secure authentication mechanisms, and access control patterns.

Key Objectives

  • Encryption at Rest: All sensitive data encrypted with AES-256-CBC
  • Digital Signatures: Mission documents signed with RSA-2048-PSS
  • Multi-Factor Authentication: Email OTP + WebAuthn/Passkey support
  • Role-Based Access Control: Hierarchical permission system
  • Complete Audit Trail: All security events logged and monitored

โœจ Features

๐Ÿ” Security Features

Feature Implementation Purpose
Password Security PBKDF2-SHA256 (100K iterations) Secure password storage
Data Encryption AES-256-CBC with random IV Protect sensitive data
Digital Signatures RSA-2048-PSS Document authenticity
Token Auth JWT with HS256 Stateless authentication
MFA Email OTP (6-digit, 5-min expiry) Second factor verification
Passkeys WebAuthn/FIDO2 Passwordless authentication

๐Ÿ‘ค User Features by Role

Field Operative:

  • Personal encrypted credential vault
  • CSPRNG-based secure password generation
  • View intel from Commanding Officers
  • WebAuthn passkey registration

Commanding Officer:

  • Issue encrypted intel directives
  • View operative missions
  • Create signed operations
  • Team management

Central Command (HQ):

  • Complete personnel oversight
  • Audit log monitoring (War Room)
  • System-wide visibility
  • Security event filtering

๐Ÿ—๏ธ Architecture

IronVault/
โ”œโ”€โ”€ backend/                      # Flask API Server
โ”‚   โ”œโ”€โ”€ app.py                   # Application entry point
โ”‚   โ”œโ”€โ”€ config.py                # Configuration & key paths
โ”‚   โ”œโ”€โ”€ models.py                # Database schema & operations
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ auth.py              # Authentication & MFA
โ”‚   โ”‚   โ”œโ”€โ”€ credentials.py       # Operative vault CRUD
โ”‚   โ”‚   โ”œโ”€โ”€ missions.py          # Mission management
โ”‚   โ”‚   โ”œโ”€โ”€ intel.py             # Intel & operations
โ”‚   โ”‚   โ””โ”€โ”€ admin.py             # HQ administration
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”œโ”€โ”€ access_control.py    # RBAC & JWT middleware
โ”‚   โ”‚   โ”œโ”€โ”€ crypto.py            # Encryption utilities
โ”‚   โ”‚   โ”œโ”€โ”€ otp.py               # OTP generation/verification
โ”‚   โ”‚   โ””โ”€โ”€ webauthn_utils.py    # Passkey utilities
โ”‚   โ””โ”€โ”€ keys/                    # Auto-generated keys (gitignored)
โ”‚
โ””โ”€โ”€ frontend/                     # Next.js 15 Web App
    โ””โ”€โ”€ src/
        โ”œโ”€โ”€ app/
        โ”‚   โ”œโ”€โ”€ page.tsx         # Login page
        โ”‚   โ”œโ”€โ”€ signup/          # Registration
        โ”‚   โ”œโ”€โ”€ reset-password/  # Password recovery
        โ”‚   โ”œโ”€โ”€ profile/         # User settings & passkeys
        โ”‚   โ”œโ”€โ”€ operative/       # Field operative dashboards
        โ”‚   โ”œโ”€โ”€ co/              # Commanding officer views
        โ”‚   โ””โ”€โ”€ hq/              # Central command panels
        โ”œโ”€โ”€ components/          # Reusable UI components
        โ””โ”€โ”€ lib/
            โ””โ”€โ”€ api.ts           # API client

๐Ÿ”’ Security Implementation

Password Hashing

# PBKDF2-SHA256 with high iteration count
password_hash = hashlib.pbkdf2_hmac(
    'sha256',
    password.encode(),
    salt,
    100000  # 100K iterations for brute-force resistance
)

AES-256-CBC Encryption

# Encrypt sensitive data
cipher = Cipher(
    algorithms.AES(key),      # 256-bit key
    modes.CBC(iv),            # Random 16-byte IV
    backend=default_backend()
)
# IV prepended to ciphertext for decryption

RSA Digital Signatures

# Sign mission documents with PSS padding
signature = private_key.sign(
    document_bytes,
    padding.PSS(
        mgf=padding.MGF1(hashes.SHA256()),
        salt_length=padding.PSS.MAX_LENGTH
    ),
    hashes.SHA256()
)

JWT Authentication Flow

1. User submits credentials
2. Server validates password hash
3. OTP sent to registered email
4. User submits OTP
5. JWT issued with user claims
6. Token included in subsequent requests

WebAuthn/Passkey Flow

Registration:
1. Server generates challenge
2. Client creates credential (biometric/security key)
3. Server stores public key

Authentication:
1. Server sends challenge
2. Client signs with private key
3. Server verifies signature

๐Ÿ‘ฅ User Roles & Access Control

Role Hierarchy

Role Code Description Clearance
Field Operative operative Field Agent Level 1
Commanding Officer co Unit Commander Level 2
Central Command hq HQ Administrator Level 3

Permissions Matrix

Resource Operative CO HQ
Credentials Vault CRUD (own) โŒ โŒ
Missions CRUD (own) Read/Create Read
Intel Reports Read CRUD Read
Operations โŒ Create/Read Read
Personnel โŒ โŒ Read
Audit Logs โŒ โŒ Read

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • Gmail account (for OTP emails)

1. Clone & Setup Backend

# Navigate to backend
cd backend

# Install dependencies
pip install -r requirements.txt

# Create .env file for email
echo "EMAIL_USER=your-email@gmail.com" > .env
echo "EMAIL_PASS=your-app-password" >> .env

# Start server
python app.py

Server runs on http://127.0.0.1:5000

First Run: Automatically generates:

  • ๐Ÿ”‘ RSA-2048 key pair (keys/private_key.pem, keys/public_key.pem)
  • ๐Ÿ” AES-256 key (keys/aes_key.key)
  • ๐Ÿ—„๏ธ SQLite database (ironvault.db)
  • ๐Ÿ‘ค Demo user accounts

2. Setup Frontend

# Navigate to frontend
cd frontend

# Install dependencies
npm install

# Start development server
npm run dev

App runs on http://localhost:3000

3. Gmail App Password Setup

  1. Enable 2-Factor Authentication on your Gmail
  2. Go to Google App Passwords
  3. Generate a new app password for "Mail"
  4. Use this password in the .env file

๐Ÿ“ก API Reference

Authentication Endpoints

Method Endpoint Description
POST /auth/register Create new user
POST /auth/login Initiate login (triggers OTP)
POST /auth/verify-otp Verify OTP and get JWT
GET /auth/me Get current user info
POST /auth/change-password Change password
POST /auth/request-password-reset Request reset OTP
POST /auth/reset-password Reset with OTP

WebAuthn Endpoints

Method Endpoint Description
POST /auth/webauthn/register/options Get registration options
POST /auth/webauthn/register/verify Verify registration
POST /auth/webauthn/login/options Get authentication options
POST /auth/webauthn/login/verify Verify authentication

Resource Endpoints

Method Endpoint Description Role
GET/POST /credentials Credential vault Operative
GET/POST /missions Mission assignments All
GET/POST /intel Intel reports CO/HQ
POST /intel/operation Create operation CO
GET /admin/users List all users HQ
GET /admin/audit-logs Audit trail HQ

๐ŸŽฎ Demo Accounts

Username Password Role Description
hq_admin admin123 HQ Central Command access
alpha_co manager123 CO Commanding Officer
ghost_op player123 Operative Field Operative

Note: OTP verification required for all logins


๐Ÿงช Testing

Testing Scenarios

1. Password Hashing Verification

# Login with correct credentials โ†’ Success
# Login with wrong password โ†’ "Invalid credentials"

2. Encryption Testing

# Add credential to vault
# Check database โ†’ encrypted content (base64)
# View in app โ†’ decrypted plaintext

3. Digital Signature Testing

# Create operation as CO
# View operation details โ†’ signature present
# Verify signature โ†’ "Valid"

4. MFA Testing

# Login โ†’ OTP sent to email
# Submit correct OTP โ†’ Access granted
# Submit wrong OTP โ†’ "Invalid OTP"
# Wait 5 minutes โ†’ "OTP expired"

5. RBAC Testing

# Operative accessing /admin โ†’ 403 Forbidden
# CO accessing /credentials โ†’ 403 Forbidden
# HQ accessing /admin โ†’ 200 OK

6. Tamper Detection

# Create mission with signature
# Modify mission data in DB directly
# Verify signature โ†’ "Invalid signature detected"

7. WebAuthn/Passkey Testing

# Register passkey in profile
# Logout and login with passkey
# No password required โ†’ Access granted

Database Inspection

# Open SQLite database
sqlite3 backend/ironvault.db

# View users (passwords are hashed)
SELECT username, role, email FROM users;

# View encrypted credentials
SELECT target_system, encrypted_password FROM credentials;

# View audit logs
SELECT * FROM audit_logs ORDER BY created_at DESC LIMIT 10;

๐Ÿ“ Key Files

File Purpose
backend/utils/crypto.py Encryption, signing, hashing
backend/utils/access_control.py JWT & RBAC middleware
backend/utils/otp.py OTP generation & verification
backend/models.py Database schema & audit logging
frontend/src/lib/api.ts API client with all endpoints

๐Ÿ›ก๏ธ Security Considerations

  1. Keys: Auto-generated on first run, stored in backend/keys/
  2. Database: SQLite for demo, use PostgreSQL in production
  3. HTTPS: Use HTTPS in production for encrypted transit
  4. Rate Limiting: Implement for production deployment
  5. Key Rotation: Implement periodic key rotation for production

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors