What It Takes To Secure A Web Application

Null Bhopal Meet Bhopal, India
1 / 48
Slide 1 of What It Takes To Secure A Web Application
Slide 2 of What It Takes To Secure A Web Application
Slide 3 of What It Takes To Secure A Web Application
Slide 4 of What It Takes To Secure A Web Application
Slide 5 of What It Takes To Secure A Web Application
Slide 6 of What It Takes To Secure A Web Application
Slide 7 of What It Takes To Secure A Web Application
Slide 8 of What It Takes To Secure A Web Application
Slide 9 of What It Takes To Secure A Web Application
Slide 10 of What It Takes To Secure A Web Application
Slide 11 of What It Takes To Secure A Web Application
Slide 12 of What It Takes To Secure A Web Application
Slide 13 of What It Takes To Secure A Web Application
Slide 14 of What It Takes To Secure A Web Application
Slide 15 of What It Takes To Secure A Web Application
Slide 16 of What It Takes To Secure A Web Application
Slide 17 of What It Takes To Secure A Web Application
Slide 18 of What It Takes To Secure A Web Application
Slide 19 of What It Takes To Secure A Web Application
Slide 20 of What It Takes To Secure A Web Application
Slide 21 of What It Takes To Secure A Web Application
Slide 22 of What It Takes To Secure A Web Application
Slide 23 of What It Takes To Secure A Web Application
Slide 24 of What It Takes To Secure A Web Application
Slide 25 of What It Takes To Secure A Web Application
Slide 26 of What It Takes To Secure A Web Application
Slide 27 of What It Takes To Secure A Web Application
Slide 28 of What It Takes To Secure A Web Application
Slide 29 of What It Takes To Secure A Web Application
Slide 30 of What It Takes To Secure A Web Application
Slide 31 of What It Takes To Secure A Web Application
Slide 32 of What It Takes To Secure A Web Application
Slide 33 of What It Takes To Secure A Web Application
Slide 34 of What It Takes To Secure A Web Application
Slide 35 of What It Takes To Secure A Web Application
Slide 36 of What It Takes To Secure A Web Application
Slide 37 of What It Takes To Secure A Web Application
Slide 38 of What It Takes To Secure A Web Application
Slide 39 of What It Takes To Secure A Web Application
Slide 40 of What It Takes To Secure A Web Application
Slide 41 of What It Takes To Secure A Web Application
Slide 42 of What It Takes To Secure A Web Application
Slide 43 of What It Takes To Secure A Web Application
Slide 44 of What It Takes To Secure A Web Application
Slide 45 of What It Takes To Secure A Web Application
Slide 46 of What It Takes To Secure A Web Application
Slide 47 of What It Takes To Secure A Web Application
Slide 48 of What It Takes To Secure A Web Application

Abstract

Walks through the full security lifecycle of deploying and hardening a web application, from OS hardening and web server configuration through TLS setup, firewall rules, WAF deployment, and backup strategies.

AI Generated Summary

AI Generated Content Disclaimer

Note: This summary is AI-generated and may contain inaccuracies, errors, or omissions. If you spot any issues, please contact the site owner for corrections. Errors or omissions are unintended.

This deck is “What It Takes To Secure A Web Application”, presented at Null Bhopal in September 2016. It walks the full security lifecycle of deploying and hardening a web application, using a realistic scenario of hosting a WordPress blog for a financial organization on a budget. Coverage runs from requirements and software selection through threat modeling, hosting, OS hardening, NGINX and PHP configuration, database lockdown, HTTPS/TLS, SSH hardening, WAF, iptables, fail2ban and Docker, closing with often overlooked concerns such as registrar security, administrator laptop hygiene, and backups.

Summary

The deck opens with a concrete scenario: a financial organization’s public blog, separate from the internal network and run on a budget. Software follows with reasons stated: Linux OS (coz its “secure” [pun intended]), WordPress (coz its simpler), PHP (coz WP needs it), NGINX (coz its hip-hop) and mysql (coz that’s what is generally used). Domain booking criteria go beyond price to DNS propagation speed and registrar protection against domain ownership transfer.

Threat modeling asks what you are protecting, from blog data and defacement to downtime and reverse hacks leading to internal network compromise. Adversaries range from stray hackers to state agencies. Hosting compares shared hosting (worst in terms of security), VPS, cloud services (GCloud, Azure, AWS) and dedicated servers. Basic hygiene: no pirated software, verified installers, updated components.

OS security keeps ports 80 (redirecting to 443), 443, and 22 open, with port 25 configured but not exposed. NGINX hardening sets server_tokens and autoindex off, adds security headers, clears identifying headers, and maps 403 to 404. PHP security recommends fastcgi mode, GET or POST instead of REQUEST, and php.ini hardening per the OWASP PHP Configuration Cheat Sheet. Database rules bar root use, blank passwords, cross-database access and public port exposure.

Application security covers wp-admin login protection, enumeration defenses and basic web application attacks, with a self-plug for the wp-security tool on GitHub. The HTTPS section recommends no CBC, no RC4, no 40 or 56 bit ciphers, sha-256 signed certs, public key modulus of at least 2048 bits, and preference for Perfect Forward Secrecy. The SSL config disables session tickets, sets HSTS max-age=15768000 (6 months), enables OCSP stapling with verification, and pins TLS 1.2 only. SSH locks to key based auth with no passwords and no root login.

