Architecture Dictates Security
When most people think about website security, they think about firewalls, encryption, and passwords. These are important, but they are surface-level defenses. The single most impactful decision for your website's security is made long before anyone configures a firewall: it is the architecture decision.
A dynamic website (WordPress, Drupal, custom PHP/Node.js applications) runs server-side code on every request. It connects to a database. It has an admin panel. It processes user input. Each of these capabilities is also an attack vector. A static website has none of these components. It is a collection of pre-built HTML, CSS, and JavaScript files served directly by a CDN or a simple web server. No database. No server-side code execution. No admin panel exposed to the internet.
The security difference between these two approaches is not marginal. It is fundamental. In this article, we will compare the attack surfaces of static and dynamic sites, explain which vulnerability classes each eliminates, and help you determine which architecture fits your needs.
Understanding the Attack Surface
What Is an Attack Surface?
The attack surface of a system is the total number of points where an attacker can try to enter or extract data. For a website, this includes:
- Every URL that accepts user input
- Every form that processes data
- Every API endpoint
- Every authentication mechanism
- Every database connection
- Every server-side process running in memory
- Every third-party dependency loaded by the server
A smaller attack surface means fewer opportunities for an attacker. The goal of secure architecture is to minimize the attack surface while still delivering the functionality you need.
Dynamic Site Attack Surface
A typical WordPress installation exposes the following attack surface:
| Component | Attack Vectors | Risk Level |
|---|---|---|
| PHP runtime | Remote code execution, file inclusion, deserialization | Critical |
| MySQL database | SQL injection, data exfiltration, privilege escalation | Critical |
| wp-admin panel | Brute force, credential stuffing, session hijacking | High |
| Plugin code | All of the above, plus supply chain compromise | Critical |
| Theme code | XSS, template injection, file upload bypass | Medium-High |
| XML-RPC | Brute force amplification, DoS | Medium |
| REST API | Information disclosure, authentication bypass | Medium |
| File uploads | Shell upload, directory traversal | High |
| Cron system | Resource exhaustion, timing attacks | Low-Medium |
That is nine distinct attack categories, each containing multiple specific vulnerabilities. We covered many of these in detail in our article on WordPress vulnerabilities in 2025.
Static Site Attack Surface
A static site served from a CDN exposes:
| Component | Attack Vectors | Risk Level |
|---|---|---|
| HTML/CSS/JS files | XSS (if user-generated content is included at build time) | Low |
| CDN configuration | Cache poisoning, misconfigured headers | Low |
| Build pipeline | Supply chain compromise (build dependencies) | Medium |
| DNS | DNS hijacking, subdomain takeover | Medium |
Four categories, most of them low risk. The build pipeline and DNS risks exist for dynamic sites too, so the net reduction is enormous.
Vulnerability Classes Eliminated by Static Sites
SQL Injection: Gone
SQL injection is consistently ranked in the OWASP Top 10. It occurs when user input is inserted into a database query without proper sanitization. With a static site, there is no database to inject into. The vulnerability class simply does not exist.
No database means no SELECT * FROM users WHERE id = ' OR 1=1 --. No stored procedures to exploit. No data to exfiltrate through UNION SELECT statements. The entire category of attacks targeting databases disappears from your threat model.
Remote Code Execution: Gone
RCE vulnerabilities allow an attacker to execute arbitrary code on your server. They typically exploit flaws in server-side languages (PHP's eval(), Node.js's child_process, Python's pickle). With a static site, there is no server-side runtime processing requests. The CDN serves files, nothing more. There is no PHP interpreter to exploit, no Node.js process to inject into, no Python runtime to abuse.
Server-Side Request Forgery (SSRF): Gone
SSRF attacks trick a server into making requests to internal resources. An attacker might cause your web server to query internal APIs, metadata endpoints (like AWS EC2 instance metadata at 169.254.169.254), or other services behind the firewall. With no server-side code, there is nothing to trick into making requests.
Authentication Bypass: Gone
If your site has no admin panel, there is no authentication to bypass. No login page means no brute force attacks, no credential stuffing, no session hijacking, no password reset exploits. We discuss the specific risks of exposed login pages in our article on exposed admin pages.
File Upload Vulnerabilities: Gone
Dynamic sites that accept file uploads (profile pictures, documents, media) risk accepting malicious files that execute server-side code. Static sites don't accept file uploads at the server level. Any file upload functionality would be handled by a separate, purpose-built service with its own security controls.
Session Management Flaws: Gone
Session fixation, session hijacking, insecure session storage: these all require server-side session management. Static sites are sessionless by default. If user authentication is needed, it can be handled through a separate authentication service (like Auth0 or Firebase Auth) with a minimal, well-audited attack surface.
What Static Sites Cannot Do (And the Workarounds)
User Authentication
Static sites don't natively support user login. If you need authenticated areas, you have options:
- Third-party auth services: Auth0, Firebase Auth, Clerk, or Supabase Auth handle authentication securely. Your static site delegates the entire auth flow to a service that specializes in it.
- Serverless functions: Platforms like Cloudflare Workers, AWS Lambda, or Netlify Functions let you add small server-side endpoints without deploying a full server. You get the benefits of static for 95% of your site, with targeted server-side logic where needed.
Dynamic Content
Need a search function? Product filtering? Real-time data? Options include:
- Client-side JavaScript: For small datasets, load the data as JSON and filter in the browser.
- External APIs: Call a dedicated API service from client-side JavaScript. The API can be a managed service (Algolia for search, Stripe for payments) or a custom serverless function.
- Incremental Static Regeneration (ISR): Some frameworks (Next.js, Astro) support regenerating individual pages at defined intervals, combining static performance with near-real-time content.
Content Management
Non-technical users need to edit content without touching code. Headless CMS solutions solve this:
- Git-based CMS: Decap CMS (formerly Netlify CMS), Tina CMS, or Forestry let editors make changes through a web interface that commits to Git. The site rebuilds automatically.
- API-based CMS: Contentful, Sanity, Strapi, or Directus provide a content editing interface. Content is delivered via API at build time or runtime.
The key insight is that the CMS (the editing interface) is separated from the website. Even if the CMS has a vulnerability, the public-facing website remains static and secure.
The Jamstack Architecture
What Jamstack Means
Jamstack (JavaScript, APIs, Markup) is the architectural pattern that formalizes the static site approach for modern web development. The core principles are:
- Pre-rendering: Pages are generated at build time, not on each request.
- Decoupling: The frontend is separated from backend services.
- CDN-first: Static assets are distributed globally through a CDN.
Popular Jamstack frameworks include Astro, Next.js (with static export), Nuxt, Hugo, Eleventy, and Gatsby. For a deeper exploration of modern web architecture choices, see our article on modern web architecture.
Jamstack Security Benefits
- No origin server to attack: Traffic goes to CDN edge nodes, not to your server.
- Immutable deployments: Each build produces a complete, self-contained set of files. Rollback means pointing to a previous build, not restoring a database.
- Reduced blast radius: If one external service is compromised, the rest of the site continues to function. Contrast this with a monolithic application where a database breach takes down everything.
- Simplified infrastructure: No servers to patch, no runtimes to update, no database backups to manage. The hosting platform handles all of this.
CDN Distribution: Security Through Architecture
DDoS Resilience
Dynamic websites are vulnerable to DDoS attacks because each request requires server-side processing. A flood of requests can overwhelm the server's CPU, memory, or database connections. Static sites served from a CDN distribute this load across hundreds of edge nodes worldwide. Major CDN providers (Cloudflare, Fastly, AWS CloudFront) have DDoS mitigation built in at the network level. They can absorb traffic volumes that would flatten any single-server setup.
Geographic Distribution
CDN edge nodes serve cached content from the location nearest to the user. This means:
- Faster load times (important for user experience and SEO)
- No single point of failure
- Automatic failover if one edge node goes down
- Content remains available even if the origin is offline (for static sites, the "origin" is just the build output uploaded to the CDN)
HTTPS by Default
All major CDN/hosting platforms (Cloudflare Pages, Netlify, Vercel, AWS Amplify) provide free, automatically renewed TLS certificates. HTTPS is not an add-on; it is the default. This eliminates an entire class of configuration errors (mixed content, expired certificates, weak cipher suites) that plague manually managed servers.
When You Still Need Dynamic
Static architecture is not the right choice for everything. You need dynamic capabilities when:
- Real-time interactivity: Chat applications, collaborative editing, live dashboards require WebSocket connections or server-sent events.
- Complex transactions: E-commerce checkout flows with inventory management, payment processing, and order fulfillment need server-side logic.
- User-generated content at scale: Social platforms, forums, or marketplaces where users create and interact with content in real time.
- Personalization: Sites that show different content to different users based on their profile, preferences, or behavior (though this can often be handled client-side).
Even in these cases, you can often adopt a hybrid approach: static for the public-facing pages, dynamic only for the interactive features. This minimizes the attack surface while delivering the functionality you need. For a comparison of WordPress and Jamstack approaches, see our article on WordPress vs. Jamstack.
Cost Comparison
Security aside, static sites are dramatically cheaper to operate:
| Factor | Dynamic (WordPress) | Static (Jamstack) |
|---|---|---|
| Hosting | $10-50/month (shared) to $100+/month (VPS/managed) | $0-20/month (often free tier) |
| SSL certificate | $0-100/year (Let's Encrypt or paid) | $0 (automatic, included) |
| CDN | $20-200/month (additional service) | $0 (included by default) |
| Security plugins/WAF | $100-300/year | Not needed |
| Maintenance updates | 2-5 hours/month | Near zero |
| Backup management | 1-2 hours/month + storage costs | Git history (free) |
A static site on Cloudflare Pages or Netlify's free tier costs literally nothing to host. A WordPress site with proper security (managed hosting, WAF, backup service, maintenance time) costs $200-500+ per month when you factor in everything.
Migration Path: From Dynamic to Static
If you're currently running a dynamic site (especially WordPress) and want to migrate to a static architecture, here is the general path:
- Content audit: Catalog every page, form, and interactive feature on your current site.
- Feature classification: Categorize each feature as "static" (can be pre-built) or "dynamic" (needs server-side logic).
- Technology selection: Choose a static site generator (Astro is our current recommendation for most business sites) and headless CMS (if non-technical editors need access).
- Design migration: Rebuild the frontend with the new framework. This is a good time to improve the design and performance.
- Content migration: Move content from the old CMS to the new one. For WordPress, plugins can export content to markdown or JSON.
- Dynamic feature replacement: Replace contact forms with services like Formspree or Netlify Forms. Replace search with Algolia or Pagefind. Replace comments with Disqus or a custom solution.
- DNS cutover: Point your domain to the new hosting platform.
Conclusion
The architecture of your website is its most important security decision. A static site eliminates SQL injection, remote code execution, authentication bypass, file upload attacks, and session management flaws by simply not having the components these attacks target. It is not security through obscurity; it is security through absence of vulnerability.
For informational websites, company sites, portfolios, blogs, and documentation, static architecture is the clear winner on security, performance, and cost. For applications requiring real-time interactivity or complex transactions, a hybrid approach offers the best balance.
If you're evaluating your website's architecture and want to understand the security implications of different approaches, contact our team. We help businesses in Lugano and across Switzerland build web presences that are secure by design, not by afterthought.
Want to know if your site is secure?
Request a free security audit. In 48 hours you get a complete report.
Request Free Audit