Web Security Guide for Heroku

Heroku provides a solid foundation for deploying web applications, but securing your app requires attention to multiple layers. This guide covers the essential security measures every Heroku application should implement.

Defense in Depth with Expedited WAF

The most effective security strategy uses multiple layers of protection. Expedited WAF sits in front of your Heroku application, filtering malicious traffic before it reaches your code.

Defense in depth: Browser, Expedited WAF, and Heroku protect your application data

This approach means that even if your application has a vulnerability or misconfiguration, many attacks will be blocked at the network edge before they can cause damage.

Encrypt All Traffic

HTTPS is non-negotiable for modern web applications. It protects data in transit and is required for many browser features.

Force HTTPS Connections

Ensure all traffic uses HTTPS by redirecting HTTP requests and setting HSTS headers. This prevents downgrade attacks and protects user data.

Enable HTTP/2

HTTP/2 improves performance and security. It requires HTTPS and provides multiplexing, header compression, and server push.

Security Headers

HTTP security headers tell browsers how to handle your content securely. Missing headers leave your application vulnerable to XSS, clickjacking, and other attacks.

Key headers to implement:

  • Content-Security-Policy - Controls which resources the browser can load
  • X-Frame-Options - Prevents clickjacking attacks
  • X-Content-Type-Options - Stops MIME type sniffing
  • Strict-Transport-Security - Enforces HTTPS connections
  • Referrer-Policy - Controls referrer information leakage

Expedited WAF can add these headers automatically, or see our detailed guide:

Block Malicious Traffic

IP Address Blocking

Block known bad actors, abusive IP ranges, or restrict access to specific regions.

User Agent Filtering

User agents are trivially spoofable, but blocking known bad user agents still eliminates a large percentage of automated attacks, vulnerability scanners, and unwanted bots.

With smartphones, the number of legitimate browser user agents has exploded and changes daily. Expedited WAF maintains a real-time updated list of legitimate browser user agents, available with one click.

Anonymous Proxy Blocking

Traffic from VPNs, Tor exit nodes, and anonymous proxies is disproportionately associated with fraud and abuse. Block or challenge this traffic to reduce risk.

Referrer-Based Blocking

Block traffic from spam referrers, competitor scrapers, or sites hotlinking your assets.

DDoS and Bot Protection

Stop DDoS Attacks

Distributed denial of service attacks can overwhelm your application. Expedited WAF provides multiple mitigation strategies:

  • CAPTCHA Challenges - Verify human users during attacks
  • JavaScript Verification - Block simple bots that can’t execute JavaScript
  • Rate Limiting - Throttle excessive requests from single sources

Learn more:

Block Malicious Bots

Not all bots are friendly. Credential stuffing bots, content scrapers, and vulnerability scanners constantly probe web applications.

Application Security

Prevent Common Vulnerabilities

The OWASP Top 10 represents the most critical web application security risks. Understanding and mitigating these vulnerabilities is essential.

Cross-Site Scripting (XSS) Protection

XSS attacks inject malicious scripts into your pages. Defense requires both server-side filtering and proper Content Security Policy headers.

Virtual Patching

When a vulnerability is discovered in your framework or dependencies, you may not be able to patch immediately. Virtual patching at the WAF level can block exploit attempts while you work on a permanent fix.

Performance and Security

Security and performance often go hand in hand. Compression reduces bandwidth and speeds up your site while also reducing attack surface by serving less data.

Enable Compression

Enable IPv6

Modern infrastructure should support IPv6. Expedited WAF handles IPv6 traffic seamlessly.

Framework Security Checklists

Each web framework has its own security considerations. We’ve created detailed checklists for popular frameworks deployed on Heroku:

Getting Started

The fastest way to improve your Heroku application’s security is to add Expedited WAF. It provides immediate protection against the most common attacks while you implement application-level security measures.

  1. Add Expedited WAF from the Heroku Elements Marketplace
  2. Review your framework’s security checklist from the list above
  3. Enable security headers to protect against browser-based attacks
  4. Force HTTPS if you haven’t already
  5. Monitor your traffic to identify and block malicious patterns

Additional Resources