Quasar Secure — Technical Audit & Zero-Trust Architecture Analysis
1. Executive Summary & Core Paradigm
Quasar Secure is a secure real-time communication platform engineered under Zero-Trust principles. Departing from typical web chat designs, Quasar utilizes multi-layered cryptography to guarantee confidentiality: communications (audio, video, screen-sharing) utilize Direct P2P WebRTC tunnels, while application state, profiles, messages, and files are stored fully encrypted at rest. An extensive source audit of the repository reveals undocumented security defenses at both system and application layers.
2. Real-Time File Integrity Monitoring (FIM)
To prevent runtime tampering of the Node.js application process, Quasar implements a strict, continuous File Integrity Monitor (FIM) inside its production initialization sequence (backend/index.js):
- // ROOT PRIVILEGE PROHIBITION: The server checks
process.getuid() === 0at startup. If executed as root, it immediately terminates (process.exit(1)) to limit potential container breakouts or host compromise. - // FS.WATCH REAL-TIME DAEMON: In production, the backend initiates
fs.watch()handlers over critical core files:index.js,auth.js, andconfig.js. The moment any modification event is detected, the server logs a critical alert and triggers an instant self-destruct shutdown, neutralizing dynamic cold-patch injections.
3. Dual-Method Cryptographic Authentication
Quasar provides dual-layer protection for administrative credentials, protecting the backend endpoints:
- // TIMING-ATTACK RESISTANT HASHER: Standard passwords are hashed and validated at
/login. The verification utilizescrypto.timingSafeEqualvia theAuthModule.safeCompareHasheshelper. If the input and stored hashes differ in length, the system executes a dummy timing-safe comparison against the stored hash itself to guarantee constant execution time, preventing timing-leakage side-channel attacks. - // RSA CHALLENGE-RESPONSE PROTOCOL: For passwordless administration, the system implements an asymmetric challenge-response flow. The client requests a cryptographically secure 32-byte hex challenge from
/admin/challenge(valid for 60s). The client must sign this challenge with their RSA Private Key and POST it to/admin/verify. The server validates the signature using the pre-loadedadmin_public.pemviacrypto.verify("sha256", challenge, key, signature)before setting a strict HttpOnly, SameSite=Strict session cookie.
4. Database Encryption at Rest & WAL Optimizations
Quasar relies on an SQLite database backed by better-sqlite3. To ensure that database file extraction yields zero readable data, symmetric database encryption is applied:
- // CRYPTOGRAPHIC KEY DERIVATION (KDF): Instead of using the raw
DB_SECRET, the application passes it through a Key Derivation Function:crypto.scryptSync(secret, 'secure_salt_quasar', 32)to output a 256-bit symmetric key. - // COLUMN-LEVEL AES-256-CBC ENCRYPTION: Sensitive database fields are encrypted via
aes-256-cbcwith random 16-byte IV vectors prepended (format:iv:ciphertext). Sensitive data includesusername_encandavatar_encin theuserstable,payload_encin themessagestable, andfilename_encin theuploaded_filestable. - // WAL & SYNCHRONOUS TUNING: To maintain high-performance messaging under constant read-writes, SQLite journal mode is set to Write-Ahead Logging (
db.pragma('journal_mode = WAL')) and the synchronous mode is set toNORMAL, yielding stable performance without risk of corruption.
5. Encrypted File Streaming & Traversal Mitigation
File transfers are end-to-end encrypted (E2EE) and isolated from the host filesystem structure:
- // ENCRYPTED UPLOAD FLOW: Uploading to
/uploadrequires a valid JWT. The client sends custom headers:x-file-iv,x-file-name, andx-file-type. The server validates size limitations (up to 10MB) dynamically, streams the encrypted payload into a random UUID v4 filename insidedata/uploads/, and encrypts the metadata (filename) in the database usingencryptDB(). - // PATH TRAVERSAL DEFEAT: The download endpoint
/file/:idvalidates the file ID against a formal UUID v4 regular expression:/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i. Any path traversal attempt (e.g.../../etc/passwd) is blocked at the routing layer with a 400 Bad Request.
6. Automated Garbage Collection & DB Sanitization
To maintain a low footprint and secure volatile state, the server runs a background job every 30 minutes:
// Runs SQLite VACUUM to reclaim disk sectors and scrub fragments
7. Signaling Orchestration & Frontend Sanitization
Beyond server infrastructure, the frontend client introduces unique features and DOM XSS mitigations:
- // SECURE USER LIST IMAGE PROTOCOLS: To prevent persistent XSS via bad image attributes (e.g.
onerrororjavascript:execution in profile cards), the ReactUserList.jsxcomponent filters incoming user avatars. It parses the URL, validating that the protocol matcheshttp:,https:, or safedata:image/schemes, falling back to a safe neutral avatar upon mismatch. - // MULTI-STREAM SIGNALING: The socket connection separates media signaling into three standard scopes: WebRTC audio/video connections (
signal), multi-recipient screen sharing (screen_signal), and synchronized media streaming (music_sync) to coordinate live client playback.
Quasar Secure — Beyond Cryptography: Architectural Hardening & Vulnerability Mitigation
1. The Core Thesis: Why Strong Crypto is Never Enough
A common pitfall in secure software engineering is relying solely on cryptographic algorithms to secure a system. An application can employ mathematically flawless AES-GCM or RSA-4096 tunnels, yet remain entirely vulnerable to compromise if its architectural foundation is weak. If an attacker can exploit a Path Traversal bug to read the server's .env configuration file, they will extract the raw database keys and JWT secrets, rendering the database encryption useless. If the process runs with root privileges, any remote code execution (RCE) grants host takeover. If the UI lacks protocol sanitization, an attacker can bypass encryption entirely by injecting an XSS payload that exfiltrates decrypted messages straight from client memory. Quasar's design demonstrates that true security is a function of system-wide architectural hardening.
2. OS Execution Hardening & System Restraints
Quasar implements defenses at the boundary between the application and the host operating system, reducing the potential impact of exploits:
- // PRIVILEGE REDUCTION & CONTAINER SECURITY: The server checks
process.getuid() === 0at startup. If executed inside a root context, it immediately aborts. This prevents attackers from gaining full root access to the host kernel or docker host interface if they find an application exploit, suppressing privilege escalation vectors. - // DYNAMIC RUNTIME TAMPER MITIGATION (FIM): Memory injection and hot-patching are active threats to Node.js servers. The continuous
fs.watch()daemon monitors core modules. If any script is altered on disk or dynamic patch attempts are made, the server shuts down immediately. This mitigates persistent server-side malware implants.
3. Sandboxed File Operations & Sandboxed Routing
File uploads are high-risk entry points. Quasar sandboxes files on disk and isolates them at the routing level to mitigate path traversals and arbitrary system reading:
- // FILENAME SANITIZATION & METADATA SEPARATION: When a file is uploaded, the original name is encrypted in the SQLite DB. On disk, the file is saved under a cryptographically random UUID v4 string (e.g.
data/uploads/9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d). This destroys the original extension and name, blocking attackers from uploading executable scripts (e.g..jsor.php) and triggering them on the host. - // REGEX UUID PATH TRAVERSAL DEFENSE: The download route
/file/:idutilizes a strict UUID validation regex:/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i. If an attacker submits a path-traversal request (e.g./file/../../.env), the server rejects it at the regex layer, preventing unauthorized system file extraction.
4. API Rate Limiting & Denial of Service (DoS) Hardening
To prevent memory depletion and application lockups caused by abuse, Quasar includes active DoS protection mechanisms:
- // SLIDING-WINDOW API LIMITER: The socket.io handlers and authentication routes are bounded by sliding-window rate limit maps. IPs that exceed 5 events per second are temporarily throttled, neutralizing brute-force password checking and automated message flooding.
- // STREAM BUFFER SIZE RESTRICTION: Upload streams are dynamically bounded. The server monitors incoming chunks in real-time, aborting the request, destroying the active write stream, and deleting the temporary disk buffer instantly if the upload size exceeds
MAX_UPLOAD_BYTES. This mitigates RAM starvation and disk-fill attacks.
5. DOM-Level Sanitization & XSS Prevention
Cross-Site Scripting (XSS) is a critical threat to E2EE chats. If an attacker can inject and run JavaScript inside another client's browser, they can extract the E2EE keys or read raw chat texts directly. Quasar mitigates this through defensive measures:
- // PROTOCOL WHITELIST FILTERING: To prevent malicious URLs from injecting javascript (e.g.
<img src="javascript:alert(1)">) inside user avatar links, the React componentUserList.jsxparses and checks incoming links against strict protocol schemes (http:,https:, and safedata:image/types), stripping malicious protocols instantly. - // GLOBAL CONTENT-SECURITY-POLICY (CSP) RESTRICTIONS: The backend applies strict CSP headers on every request. Scripts can only be executed if they originate from
'self'or strict verified CDNs. Object injections are disabled (object-src 'none'), base URI modifications are banned (base-uri 'none'), and framing is completely disabled (X-Frame-Options: DENY) to prevent Clickjacking and script injection bypasses.