{ "name": "coreruleset", "version": "4.25.2", "summary": "OWASP CRS 4.25 LTS, the ModSecurity rule set against common web attacks, with the application exclusion plugins", "category": "library", "license": "Apache-2.0", "homepage": "https://coreruleset.org/", "source": { "url": "https://github.com/coreruleset/coreruleset/releases/download/v4.25.2/coreruleset-4.25.2-minimal.tar.gz", "sha256": "a2d4b2a5bb4f397f7e40d4e22d0346350706a5f17c1cfefc09e8b9740e00d87e" }, "watch": {"kind": "github-release", "repo": "coreruleset/coreruleset", "tag_regex": "^v([0-9]+(?:\\.[0-9]+)+)$", "pin": "4.25", "source": "https://github.com/coreruleset/coreruleset/releases/download/v{version}/coreruleset-{version}-minimal.tar.gz"}, "deps": [ "libmodsecurity" ], "env_packages": [], "static": false, "nss": false, "vendor": "vendor.txt", "check": "d=share/coreruleset && v=$(sed -n \"s/.*setvar:tx.crs_setup_version=\\([0-9]*\\).*/\\1/p\" \"$d/crs-setup.conf.example\") && [ \"$v\" = 4252 ] && [ \"$(ls \"$d\"/rules/*.conf | wc -l)\" -ge 25 ] && for a in wordpress xenforo phpbb phpmyadmin nextcloud drupal dokuwiki; do [ -s \"$d/plugins/$a-rule-exclusions-config.conf\" ] && [ -s \"$d/plugins/$a-rule-exclusions-before.conf\" ] && [ -s \"$d/licenses/$a-rule-exclusions-plugin.LICENSE\" ] || { echo \"coreruleset: the $a plugin is incomplete\" >&2; exit 1; }; done && printf '%s\\n' \"Include $PREFIX/share/coreruleset/crs-setup.conf.example\" \"Include $PREFIX/share/coreruleset/plugins/*-config.conf\" \"Include $PREFIX/share/coreruleset/plugins/*-before.conf\" \"Include $PREFIX/share/coreruleset/rules/*.conf\" \"Include $PREFIX/share/coreruleset/plugins/*-after.conf\" > \"$TMPDIR/crs.conf\" && cat > \"$TMPDIR/t.c\" <<'CEOF' &&\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n/* the rules' messages go to the audit log in WebPortico; here they are not printed */\nstatic void quiet(void *data, const void *message) { (void)data; (void)message; }\n\n/* one request through a rule set: GET (body NULL) or a urlencoded POST */\nstatic int ask(ModSecurity *ms, RulesSet *rs, const char *method, const char *uri, const char *body) {\n ModSecurityIntervention it;\n memset(&it, 0, sizeof it);\n it.status = 200;\n Transaction *t = msc_new_transaction(ms, rs, NULL);\n msc_process_connection(t, \"192.0.2.7\", 40000, \"127.0.0.1\", 80);\n msc_process_uri(t, uri, method, \"1.1\");\n msc_add_request_header(t, (const unsigned char *)\"Host\", (const unsigned char *)\"forum.example\");\n msc_add_request_header(t, (const unsigned char *)\"User-Agent\", (const unsigned char *)\"Mozilla/5.0 (X11; Linux x86_64) Firefox/140.0\");\n msc_add_request_header(t, (const unsigned char *)\"Accept\", (const unsigned char *)\"text/html\");\n if (body) {\n char n[16];\n snprintf(n, sizeof n, \"%zu\", strlen(body));\n msc_add_request_header(t, (const unsigned char *)\"Content-Type\", (const unsigned char *)\"application/x-www-form-urlencoded\");\n msc_add_request_header(t, (const unsigned char *)\"Content-Length\", (const unsigned char *)n);\n }\n msc_process_request_headers(t);\n if (body) msc_append_request_body(t, (const unsigned char *)body, strlen(body));\n msc_process_request_body(t);\n msc_intervention(t, &it);\n if (it.log) free(it.log);\n if (it.url) free(it.url);\n msc_transaction_cleanup(t);\n return it.status;\n}\n\n/* a rule set the way WebPortico loads it: a site's own lines (site), then CRS with every plugin (the file crs) */\nstatic RulesSet *load(const char *site, const char *crs) {\n const char *err = NULL;\n RulesSet *parent = msc_create_rules_set(), *child = msc_create_rules_set();\n if (msc_rules_add_file(parent, crs, &err) < 0 || msc_rules_add(child, site, &err) < 0 ||\n msc_rules_merge(child, parent, &err) < 0) {\n printf(\"rules: %s\\n\", err ? err : \"?\");\n exit(1);\n }\n return child;\n}\n\nint main(int argc, char **argv) {\n ModSecurity *ms = msc_init();\n const char *on = \"SecRuleEngine On\\nSecRequestBodyAccess On\\n\"\n \"SecAction \\\"id:10001,phase:1,pass,nolog,setvar:tx.xenforo-rule-exclusions-plugin_enabled=0\\\"\\n\";\n const char *xf = \"SecRuleEngine On\\nSecRequestBodyAccess On\\n\"\n \"SecAction \\\"id:10001,phase:1,pass,nolog,setvar:tx.xenforo-rule-exclusions-plugin_enabled=1\\\"\\n\";\n RulesSet *a, *b;\n int sqli, plain, post_plain, post_xf;\n const char *reply = \"message_html=%3Cp%3EWhy+does+%3Cscript%3Ealert(1)%3C%2Fscript%3E+show+as+text%3F%3C%2Fp%3E&_xfToken=1\";\n msc_set_connector_info(ms, \"bvs-check\");\n msc_set_log_cb(ms, quiet);\n a = load(on, argv[1]);\n b = load(xf, argv[1]);\n sqli = ask(ms, a, \"GET\", \"/index.php?id=1%27%20OR%20%271%27%3D%271\", NULL);\n plain = ask(ms, a, \"GET\", \"/index.php?id=5&page=2\", NULL);\n post_plain = ask(ms, a, \"POST\", \"/threads/hello.12/add-reply\", reply);\n post_xf = ask(ms, b, \"POST\", \"/threads/hello.12/add-reply\", reply);\n printf(\"CRS on %s: SQL injection %d, a plain page %d; a forum reply quoting