Skip to content

AlanLau9809/2025_COMP3334_Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

36 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Secure Online Storage System with Client-Side Encryption

COMP3334 - Computer Systems Security: Coursework Group Project (2025)

Python Flask Security License

๐Ÿ“‹ Abstract

This project implements a secure online storage system designed to protect user data from passive attacks through comprehensive security measures. The system features client-side file encryption, multi-factor authentication, secure password hashing, and comprehensive audit logging. The design ensures that server administrators cannot access unencrypted files while maintaining usability and implementing defense against common security vulnerabilities.

Key Security Focus: Protection against passive adversaries including server operators and unauthorized users attempting to decrypt data or compromise accounts.

๐Ÿ”’ Security Architecture

Threat Model

  • Server Operators: Passive adversaries who can read encrypted files and observe client-server communications but cannot perform active attacks
  • Unauthorized Users: Malicious actors with compromised devices or stolen credentials attempting to access or decrypt user data

Core Security Features

  • ๐Ÿ” AES-256-CBC Encryption with unique initialization vectors (IV)
  • ๐Ÿ”‘ HMAC-SHA256 for secure password hashing and key derivation
  • ๐Ÿ“ง Multi-Factor Authentication via email OTP verification
  • ๐Ÿ›ก๏ธ SQL Injection Protection using SQLAlchemy ORM
  • ๐Ÿ“Š Comprehensive Audit Logging for all user actions
  • ๐Ÿšซ Access Control with file ownership and sharing permissions

๐Ÿ—๏ธ Technical Implementation

Encryption Algorithms

File Encryption: AES-256-CBC with PKCS#7 Padding
Key Derivation: HMAC-based Key Derivation Function (HKDF)
Password Hashing: HMAC-SHA256 with cryptographically secure salt
Random Generation: os.urandom() for cryptographically secure randomness

Security Measures

  • Client-side encryption before file upload
  • Unique encryption keys per file with secure key derivation
  • Session management with secure cookie configuration
  • Input validation and sanitization
  • Role-based access control (User/Admin)

๐Ÿš€ Features

User Management

  • โœ… Secure user registration with email verification
  • โœ… Multi-factor authentication (OTP via email)
  • โœ… Password strength validation and secure storage
  • โœ… Session management with automatic logout

File Operations

  • โœ… Encrypted file upload (supports .txt, .pdf, .docx, .xlsx, .pptx, images, audio, video, archives)
  • โœ… Secure file sharing with permission controls
  • โœ… Online file viewing/editing for text files
  • โœ… Encrypted file download with integrity verification
  • โœ… Secure file deletion with database cleanup

Administrative Features

  • โœ… Comprehensive audit logging with filtering and search
  • โœ… User activity monitoring and suspicious behavior detection
  • โœ… System-wide security oversight and access control management

Security Validations

  • โœ… SQL Injection Protection - Demonstrated resistance to injection attacks
  • โœ… Unauthorized Access Prevention - Session-based access control
  • โœ… Admin Privilege Escalation Protection - Role verification for sensitive operations

๐Ÿ“‹ Requirements

System Requirements

  • Python: 3.9 or higher
  • Database: MySQL 8.0+ or MariaDB 10.5+
  • Web Server: Development server included (Flask)
  • Email Service: SMTP server for OTP delivery

Python Dependencies

flask==3.0.2
flask-sqlalchemy==3.1.1
flask-login==0.6.3
flask-migrate==4.0.5
cryptography==42.0.5
python-dotenv==1.0.1
pymysql==1.1.0
wtforms==3.1.2
flask-mail==0.10.0

๐Ÿ› ๏ธ Installation & Setup

1. Clone Repository

git clone https://github.com/AlanLau9809/COMP3334_Project.git
cd COMP3334_Project

2. Create Virtual Environment (Recommended)

# Create virtual environment
python -m venv venv

# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Database Setup

Option A: Using XAMPP (Recommended for Development)

  1. Install and start XAMPP
  2. Start MySQL service in XAMPP Control Panel
  3. Import database schema:

