Building a Secure Webmail Replacement, Why This Project Exists

Email remains the nervous system of modern digital life. Contracts, credentials, recovery links, legal notices, financial records, operational alerts, all flow through it. Yet the web interfaces most people use to access email were designed for a different threat landscape, a more trusting internet that no longer exists.

This project was born from a simple observation:

If your email is compromised, everything else eventually follows.

Not immediately. Not always noisily. But inevitably.


The Problem, Webmail as a High-Value Attack Surface

Traditional webmail systems prioritize usability, compatibility, and convenience. Security is often layered on afterward rather than engineered as the primary constraint.

Common weaknesses include:

  • Large client-side codebases exposed to the public internet
  • Legacy authentication models
  • Session management weaknesses
  • Plugin ecosystems of varying quality
  • Insufficient isolation between users
  • Weak assumptions about network trust
  • Poor resilience against phishing-assisted account takeover
  • Limited protection against credential replay and token theft

Even when the mail server itself is hardened, the web interface can become the soft underbelly.

In many environments, especially self-hosted systems, the webmail component represents the largest externally exposed attack surface of the entire stack.


Why Not Just Use Hosted Email?

Outsourcing email to a cloud provider transfers risk, it does not eliminate it.

Hosted solutions introduce their own concerns:

  • Loss of data sovereignty
  • Dependence on third-party security posture
  • Legal exposure to foreign jurisdictions
  • Surveillance and data mining risks
  • Vendor lock-in
  • Limited visibility into actual security controls
  • Inability to apply organization-specific defensive measures

For individuals and organizations with elevated security requirements, these tradeoffs are often unacceptable.

Self-hosting remains the only way to maintain full control. But self-hosting must be done correctly.


The Hidden Weakness, “Secure Infrastructure” with an Insecure Interface

Many administrators invest heavily in securing the backend:

  • Hardened operating systems
  • Strict firewall rules
  • Intrusion detection
  • Spam filtering and malware scanning
  • Encrypted transport
  • Regular patching

Yet the webmail frontend frequently remains a general-purpose application designed for mass deployment.

This creates a paradox:

The core system may be engineered for resilience, but the user entry point is optimized for convenience.

Attackers will always target the weakest link, and webmail is attractive because it provides:

  • Direct credential entry
  • High-value data access
  • Persistent sessions
  • Browser-exposed attack vectors
  • Opportunities for social engineering
  • A path to lateral movement

The VPN Myth, “It’s Safe Because It’s Internal”

A common mitigation is restricting webmail access to a private network or VPN. This is helpful, but not sufficient.

Modern threat models assume:

  • Endpoints may already be compromised
  • VPN credentials can be stolen
  • Insider threats exist
  • Malware operates inside trusted networks
  • Phishing bypasses perimeter controls

In other words:

Trust boundaries have shifted from networks to identities and devices.

A secure system must assume that an attacker can eventually appear “inside.”


Project Goals

This project aims to build a secure webmail service designed from the ground up for hostile environments, not benign ones.

1. Zero-Trust Assumptions

No component, network location, or user context is implicitly trusted.

Access decisions should consider:

  • Strong authentication
  • Device posture where possible
  • Session integrity
  • Behavioral anomalies
  • Least privilege

2. Minimized Attack Surface

Reduce exposed functionality to only what is necessary.

  • Remove unused features
  • Avoid plugin sprawl
  • Limit external dependencies
  • Constrain browser-exposed capabilities
  • Harden input handling

Complexity is the enemy of security.


3. Strong Authentication Everywhere

Email access should require more than a password.

Support for multi-factor authentication, especially time-based one-time passwords, is essential. Client compatibility matters as well, not all mail applications handle advanced authentication gracefully, so the design must accommodate real-world usage patterns.


4. Defense Against Account Takeover

Even with MFA, attackers attempt:

  • Session hijacking
  • Token replay
  • Phishing proxies
  • Malware-assisted access

Protections should include:

  • Session binding controls
  • Reauthentication for sensitive actions
  • Anomaly detection
  • Short-lived credentials
  • Visibility into active sessions

5. Privacy and Data Control

Users must retain ownership of their communications.

  • No external data harvesting
  • No hidden telemetry
  • No opaque third-party dependencies
  • Full control over storage and retention

6. Operational Transparency

Administrators need clear insight into system behavior:

  • Security logs that are actually useful
  • Evidence of attempted intrusions
  • Verification that protections are functioning
  • Auditability of configurations

Security without visibility is merely optimism.


Why a New Approach Is Necessary

Retrofitting security onto legacy systems eventually reaches diminishing returns. At some point, it becomes safer and more effective to design specifically for the threat model rather than against it.

Modern adversaries are persistent, automated, and economically motivated. Email accounts enable:

  • Identity theft
  • Financial fraud
  • Business compromise
  • Credential resets for other services
  • Intelligence gathering
  • Long-term surveillance

Protecting email is therefore protecting everything connected to it.


