“What It Takes to Secure a Web Application” was presented at Null Bhopal in September 2016. The session walks through the full security lifecycle of deploying and hardening a web application, from requirements gathering and software selection through OS hardening, web server and PHP configuration, database lockdown, HTTPS/TLS setup, SSH hardening, firewall rules, WAF deployment, and often-overlooked concerns like registrar security, admin endpoint protection, and backup strategy. Every decision is framed inside a realistic scenario: deploying a WordPress blog for a financial organization on a budget.
Summary
The scenario set concrete constraints: a financial organization’s public blog, accessed by the PR team plus one administrator, global accessibility including the admin interface, around one lakh hits a day, and a budget not to exceed $20 a month excluding the admin’s salary. The software stack followed from simplicity and cost: Linux, WordPress, PHP, NGINX, and MySQL. Threat modeling asked what is being protected and who the adversaries are: stray hackers, disgruntled employees, rivals or attackers for hire, and state agencies. On hosting, shared hosting was called the worst for security; the final pick was a virtual server instance with 1 core, 1 to 2 GB RAM, 1 static IP, and a management console at around $10 a month from providers like DigitalOcean, Linode, or AWS.
OS security kept ports 80 (redirecting to 443), 443, and 22 (SFTP over SSH) open, with port 25 reserved for outbound mail and never exposed publicly, plus automatic updates and a warning against untrusted PPAs. NGINX hardening used a 301 redirect, server_tokens off, autoindex off, the full security header set, clearing informative headers, and mapping error_page 403 =404 to prevent information leakage. PHP ran in FastCGI mode with hardened php.ini settings and long disable_functions lists per the OWASP PHP Configuration Cheat Sheet. Database rules: never use root or blank passwords, separate accounts by role, keep the WordPress user out of other databases, and never expose the database port. WordPress application security covered wp-admin login protection and information disclosure through username and attachment enumeration.
HTTPS transport security asked which certificate and ciphers to use and why Perfect Forward Secrecy matters, validated with SSLLabs, Mozilla’s Server Side TLS resources, and SSLScan; the recommendation was no CBC or RC4, preference above 128 bit, a trusted authority, SHA-256 signing, at least 2048-bit keys, and PFS, with the NGINX SSL config pinning a modern TLSv1.2-only cipher suite, adding HSTS, and enabling OCSP stapling. SSH hardening demanded key-based auth, no password login, no root login, and no X11 sharing.
Additional protections stacked four layers: a WAF (NAXSI as the default choice, ModSecurity the more powerful alternative), iptables (default DROP policy with port allowances chained into fail2ban plus minimal DoS mitigation rules), fail2ban (jails for SSH and WordPress login), and Docker for container-based separation of nginx, PHP, and MySQL. The deck then asked “are we done yet” and answered no: provider accounts need 2FA and complex passwords; registrar and DNS accounts need 2FA and resistance to social engineering, testable by calling them with fake details; the administrator laptop needs privilege separation, full disk encryption, and a password manager; and backups need multiple encrypted copies across onsite, offsite, and cold storage with periodic restoration testing.
Key Themes
- Defining the scope with a realistic scenario: a financial organization’s public blog requiring global accessibility, WYSIWYG editing for a PR team plus one administrator, separation from internal networks, around 100,000 hits per day, and a $20/month budget, which drives the stack selection of Linux, WordPress, PHP, NGINX, and MySQL.
- Threat modeling: what you protect (blog data, reputation, financial data, availability, and the reverse-hack path into the internal network) and who the adversaries are, from stray hackers and disgruntled employees to hired attackers and state agencies.
- Domain registration and hosting decisions: registrars evaluated on DNS propagation speed and resistance to unauthorized domain transfers (Gandi and Namecheap named), shared hosting called worst for security, and a 1 core, 1 to 2 GB RAM, 1 static IP VPS or cloud instance at roughly $10/month from DigitalOcean, Linode, or AWS.
- OS security and port management: only ports 80, 443, and 22 stay open with automatic updates enabled, encrypted partitions considered, and untrusted third-party PPAs avoided.
- Web server hardening (NGINX): port 80 to 443 redirect,
server_tokens off, autoindex off, the full security header set, clearing informative headers, and mapping 403 to 404.
- PHP, database, and WordPress application security: FastCGI mode, hardened php.ini settings and disabled dangerous functions per the OWASP PHP Configuration Cheat Sheet, no root or blank passwords with role-separated accounts and an isolated WordPress database user, wp-admin login protection, and defense against username and attachment enumeration, with the author’s
wp-security tool and the OWASP Testing Guide v4 as references.
- HTTPS/TLS and SSH hardening: TLS 1.2-only with strong non-CBC, non-RC4 ciphers, SHA-256 certificates with 2048-bit keys, PFS, HSTS, and OCSP stapling validated via SSLLabs, Mozilla resources, and sslscan; SSH locked to key-based auth with no root login, checked with ssh_scan.
- Additional protections and the often-overlooked chain: NAXSI or ModSecurity, default-DROP iptables with DoS rules, fail2ban for SSH and WordPress, optional Docker separation; then the layers beyond the server: provider and registrar 2FA, social engineering testing, administrator laptop hardening, and a tested backup strategy.
Notable Points
- Apply the full NGINX security header set (
X-Frame-Options, X-Content-Type-Options, X-XSS-Protection, X-Download-Options), hide server identification with server_tokens off, and map 403 errors to 404: low-effort, high-value hardening for any production deployment.
- Disable dangerous PHP functions (
system, exec, shell_exec, passthru, and the rest of the deck’s disable_functions lists) in production php.ini, following the OWASP PHP Configuration Cheat Sheet as a baseline.
- Implement a default-DROP iptables policy and integrate fail2ban for both SSH and WordPress login brute-force protection, using the deck’s rules as a starting template; the wp-fail2ban plugin supplies the WordPress auth log.
- Configure TLS to modern settings: TLS 1.2 only, PFS-enabled cipher suites, HSTS
max-age=15768000, and OCSP stapling, then validate with SSLLabs and Mozilla’s SSL Config Generator.
- Secure the whole operational chain beyond the server: 2FA (Google Authenticator or FreeOTP) on hosting provider, registrar, and DNS accounts, and test registrars against social engineering by calling with fake or public details.
- Harden the administrator laptop: privilege separation into root, admin, and non-sudo daily users, full disk encryption, encrypted work-only storage, and a password manager.
- Maintain multiple encrypted backup copies across onsite, offsite, and cold storage, and verify them by performing actual restoration tests instead of assuming they work.
- The database rules are concrete: never use root for application access, never leave blank passwords, keep the WordPress user out of other databases, and never expose the database port to the public internet.
Notable Quotes
“Linux OS (coz its “secure” [pun intended])”
“NGINX (coz its hip-hop)”
“Budget not to exceed 20$ a month excluding admin’s salary”
“Shared hosting (worst in terms of security)”
“what if backup don’t restore properly.”
“don’t just backup try periodically restoring them also”