WhisperChain+: Anonymous Messaging with Role-Based Control and Accountability
by Cameron Keith and Jacob Zhang
Spring 2025
Professor Sami Saydjari, Mohamed Moustafa Dawoud
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.
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
| 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 |
- 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
- 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
- Node.js (v16 or higher)
- MongoDB Atlas account or local MongoDB instance
- Git
- Clone the repository
git clone <repository-url>
cd whisperchain/api- Install dependencies
npm install- Environment Configuration
Create a
.envfile in theapidirectory:
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- Generate Server Keys
npm run generate-keys- Start the server
npm startnpm run prod- Navigate to client directory
cd ../client- Install dependencies
npm install- Environment Configuration
Create a
.envfile in theclientdirectory:
VITE_API_URL=http://localhost:9090/api- Start the development server
npm run devnpm startPOST /api/auth/register- New user registrationPOST /api/auth/login- User authentication
POST /api/messages/send- Send encrypted messageGET /api/messages- Retrieve received messagesGET /api/messages/sent- View sent message historyPOST /api/messages/flag- Flag/unflag inappropriate messagesPOST /api/messages/markAsRead- Marks messages as readPOST /api/messages/unread/count- Returns unread message countGET /api/auth/profile- User profile informationPOST /api/auth/generateKeyPair- RSA key pair generationGET /api/moderator/public-key- Get moderator public keyGET /api/auth/searchUsers- Search for users by email address
GET /api/moderator/flaggedMessages- View flagged message queueGET /api/moderator/flagged/count- Get number of flagged messagesPOST /api/moderator/moderateMessage- Take moderation actionPOST /api/moderator/freezeToken- Suspends the sender of a flagged messageGET /api/moderator/auditLogs- Access audit logsPOST /api/moderator/public-key- Set moderator public keyGET /api/moderator/flagged/count- Get flagged message count
POST /api/admin/setup- Create the admin account (only works once since there's only one admin)POST /api/admin/addUser- Add new usersPOST /api/admin/assignRole- Assign user rolesGET /api/admin/users- List all usersGET /api/admin/stats- Get platform basic overview (e.g., number of users, messages sent/received)GET /api/admin/pendingUsers- View pending user mod requestsPOST /api/admin/makeModeratorIdle- Pause Mod's accessPOST /api/admin/reactivateModerator- Resume Mod's access
- Registration: Sign up with email and request a role
- Key Generation: Generate RSA key pair for encryption
- Send Messages: Compose encrypted anonymous messages to other users
- Receive Messages: Decrypt and read messages in your inbox
- Flag Content: Report inappropriate messages to moderators
- Setup: Upload private key for decrypting flagged content
- Review Flags: Examine flagged messages in the moderation queue
- Take Action: Suspend users or freeze tokens for policy violations
- Audit Access: Review system audit logs for security monitoring
- User Management: Approve pending registrations
- System Oversight: Monitor system statistics and health
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
- 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
- Format:
msg_${timestamp}_${nanoid(10)} - Properties: One-time use, unlinkable to user identity
- Lookup: Sender identity only accessible through database token mapping
- 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
- 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
- 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
- Role enforcement on all endpoints
- Encryption/decryption roundtrip testing
- Token unlinkability verification
- Audit log tamper resistance
- Complete message workflow (send/receive/decrypt)
- Flagging and moderation process
- User management and role assignment
- Cross-platform encryption compatibility
-
Admin Compromise
- Mitigation: Separation of duties, admins cannot access message content
- Audit: All admin actions logged with timestamps
-
Token Sharing/Abuse
- Mitigation: One-time use tokens, freezing capability
- Detection: Monitoring for suspicious usage patterns
-
Message Privacy Breach
- Mitigation: End-to-end encryption, no server-side plaintext storage
- Access Control: Only intended recipients can decrypt messages
-
Audit Log Tampering
- Mitigation: Append-only design, modification prevention
- Integrity: Database-level constraints preventing alterations
- 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
- 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
- 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
- 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
- Key Recovery: No built-in mechanism for users' lost private keys
- Password Management: No current implementation to reset passwords
- 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
- 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
- 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
- Admin Privilege Escalation: Database access could allow role manipulation
- 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
- 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
- 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
- Monitoring Enhancement: Implement advanced threat detection and response
- Fork the repository
- Create a feature branch
- Implement changes with appropriate tests
- Ensure security requirements are met
- Submit a pull request with detailed description
MIT License
For technical issues or questions about the system:
- Check the audit logs for system events
- Review the API documentation for endpoint usage
- Examine server logs for operational issues
- Consult the security documentation for threat mitigation
- Contact us