Intended Use Cases

This project targets environments where compromise has disproportionate consequences:

  • Security professionals
  • Consultants handling sensitive client data
  • Small organizations without enterprise resources
  • High-net-worth individuals
  • Activists and journalists
  • Operators of self-hosted infrastructure
  • Anyone who cannot tolerate silent account takeover

Security as a Primary Feature, Not an Add-On

Convenience sells products. Security preserves systems.

The goal is not to create the most feature-rich webmail platform, but the most defensible one that remains usable in daily operations.

Success will be measured by how few vulnerabilities are exposed, not how many features are included.


Formal Project Charter

Mission:
Design and deploy a defensible webmail system suitable for hostile internet environments.

Objectives:

  • Provide secure browser-based email access without expanding attack surface
  • Resist credential theft and account takeover
  • Maintain data sovereignty
  • Operate independently of third-party control planes
  • Support modern authentication mechanisms
  • Remain operationally maintainable by a small team

Non-Goals:

  • Consumer-grade convenience features
  • Broad plugin ecosystems
  • Tight coupling to proprietary cloud services
  • Feature parity with large commercial platforms

Success Criteria:

  • Demonstrable reduction in externally reachable attack surface
  • No unauthenticated access to sensitive functionality
  • Resistance to common web exploitation classes
  • Clear forensic visibility after incidents
  • Predictable operational behavior

Threat Model (OWASP / NIST Aligned)

Adversaries

  • Opportunistic internet scanners
  • Credential stuffing operators
  • Phishing actors
  • Targeted attackers
  • Malicious insiders
  • Supply chain compromise actors

Assets

  • Email content and attachments
  • Authentication credentials
  • Session tokens
  • Address books and metadata
  • Administrative interfaces
  • Encryption keys

Attack Vectors

  • Web application vulnerabilities
  • Authentication bypass
  • Session hijacking
  • Cross-site scripting
  • CSRF
  • Password reuse attacks
  • Malicious file handling
  • Dependency compromise

Assumed Capabilities

Attackers may:

  • Observe network traffic
  • Deliver phishing payloads
  • Operate from inside trusted networks
  • Exploit browser vulnerabilities
  • Replay captured tokens
  • Attempt lateral movement after initial access

Security Objectives

  • Confidentiality of communications
  • Integrity of stored data
  • Availability of service
  • Non-repudiation of administrative actions
  • Containment of compromised accounts

Technical Architecture Overview

A defensible webmail system should adopt layered isolation:

Frontend Layer

  • Minimal browser client
  • Strict content security policies
  • Hardened session management
  • Limited scripting surface

Application Layer

  • Strong authentication gateway
  • Authorization enforcement
  • Input validation
  • Secure file handling

Mail Integration Layer

  • IMAP/SMTP access via constrained interfaces
  • Credential isolation from backend systems
  • Rate limiting and abuse controls

Infrastructure Layer

  • Network segmentation
  • Firewall enforcement
  • Intrusion detection
  • Logging pipelines

Administrative Plane

  • Separate authentication domain
  • Restricted network access
  • Audit logging

No single compromise should expose the entire system.


Comparison, Why Not Use Traditional Webmail Platforms

Common general-purpose webmail solutions were designed for wide compatibility and ease of deployment, not adversarial resilience.

Typical limitations include:

  • Large codebases with historical baggage
  • Extensive plugin ecosystems
  • Shared hosting assumptions
  • Weak isolation boundaries
  • Limited protection against modern account takeover techniques

A purpose-built system can eliminate entire classes of risk by refusing to implement unnecessary features.


Zero-Trust Deployment Blueprint

A secure deployment assumes that compromise can occur at any layer.

Access Controls

  • Require multi-factor authentication for all users
  • Enforce strong password policies
  • Rate limit authentication attempts
  • Detect anomalous login behavior

Network Controls

  • Restrict exposure to only required services
  • Prefer private access paths when possible
  • Monitor for unusual traffic patterns

Session Security

  • Short session lifetimes
  • Token rotation
  • Reauthentication for sensitive operations
  • Immediate revocation capability

Endpoint Considerations

  • Assume some clients are compromised
  • Avoid persistent trust in devices
  • Limit damage from session theft

Monitoring and Response

  • Centralized logging
  • Alerting on suspicious activity
  • Ability to quarantine accounts
  • Forensic readiness

Final Thoughts

Email is still the master key to digital identity. Treating its interface as an ordinary web application is no longer adequate.

A secure email web service must assume that:

  • Attackers are capable
  • Compromise attempts are constant
  • Network boundaries are porous
  • Users are human
  • Failures will occur

The objective is not perfect security, which does not exist, but controlled failure that does not cascade into total compromise.

This project exists because the status quo assumes benign conditions.

Reality does not.

A defensible system must be designed for the internet as it actually is, not as it used to be.

project GitHub is found at unattributed/OSMAP backend secure mail service project GitHub is found at https://github.com/unattributed/openbsd-mailstack