Free WAF rules for AEM as a Cloud Service, without the WAF licence
How to protect AEM as a Cloud Service with standard CDN traffic filter rules built from OWASP CRS, and what they can't catch compared with Adobe's WAF.
By Matija Kovacek · Published
Last updated
You can filter most automated attacks on AEM as a Cloud Service without Adobe's WAF licence. Standard CDN traffic filter rules can't use Adobe's WAF flags, but they can match URLs, headers, user agents and IP networks with regular expressions. Port the OWASP Core Rule Set into those rules and you cover traversal, XSS, SQL injection and scanners.
That is what our open-source project Free Open-Source WAF Rules for AEM does. This article explains how it works, what it catches, and where it stops.
Standard rules versus WAF rules
Every AEM as a Cloud Service program can deploy traffic filter rules through a config/cdn.yaml file and a Cloud Manager config pipeline. Adobe splits them into two kinds:
- Standard traffic filter rules are available to everyone. They match on request properties such as path, query string, headers, client IP and ASN, and they can block, log, allow or rate limit.
- WAF traffic filter rules add
wafFlagslikeSQLI,XSSorSCANNER, and Adobe's engine decides whether a request is an attack. These need the Extended Security or WAF-DDoS Protection licence.
Without the licence, nothing at the CDN inspects requests for attack patterns unless you write the rules yourself. Writing and maintaining hundreds of attack patterns by hand is where most teams give up.
Borrowing the rules from OWASP
The OWASP Core Rule Set (CRS) is the open-source rule set used with ModSecurity and Coraza, maintained for well over a decade. Its detection is mostly regular expressions and word lists, which is exactly what AEM's standard rules accept.
Our rule set pulls the latest CRS release and converts about 70 of its rules into AEM's format:
- block from day one: scanner user agents, restricted files such as
.gitand.env, path traversal, Log4j JNDI headers, null bytes and AEM paths that should never be public, like/bin/querybuilder.jsonor/system/console - log first: SQL injection, XSS, remote code execution, remote file inclusion and protocol attacks, because these are the rules most likely to hit a legitimate URL on your site
A generated rule looks like this (shortened to one of its three conditions):
- name: crs-930-path-traversal
when:
anyOf:
- reqProperty: urlRaw
matches: '(?i)(?:^|[/;\x5c])\.{2,3}[/;\x5c]'
action:
type: block
alert: trueThe PHP and Node.js rule families are left out on purpose: AEM runs on Java, and those rules would only add size and false positives.
Fitting into 100 KB
AEM limits cdn.yaml to 100 KB. CRS was never written with a size limit in mind, so the generator adds rule groups in priority order and stops when the file is full. Anything that didn't fit is listed in the build report. Today the full set comes to about 98 KB.
Bots and AI crawlers
The same file also handles bots:
- AI training crawlers such as GPTBot, ClaudeBot and CCBot are blocked. The list comes from the open ai.robots.txt project.
- AI search crawlers and assistants fetching a page for a user are allowed, so your site still shows up in ChatGPT, Claude and Perplexity answers.
- A request that claims to be Googlebot, Bingbot or GPTBot but comes from an IP outside that vendor's published ranges is flagged as an impostor.
- Traffic from around 930 datacenter networks gets a tighter per-IP rate limit, with real search engines excluded.
The generator also writes a matching robots.txt, so polite crawlers stop on their own and the CDN enforces the policy for the rest.
Staying up to date
Attack patterns and crawler lists keep changing, so we rebuild the rules every day. Each build runs a test suite: known attacks must be caught, and normal AEM URLs must never be blocked. A build that changes the rules is reviewed by a person before it replaces the published files, so a bad upstream change can't reach your site by itself.
If a rule blocks a legitimate URL on your site, tell us. We add the URL to the test suite, and every later build is checked against it.
How much does it catch?
Measured at build time against public payload lists sent in a query parameter:
| Attack type | Detected |
|---|---|
| Cross-site scripting | 99% |
| Command injection | 100% |
| Local file inclusion | 87% |
| SQL injection | 70% |
Most SQL injection misses are single words like update or like, which appear in normal search queries too.
What it can't do
Know the limits before you rely on it:
- No request body inspection. Attacks sent in a JSON or XML POST body pass through. Forms and APIs that accept JSON still need validation in AEM or a licensed WAF.
- No IP reputation feed. Adobe's licensed WAF knows which IPs attacked other sites recently. A free rule set doesn't.
- No challenges. Adobe's CDN can't show a CAPTCHA or JavaScript challenge, so a bot driving a real browser with a normal user agent looks like a person.
- Different regex engine. The rules are tested with Python, and the CDN runs Fastly's engine. Always deploy to a dev environment first.
For a marketing site with few forms, that is a big step up from no filtering. For an application that takes payments or personal data in JSON, it is a first layer, not the whole answer.
How to start
-
Download cdn.yaml and save it as
config/cdn.yamlin your AEM repository. If you already have acdn.yaml, merge your own rules into it. -
Create a Cloud Manager config pipeline for the
configfolder and deploy to a dev environment. -
Check that the CDN decodes URLs the way the rules expect. Send one encoded traversal attempt to your dev publish URL:
curl -s -o /dev/null -w "%{http_code}\n" "https://<dev-publish>/content/x.html?f=%2e%2e%2f%2e%2e%2fetc%2fpasswd"A 406 means it works. A 200 means your environment matches on the encoded URL: replace
urlRawwithurlandpathRawwithpathin the file and deploy again. -
Watch the CDN logs for one to two weeks. Adobe's traffic filter dashboards for ELK and Splunk show which rules fired and on which URLs.
-
For each rule that showed no false positives, change its action from
logtoblock, one rule at a time. -
Merge robots.txt into your site's robots.txt and add your sitemap URL.
-
Download the files again every few weeks to pick up new attack patterns and crawlers, and reapply your changes from steps 3 and 5.
The rules are free to use under the Apache 2.0 licence. Keep NOTICE.txt with any copy you share or hand to a client. The project isn't affiliated with or endorsed by Adobe. If you would like help rolling it out on your AEM program, or a second opinion on your current CDN setup, see our AEM development services or contact us.
Need help with something like this?
Tell us what you want to automate, fix or build.