Option B: Manual MySQL Setup

# Login to MySQL
mysql -u root -p

# Create database
CREATE DATABASE online_storage;

# Import schema
mysql -u root -p online_storage < online_storage.sql

5. Email Configuration (Required for OTP)

The system uses Gmail SMTP for OTP delivery. Current configuration in app/__init__.py:

app.config['MAIL_SERVER'] = 'sample.smtp.gmail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = 'sample.polycomp3334project@gmail.com'
app.config['MAIL_PASSWORD'] = 'SamplePassword'

For production deployment: Update email credentials in app/__init__.py or use environment variables.

6. Run Application

python run.py

Access the application: http://localhost:5000

๐Ÿ‘ค Default Admin Account

A pre-configured admin account is included for initial setup:

Username: admin
Password: 123
Email: admin@admin.com

โš ๏ธ Security Notice:

  • Change the default password immediately after first login
  • This account should only be used for initial system setup
  • Create additional admin accounts through database modification if needed

Creating Additional Admin Users

-- Method 1: Promote existing user to admin
UPDATE User SET is_admin = 1 WHERE username = 'your_username';

-- Method 2: Verify admin status
SELECT username, is_admin FROM User WHERE is_admin = 1;

๐Ÿ” Security Testing & Validation

SQL Injection Protection Test

The system successfully prevents SQL injection attacks through SQLAlchemy ORM:

โœ… Parameterized queries prevent injection
โœ… Input sanitization and validation
โœ… No raw SQL query execution

Access Control Validation

โœ… Session-based authentication required
โœ… File ownership verification
โœ… Admin privilege verification for sensitive operations
โœ… Automatic session termination for security

Encryption Validation

โœ… Unique encryption keys per file
โœ… Secure key derivation using HMAC
โœ… Proper IV generation and handling
โœ… PKCS#7 padding implementation

๐Ÿ“Š System Architecture

Database Schema

  • User: User accounts with secure password storage
  • File: Encrypted file storage with metadata
  • FileShare: File sharing permissions and access control
  • AuditLog: Comprehensive activity logging

Security Flow

  1. User Registration โ†’ Email OTP verification โ†’ Secure password hashing
  2. File Upload โ†’ Client-side encryption โ†’ Secure key storage
  3. File Access โ†’ Permission verification โ†’ Decryption โ†’ Audit logging
  4. Admin Operations โ†’ Role verification โ†’ Action logging

๐Ÿ”ฎ Future Enhancements

Planned Security Improvements

  • Version Control: Encrypted file versioning with delta encoding
  • Trash & Recovery: 30-day encrypted file recovery system
  • Advanced Sharing: Time-limited access and read-only permissions
  • Notification System: Security alerts for failed login attempts
  • API Development: RESTful API for third-party integrations

Technical Roadmap

  • Enhanced Encryption: Consider post-quantum cryptography
  • Zero-Knowledge Architecture: Server-side encryption key elimination
  • Advanced Audit: Machine learning for anomaly detection
  • Mobile Support: Cross-platform mobile application

๐Ÿ† Project Achievements

Security Implementation

  • โœ… Zero server-side plaintext exposure - All files encrypted before upload
  • โœ… Comprehensive threat mitigation - Protection against passive adversaries
  • โœ… Industry-standard cryptography - AES-256-CBC with proper implementation
  • โœ… Multi-layered security - Authentication, authorization, and audit logging

Technical Excellence

  • โœ… Clean architecture - Separation of concerns with Flask blueprints
  • โœ… Secure coding practices - Input validation, error handling, session management
  • โœ… Database security - ORM usage, proper indexing, foreign key constraints
  • โœ… User experience - Intuitive interface with security transparency

๐Ÿ“š Technical References

Cryptographic Standards

Security Best Practices

๐Ÿ“„ License

This project is developed for academic purposes as part of PolyU COMP3334 - Computer Systems Security course. All rights reserved for educational use.

About

A secure online storage system designed to protect user data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors