Web Server — Attack & Defense.
Per-server-class attack chains paired with the corresponding hardening — Apache, nginx, IIS, Tomcat, JBoss — and the decision tree from first 200 OK to authenticated context.
Apache HTTPD
- Attack.
.htaccessabuse where AllowOverride permits SetHandler — drop a PHP handler in a writable upload dir for instant RCE.mod_cgi+ CVE-2021-41773 path traversal still reachable on stragglers.mod_statusat/server-statusleaks live request URIs including auth tokens. - Defense.
AllowOverride Noneglobally. Disable mod_status or restrict to loopback. Patch above 2.4.50 and auditDirectoryaliases for traversal escape.
nginx
- Attack. Off-by-slash misconfig:
location /api { proxy_pass http://backend; }with request/api../adminnormalizes server-side. Header injection viaproxy_set_header X-Real-IP $http_x_forwarded_for. Lua-module sandbox escape on old OpenResty. - Defense. Trailing slash discipline:
location /api/ { proxy_pass http://backend/; }. Strip$http_*headers that the backend trusts. Pin OpenResty if you use it; track its CVE feed separately from nginx-core.
IIS / ASP.NET
- Attack. WebDAV PUT to writable virtual dir;
.configoverwrite to swap handlers. Unicode normalization (%c0%af) for traversal on legacy installs. ViewState deserialization where machineKey is leaked or default. - Defense. Disable WebDAV unless required, restrict verbs. Set
requestFilteringto block..sequences. RotatemachineKey, ensure validation/decryption keys are not default.
Tomcat / JBoss / WildFly
- Attack.
/manager/htmlwith default creds (tomcat:tomcat,admin:admin) → WAR deploy → JSP shell. JMX-Console / Admin-Console on JBoss legacy → invoker-servlet → deserialization. RMI port 1099 still externally exposed in misconfigured deploys. - Defense. Remove manager/admin apps from production builds. If required, bind to loopback and restrict by IP + strong creds. Disable JMX remote unless explicitly needed; never on a public interface.
Decision tree from first 200 OK
- Tech identified? If yes → consult banner→CVE list. If no → fingerprint more (favicon, error pages, behavioral probes).
- Auth surface visible? Login form, basic auth, NTLM → spray known weak credentials (
kerbrute,hydra) within lockout policy. - Admin panel reachable? Default creds first, then known CVE for that panel, then password-recovery logic flaws.
- No auth, static-ish app? Directory fuzz (
ffuf -w raft-large -e .bak,.old,.zip,.txt) for backup files, source leaks, config dumps. - API endpoint? Look for
/api/v1,/api/v2,/swagger,/openapi.json,/graphql+ introspection. Test mass assignment, IDOR, JWT confusion.
Rule of thumbNever deploy management interfaces (Tomcat manager, JBoss admin, Confluence admin) on a public interface, regardless of password strength. Network-layer restriction defeats entire classes of attack that password rotation cannot.
Related notes in this domain
- Featured Comprehensive Pentest Reference
- Featured Pentest Methodology — Canonical Reference
- Featured Advanced Penetration Testing & Red Team
- Featured Recon & Discovery
- Featured Active Directory Pentest
- Featured Internal Pivoting & Lateral Movement
- Reference Recon Tooling — Operator Reference
- Reference Operator Toolkits — Catalog & Reference
- Reference Automation vs. Manual Testing
- Background Social Engineering & Phishing
- Background Pentester Foundations & CTF Practice
From reference to evidence