Security guide · Romania

What is a WAF (Web Application Firewall) and when do I need one?

A network firewall decides whether a connection to port 443 is allowed. A WAF reads what is inside that connection, meaning the URL, headers and request body, and blocks known attack patterns before they reach the application.

Updated:

Short answer

  1. A WAF (Web Application Firewall) is a filter that inspects HTTP and HTTPS requests at the application layer and blocks known attack patterns such as SQL injection and XSS.
  2. You need one when you run a public web application that you cannot patch the instant a vulnerability appears: WordPress with plugins, online shops, public APIs.
  3. A WAF does not replace the network firewall or application updates; it is a complementary layer that buys you time.
  4. Choose between a hosting-level or server-level WAF, such as ModSecurity with the OWASP Core Rule Set, and a cloud WAF, and start in detection mode before you block.
Layer it works at
L7, application: URL, headers, HTTP body
What it mainly prevents
SQL injection, XSS and the rest of the OWASP Top 10
Common open-source implementation
ModSecurity + OWASP Core Rule Set
Recommended start mode
detection first, blocking after tuning

The difference between a WAF and a network firewall

A network firewall works with IP addresses, ports and protocols: it allows 443 and refuses 3306. It does not know what an HTTP request is, so it lets through anything that reaches the allowed port, including a SQL query injected into a login form. A WAF sits in front of the application and decodes the request: it recognises ' OR 1=1 in a parameter, a script in a comment field, an attempt to read /etc/passwd through directory traversal. The two filters work together, at different layers.

When you need a WAF and when it is not enough

You need a WAF when the application contains code you do not fully control, such as WordPress plugins, when published vulnerabilities are exploited within hours and you need days to patch, or when you expose a public API. A WAF buys time but does not fix the cause: the flaw stays in the code and a patient attacker finds a payload the rule does not catch. False positives are the cost, so start in detection mode, read the logs for a week and exclude the rules that hit legitimate traffic.

  • Hosting-level WAF: protects every site in the account, with no configuration
  • Server-level WAF, ModSecurity: full control over the rules, but it needs maintenance
  • Cloud WAF: filters before the server and absorbs L7 DDoS, but traffic passes through a third party
Types of WAF and where they fit
WAF typeWhere it runsMain advantageLimit
Hosting-levelOn the hosting server, for all accountsActive by default, no configurationGeneric rules, limited tuning
On the server (ModSecurity + OWASP CRS)In Nginx or Apache, in front of the applicationFull control over the rulesNeeds maintenance and log reading
Cloud (DNS change)In the provider's network, before the serverAlso absorbs L7 DDoS, updated centrallyTraffic passes through a third party; the origin must stay hidden

Commands and configuration

ModSecurity: start in detection mode
# /etc/modsecurity/modsecurity.conf
SecRuleEngine DetectionOnly
SecAuditEngine RelevantOnly
SecAuditLog /var/log/modsec_audit.log
OWASP CRS: exclude one rule for a single endpoint
SecRule REQUEST_URI "@beginsWith /api/filter" \
  "id:10001,phase:1,pass,nolog,ctl:ruleRemoveById=942100"

Practical examples

WooCommerce shop in Cluj-Napoca

A vulnerability in an invoicing plugin was published on Monday, and the patch arrived on Thursday. The hosting-level WAF blocked exploitation attempts in the meantime, visible in the logs from Tuesday. Without a WAF, the exposure window would have been three days.

SaaS company in Iasi with a public API

A generic SQL injection rule blocked a legitimate endpoint that received filter queries with AND and OR operators. The team excluded the rule for that endpoint only, added schema validation on the request body and kept the rest of the ruleset active.

Common mistakes

  • Thinking the WAF replaces application updates, when the vulnerability in the code remains.
  • Switching straight to blocking mode and blocking real customers on day one.
  • Enabling a cloud WAF while leaving the server's IP directly reachable, which bypasses the filter.
  • Treating the WAF as volumetric DDoS protection, when it only works at the application layer.

How 4hosting helps

  • WAF & DDoS Protection configures a WAF with OWASP rules, rate limiting and bot filtering, including the detection period and the exclusion of false positives.
  • The monthly CyberSecurity hours in your plan, 1 on cPanel from Advanced up, 1–8 on VPS, 5–10 on dedicated servers depending on the plan and 10 on GPU servers, are requested from the client panel, in the “DevOps Services” section.
  • Pentesting & Security Audit finds what a WAF only masks.

Related questions

  • WAF or a WordPress security plugin?

    A plugin runs in PHP, so the request has already reached the application and uses resources. A hosting-level or web-server WAF blocks before PHP starts. They complement each other: the WAF for filtering, the plugin for 2FA and limiting login attempts.

  • Does a WAF slow my site down?

    Inspection adds a small amount of time to each request, usually imperceptible next to application time. A very large ruleset or inspection of big request bodies can become visible; exclude file uploads and high-volume endpoints from inspection once you have checked them.

  • Do I need a WAF for an API with no web interface?

    Yes, because SQL injection, directory traversal and unsafe deserialisation hit a JSON API just as well. Tune the rules for your format: exclude the HTML and XSS rules if the API never returns HTML, and add schema validation on the request body.

Request a security review

A production server starts getting attacked within minutes of receiving a public IP address, however small the project is. This guide ranks the controls by impact, from SSH access to incident response, with the Romanian rules that apply along the way. Every topic has its own page with a short answer, examples and ready-to-use configuration.