Skip to content

Latest commit

 

History

45 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

WhisperChain+: Anonymous Messaging with Role-Based Control and Accountability

by Cameron Keith and Jacob Zhang

COSC 55: Security and Privacy Lab 2

Spring 2025

Professor Sami Saydjari, Mohamed Moustafa Dawoud

Project Overview

WhisperChain+ is a secure, anonymous messaging platform designed for learning communities where users can send encrypted compliments and encouragement while maintaining strict privacy and accountability standards. The system implements role-based access control (RBAC), comprehensive audit logging, and advanced cryptographic security measures.

Core Mission

Build a role-based anonymous messaging platform that:

  • Allows users to send anonymous, encrypted compliments
  • Enforces strict role-based permissions for sending, receiving, flagging, and auditing
  • Supports logging and moderation without breaking anonymity
  • Prevents spam, message flooding, and identity abuse
  • Maintains privacy while offering traceability and accountability

System Roles

Role Capabilities
User (Sender/Recipient) Send encrypted anonymous messages, receive and decrypt messages, flag inappropriate content
Moderator View flagged messages, review audit logs, suspend users, freeze abusive tokens
Admin User management, role assignment, system statistics, audit log access (no message content access)
Idle Suspended or pending approval users

Technical Architecture

Tech Stack

  • Frontend: React + Vite, Material-UI, Zustand state management
  • Backend: Node.js + Express, Babel transpilation
  • Database: MongoDB with Mongoose ODM
  • Encryption: Web Crypto API (frontend), Node.js crypto (backend)
  • Authentication: JWT tokens with role-based middleware

Security Features

  • End-to-end encryption using RSA-OAEP with 2048-bit keys
  • Anonymous token system with unlinkable message attribution
  • Chunked encryption for messages larger than 190 bytes
  • Server-mediated moderation with encrypted flagged content
  • Tamper-proof audit logging with append-only design
  • Separation of duties preventing admins from accessing message content

Setup Instructions

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB Atlas account or local MongoDB instance
  • Git

Backend Setup

  1. Clone the repository
git clone <repository-url>
cd whisperchain/api
  1. Install dependencies
npm install
  1. Environment Configuration Create a .env file in the api directory:
PORT=9090
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/whisperchain
JWT_SECRET=your-jwt-secret-key
SERVER_PUBLIC_KEY=base64-encoded-server-public-key
SERVER_PRIVATE_KEY=base64-encoded-server-private-key
  1. Generate Server Keys
npm run generate-keys
  1. Start the server
npm start
npm run prod

Frontend Setup

  1. Navigate to client directory
cd ../client
  1. Install dependencies
npm install
  1. Environment Configuration Create a .env file in the client directory:
VITE_API_URL=http://localhost:9090/api
  1. Start the development server
npm run dev
npm start

API Endpoints

Authentication

  • POST /api/auth/register - New user registration
  • POST /api/auth/login - User authentication

Messaging (User Role) protected by requireAuth, requireRole(ROLES.USER)

  • POST /api/messages/send - Send encrypted message
  • GET /api/messages - Retrieve received messages
  • GET /api/messages/sent - View sent message history
  • POST /api/messages/flag - Flag/unflag inappropriate messages
  • POST /api/messages/markAsRead - Marks messages as read
  • POST /api/messages/unread/count - Returns unread message count
  • GET /api/auth/profile - User profile information
  • POST /api/auth/generateKeyPair - RSA key pair generation
  • GET /api/moderator/public-key - Get moderator public key
  • GET /api/auth/searchUsers - Search for users by email address

Moderation (Moderator Role) protected by requireAuth, requireModerator

  • GET /api/moderator/flaggedMessages - View flagged message queue
  • GET /api/moderator/flagged/count - Get number of flagged messages
  • POST /api/moderator/moderateMessage - Take moderation action
  • POST /api/moderator/freezeToken - Suspends the sender of a flagged message
  • GET /api/moderator/auditLogs - Access audit logs
  • POST /api/moderator/public-key - Set moderator public key
  • GET /api/moderator/flagged/count - Get flagged message count