Additional protections bring in a WAF, iptables, fail2ban and Docker. NAXSI is the default WAF choice, started in learning mode, with ModSecurity as the more powerful alternative. Iptables sets default DROP policies with fail2ban chains and minimal DoS rules. Fail2ban jails cover WordPress and SSH with maxretry 3, the WordPress jail needing a plugin such as wp-fail2ban. Docker, “new kid in the block”, splits the application into nginx, php and mysql containers, judged useful but not necessary.

The deck then asks whether the work is done and answers no: server provider and registrar accounts need two factor authentication (Google authenticator, freeotp) and resistance to social engineering; the administrator laptop needs privilege separation (1 root user, 1 admin user, 1 non sudo daily user), full disk encryption, encrypted work storage, and a password manager. Backup planning covers provider outages with multiple encrypted copies across onsite, offsite and cold storage, periodic restore testing, and secured backup accounts.

Key Themes

  • Defining the Scope: A financial organization’s public blog, separate from the internal network, PR team plus one administrator, globally accessible including admin, 100,000 hits a day, budget under 20$ a month excluding admin salary.
  • Software Stack and Domain Registration: Linux OS, WordPress, PHP, NGINX and MySQL chosen for cost, simplicity or habit; registrars judged on DNS propagation speed and prevention of unauthorized domain transfer, not just price.
  • Threat Modeling: Assets include blog data, defacement, financial data, downtime and reverse hacks leading to internal network compromise; adversaries range from stray hackers and disgruntled employees to hired attackers and state agencies.
  • Hosting Decision: Shared hosting is worst for security; VPS, cloud and dedicated servers shift security responsibility to you, with a 1 core, 1-2 GB RAM, static IP instance at about 10$ as the pick.
  • OS Security and Port Management: Only ports 80 (redirecting to 443), 443 and 22 stay open, port 25 stays private for outbound mail, plus automatic updates and avoiding untrusted PPAs.
  • Web Server, PHP and Database Hardening: NGINX server_tokens off, the four security headers, cleared identifying headers and mapping 403 errors to 404; the OWASP php.ini baseline with dangerous functions disabled; database rules against root use, blank passwords and public port exposure.
  • HTTPS/TLS and SSH Hardening: TLS 1.2 only, no CBC or RC4, PFS, sha-256 certs with 2048-bit keys, HSTS and OCSP stapling validated with SSLLabs and Mozilla tooling; SSH locked to key based auth with no root login.
  • Additional Protections and Overlooked Concerns: NAXSI or ModSecurity as WAF, default DROP iptables with fail2ban chains and DoS limits, optional Docker separation, plus 2FA on provider and registrar accounts, administrator laptop privilege separation, and tested encrypted backups.

Notable Points

  1. The NGINX production header block sets X-Frame-Options: SAMEORIGIN, X-Content-Type-Options: nosniff, X-XSS-Protection: 1; mode=block and X-Download-Options: noopen, clears the Link, Server and X-CF-Powered-By headers, and maps 403 errors to 404.
  2. TLS recommendations: no CBC or RC4, no 40 or 56 bit ciphers preferring over 128 bit, sha-256 signed certificates from a trusted authority, public key modulus of at least 2048 bits, and preference for Perfect Forward Secrecy.
  3. The SSL config disables session tickets, sets HSTS to max-age=15768000 (6 months), enables ssl_stapling and ssl_stapling_verify, and pins ssl_protocols to TLSv1.2 only; validation tools named: SSLLabs, Mozilla’s Server Side TLS wiki, Mozilla’s SSL config generator, and SSLScan, with Mozilla’s ssh_scan and the OpenSSH guidelines for SSH.
  4. SSH hardening: key based authentication only, no passwords, no root login, no sharing of X clients.
  5. The php.ini baseline turns off allow_url_fopen, allow_url_include, allow_webdav_methods and expose_php, sets error_reporting = E_ALL with display_errors off, logs errors to a file, and carries a disable_functions list including system, exec, shell_exec, passthru, phpinfo, show_source, popen and proc_open, per the OWASP PHP Configuration Cheat Sheet.
  6. Iptables applies default DROP policies (iptables -P INPUT DROP, iptables -P OUTPUT DROP, iptables -P FORWARD DROP), sends ports 80,443 to a fail2banwordpress chain and port 22 to fail2ban-ssh, and adds DoS rules limiting RST floods to 2/sec and connection rates to 50/min.
  7. Fail2ban runs [wordpress] and [ssh] jails with maxretry 3 over /var/log/auth.log; the WordPress jail needs a plugin such as wp-fail2ban to provide the auth log.
  8. Docker is presented as “new kid in the block”, splitting the application into nginx web server, php app server and mysql database server containers, useful but not necessary.
  9. Provider and registrar accounts get two factor authentication (Google authenticator/freeotp) and complex passwords; registrars are tested against social engineering by calling with fake or public details to attempt an account password reset.
  10. The administrator laptop uses privilege separation (1 root user, 1 admin user, 1 non sudo daily user), full disk encryption, encrypted work-only storage, and a password manager; backup strategy is multiple encrypted copies across onsite, offsite and cold storage with periodic restoration testing, motivated by failure cases including the Linode outage of December 2015.

Notable Quotes

“WHAT IT TAKES TO SECURE A WEB APPLICATION”

“Linux OS (coz its “secure” [pun intended])”

“NGINX (coz its hip-hop)”

“Shared hosting (worst in terms of security)”

“new kid in the block”

“NOPE NOT YET”

Resources

Embed This Presentation

See Also