Administration (Admin Role) protected by requireAuth, requireAdmin

  • POST /api/admin/setup - Create the admin account (only works once since there's only one admin)
  • POST /api/admin/addUser - Add new users
  • POST /api/admin/assignRole - Assign user roles
  • GET /api/admin/users - List all users
  • GET /api/admin/stats - Get platform basic overview (e.g., number of users, messages sent/received)
  • GET /api/admin/pendingUsers - View pending user mod requests
  • POST /api/admin/makeModeratorIdle - Pause Mod's access
  • POST /api/admin/reactivateModerator - Resume Mod's access

Usage Guide

For Users

  1. Registration: Sign up with email and request a role
  2. Key Generation: Generate RSA key pair for encryption
  3. Send Messages: Compose encrypted anonymous messages to other users
  4. Receive Messages: Decrypt and read messages in your inbox
  5. Flag Content: Report inappropriate messages to moderators

For Moderators

  1. Setup: Upload private key for decrypting flagged content
  2. Review Flags: Examine flagged messages in the moderation queue
  3. Take Action: Suspend users or freeze tokens for policy violations
  4. Audit Access: Review system audit logs for security monitoring

For Admins

  1. User Management: Approve pending registrations
  2. System Oversight: Monitor system statistics and health

Project Structure

whisperchain/
├── api/                          # Backend server
│   ├── src/
│   │   ├── controllers/          # API endpoint handlers
│   │   │   ├── admin_controller.js
│   │   │   ├── auth_controller.js
│   │   │   ├── crypto_controller.js
│   │   │   ├── message_controller.js   
│   │   │   ├── moderator_controller.js
│   │   │   └── verification_code_controller.js 
│   │   ├── models/              # Database schemas
│   │   │   ├── admin_model.js
│   │   │   ├── audit_log_model.js
│   │   │   ├── auth_token_model.js   
│   │   │   ├── flagged_messages_model.js
│   │   │   ├── message_model.js  
│   │   │   ├── user_model.js  
│   │   │   └── verification_code_model.js 
│   │   ├── services/            # Authentication and authorization
│   │   │   ├── auth_service.js    # authentication and authorization
│   │   │   └── email_service.js   # sends emails
│   │   ├── utils/               # Cryptography
│   │   │   ├── adminSetup.js    # admin setup
│   │   │   └── crypto.js        # crypto functions
│   │   ├── router.js           # Routes
│   │   └── server.js           # Application entry point
│   ├── package.json
│   └── .env
├── client/                       # Frontend application
│   ├── src/
│   │   ├── components/          # React components
│   │   │   ├── admin/
│   │   │   ├── chat/
│   │   │   ├── home/
│   │   │   ├── moderator/
│   │   │   ├── profile/
│   │   │   ├── shared-components/
│   │   │   ├── sign-in/
│   │   │   └── sign-up/
│   │   ├── utils/               # Client-side crypto utilities
│   │   ├── store/              # State management
│   │   │   ├── authSlice.js # auth
│   │   │   ├── index.js
│   │   │   └── userSlice.js # user
│   │   └── index.jsx             # Main application component
│   ├── package.json
│   └── .env
└── README.md

Security Implementation

Encryption Details

  • Algorithm: RSA-OAEP with SHA-256
  • Key Size: 2048-bit RSA keys
  • Chunking: Automatic splitting for messages >190 bytes
  • Format: PKCSS8 (private), RSA_PKCS1_OAEP_PADDING, OAEP encoding
  • Key Management: Public key for encryption, private key for decryptionSPKI (public), Base64 encoding

Anonymous Token System

  • Format: msg_${timestamp}_${nanoid(10)}
  • Properties: One-time use, unlinkable to user identity
  • Lookup: Sender identity only accessible through database token mapping

Audit Logging

  • Actions Tracked: User creation, role changes, message sending, flagging, moderation
  • Tamper Protection: Append-only design, modification prevention
  • Privacy Preservation: No sender identity logging, only role-level metadata

Features

Implemented Extensions

  • Unlinkable Token System: Anonymous message attribution without identity exposure
  • Server-Mediated Encryption: Secure moderator access to flagged content
  • Role-Based UI Adaptation: Interface changes based on user permissions
  • Comprehensive Audit Trail: Detailed logging while preserving anonymity

Security Measures

  • Admin Compromise Protection: Separation of duties, content access restrictions
  • Token Abuse Prevention: Freezing capability, usage tracking
  • Message Privacy: End-to-end encryption, no plaintext storage
  • Audit Integrity: Tamper-proof logging, append-only design

Testing

Security Validation

  • Role enforcement on all endpoints
  • Encryption/decryption roundtrip testing
  • Token unlinkability verification
  • Audit log tamper resistance

Functional Testing

  • Complete message workflow (send/receive/decrypt)
  • Flagging and moderation process
  • User management and role assignment
  • Cross-platform encryption compatibility

Threat Model

Identified Threats & Mitigations

  1. Admin Compromise

    • Mitigation: Separation of duties, admins cannot access message content
    • Audit: All admin actions logged with timestamps
  2. Token Sharing/Abuse

    • Mitigation: One-time use tokens, freezing capability
    • Detection: Monitoring for suspicious usage patterns
  3. Message Privacy Breach

    • Mitigation: End-to-end encryption, no server-side plaintext storage
    • Access Control: Only intended recipients can decrypt messages
  4. Audit Log Tampering

    • Mitigation: Append-only design, modification prevention
    • Integrity: Database-level constraints preventing alterations

System Analysis

Pros

Security Strengths

  • Strong Encryption: RSA-OAEP with 2048-bit keys provides robust protection
  • Anonymous Messaging: Unlinkable tokens preserve sender privacy
  • Role-Based Security: Strict RBAC prevents unauthorized access
  • Audit Trail: Comprehensive logging for accountability and forensics
  • Separation of Duties: Admins cannot access message content
  • Tamper-Proof Logs: Append-only design prevents log modification
  • End-to-End Encryption: No server-side plaintext storage
  • Comprehensive Logging: audit logs for accountability
  • One-time Verification Codes: only verified email addresses can access their account
  • Rate Limiting: wrong password lockout prevent brute force attacks

Usability Features

  • Intuitive Interface: Role-based UI adapts to user permissions
  • Automatic Key Management: Transparent encryption/decryption for users
  • Responsive Design: Works across desktop and mobile platforms
  • Real-time Updates: Live status indicators and notifications
  • Moderation Tools: Efficient flagging and review workflow

Technical Benefits

  • Scalable Architecture: Stateless API design supports horizontal scaling
  • Modern Tech Stack: React, Node.js, MongoDB for maintainability
  • Cross-Platform Compatibility: Web Crypto API and Node.js crypto interoperability
  • Production Ready: Comprehensive error handling and logging
  • Performance Optimized: Sub-100ms response times for most operations

Cons

Technical Limitations

  • RSA Performance: Slower than symmetric encryption, especially for large messages
  • Storage Overhead: Chunked encryption increases message size by ~35%
  • Key Management Complexity: Users must manage and backup private keys
  • Browser Dependency: Web Crypto API requires modern browser support
  • Single Point of Failure: Centralized server architecture

Usability Challenges

  • Key Recovery: No built-in mechanism for users' lost private keys
  • Password Management: No current implementation to reset passwords

Operational Concerns

  • Abuse Potential: Anonymous nature can be exploited for harassment
  • One-time Tokens: reduce convenience because you have to verify the 6-digit code every time you login

Known Vulnerabilities

Cryptographic Risks

  • Quantum Threat: RSA-2048 vulnerable to future quantum computers (Shor's algorithm)
  • Key Compromise: If private keys are stolen and your password and email are compromised, all received messages are vulnerable

System Architecture Vulnerabilities

  • Database Injection: MongoDB queries could be vulnerable to NoSQL injection
  • JWT Weaknesses: Token theft or replay attacks possible
  • Session Management: Concurrent sessions not properly managed
  • Memory Leaks: Cryptographic operations may leave sensitive data in memory

Operational Security Issues

  • Admin Privilege Escalation: Database access could allow role manipulation

Social Engineering Risks

  • Phishing Attacks: Users could be tricked into revealing private keys
  • Social Pressure: Coercion to reveal anonymous message senders
  • Moderator Compromise: Malicious moderators could abuse flagged content access
  • False Flag Operations: Malicious users could frame others for violations
  • Trust Exploitation: Users may overshare believing in system anonymity

Mitigation Strategies

Immediate Improvements

  • Rate Limiting: Implement API rate limiting to prevent DoS attacks
  • Key Rotation: Add support for periodic key rotation
  • Input Validation: Strengthen all user input validation and sanitization
  • Session Security: Implement proper session management and timeouts
  • Memory Protection: Clear sensitive data from memory after use

Long-term Enhancements

  • Post-Quantum Cryptography: Migrate to lattice-based or other quantum-resistant algorithms
  • Multi-Factor Authentication: Add support for multi-factor authentication
  • Encryption Strength: Upgrade to stronger encryption

Operational Security

  • Monitoring Enhancement: Implement advanced threat detection and response

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Implement changes with appropriate tests
  4. Ensure security requirements are met
  5. Submit a pull request with detailed description

License

MIT License

Support

For technical issues or questions about the system:

  1. Check the audit logs for system events
  2. Review the API documentation for endpoint usage
  3. Examine server logs for operational issues
  4. Consult the security documentation for threat mitigation
  5. Contact us

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages