Skip to main content

Documentation Index

Fetch the complete documentation index at: https://wiki.krkn.tech/llms.txt

Use this file to discover all available pages before exploring further.

Custom WAF Rules

Aegis supports three rule match modes: Condition Builder for structured field/operator/value rules, Raw Regex for advanced RE2-based pattern matching, and Correlated for multi-request Mnemos correlation rules.
Image

Rule Options

Every custom rule supports the following configuration:
OptionDescription
NameRule display name
DescriptionDetailed description of what the rule detects
CategoryClassification category
Severitylow, medium, high, or critical
Actionblock, allow, challenge, log, or redirect
EnabledToggle rule on/off
ParanoiaParanoia level (1-4)
TagsFree-form tags for organization
OWASP IDsAssociated OWASP identifiers
CVE IDsAssociated CVE identifiers

Condition Builder Mode

Condition Builder is the standard rule-authoring flow. It supports multi-line field-based rules with AND / OR logic.

Available Fields

FieldDescription
Request URIFull request URI
Request PathURL path component
Query StringURL query string
HTTP MethodRequest method (GET, POST, etc.)
Request BodyRequest body content
User AgentUser-Agent header value
Host HeaderHost header value
Content-TypeContent-Type header value
RefererReferer header value
Source IPClient source IP address
Any HeaderMatch against any request header
Specific HeaderMatch against a named header
Any CookieMatch against any cookie
Specific CookieMatch against a named cookie

Available Operators

OperatorDescription
containsField contains the value
does not containField does not contain the value
equalsExact match
does not equalNot an exact match
starts withField starts with the value
ends withField ends with the value
matches regexRE2 regex match
does not match regexRE2 regex non-match
is in listValue is in a provided list
is not in listValue is not in a provided list
greater thanNumeric comparison
less thanNumeric comparison
existsField is present (no value needed)
does not existField is absent (no value needed)
is IP in rangeIP or CIDR range match

Per-Condition Options

  • Case Sensitive — toggle case sensitivity
  • Negate Result — invert the condition match

Examples

  • Block requests where Request Path contains /wp-admin
  • Block requests where Specific Header matches regex a malicious header pattern
  • Allow requests where Source IP is IP in range 10.0.0.0/8

Raw Regex Mode

Raw Regex mode is for advanced rules and built-in style pattern matching. You provide a Go RE2 pattern and one or more request targets to inspect.

Supported Targets

TargetDescription
Path / URIRequest path and URI
Query StringURL query parameters
BodyRequest body
HeadersAll request headers
CookiesAll cookies
User AgentUser-Agent header

Notes

  • Patterns are compiled with Go’s regexp engine (RE2 syntax)
  • Inline flags such as (?i) are supported (server-side evaluation)
  • Rules require both a pattern and at least one target

Rule Testing

The rule tester uses the real backend WAF evaluation path — the same compiled Go regex engine and condition evaluator that runs in production. This is not a browser-side JavaScript approximation.

Single Rule Test

Test an individual rule against a crafted request:
POST /api/v1/rules/test
{
  "rule": {
    "name": "Test SQLi",
    "match_mode": "regex",
    "pattern": "(?i)union\\s+select",
    "targets": ["query", "body"],
    "action": "block"
  },
  "request": {
    "method": "GET",
    "url": "/api/search?q=1 UNION SELECT 1,2,3",
    "headers": {"User-Agent": "Mozilla/5.0"},
    "body": "",
    "source_ip": "10.0.0.1"
  }
}
Response:
{
  "matched": true,
  "matched_target": "query",
  "matched_value": "UNION SELECT",
  "pattern_valid": true,
  "pattern_error": "",
  "processing_us": 42
}
The response includes:
FieldDescription
matchedWhether the rule fired on the test request
matched_targetWhich request surface matched (path, query, body, headers, cookies, user-agent)
matched_valueThe specific value that triggered the match
pattern_validWhether the regex compiled successfully (RE2 syntax)
pattern_errorCompilation error message if the pattern is invalid
processing_usEvaluation time in microseconds

Test All Rules

Test a crafted request against all enabled WAF rules to see which ones fire:
POST /api/v1/rules/test-all
{
  "request": {
    "method": "POST",
    "url": "/api/login",
    "headers": {"Content-Type": "application/json"},
    "body": "{\"user\":\"admin' OR 1=1--\"}",
    "source_ip": "10.0.0.1"
  }
}
Response:
{
  "matched": true,
  "tested_rules": 26,
  "matches": [
    {
      "rule_id": 1,
      "rule_name": "SQLi - Core",
      "category": "sqli",
      "severity": "high",
      "action": "block",
      "matched_target": "body",
      "matched_value": "OR 1=1"
    }
  ],
  "processing_us": 187
}

Testing Correlation Rules

Correlated (Mnemos) rules can be tested by providing an array of requests that simulate a multi-request sequence:
{
  "rule": {
    "name": "Test Correlation",
    "match_mode": "correlated",
    "action": "block",
    "correlation_config": {
      "window_seconds": 60,
      "threshold": 2,
      "group_by": "source_ip"
    }
  },
  "requests": [
    {"method": "GET", "url": "/api/users", "source_ip": "10.0.0.1"},
    {"method": "GET", "url": "/api/config", "source_ip": "10.0.0.1"},
    {"method": "GET", "url": "/api/billing/export", "source_ip": "10.0.0.1"}
  ]
}

What Gets Tested

Rule ModeEvaluation
RegexPattern compiled with Go RE2, tested against selected targets
ConditionsEach condition evaluated with the same field extraction and operator logic as production
CorrelatedRequest sequence fed into a real correlation store with compiled host rules
All three modes run through the same code paths as the live WAF — engine.TestRule() and engine.Evaluate() — so test results accurately predict production behavior.

Rule Import (JSON / YAML)

Aegis supports bulk importing WAF rules from JSON or YAML files via the admin API. This allows you to share rule sets between Aegis instances, version-control your custom rules, or ingest community rule definitions.

Endpoint

POST /api/v1/rules/import
Content-Type: multipart/form-data
Upload a .json, .yaml, or .yml file (max 4 MB). The format is auto-detected from the file extension.

File Format

Rules can be provided in either a wrapped or direct array format: Wrapped format (JSON):
{
  "version": "1.0",
  "rules": [
    {
      "name": "Block WordPress Admin",
      "category": "custom",
      "severity": "high",
      "action": "block",
      "enabled": true,
      "paranoia": 1,
      "match_mode": "conditions",
      "condition_logic": "AND",
      "conditions": [
        {
          "field": "Request Path",
          "operator": "contains",
          "value": "/wp-admin"
        }
      ],
      "description": "Block access to WordPress admin panel",
      "tags": ["wordpress"],
      "owasp_ids": [],
      "cve_ids": []
    }
  ]
}
Wrapped format (YAML):
version: "1.0"
rules:
  - name: Block WordPress Admin
    category: custom
    severity: high
    action: block
    enabled: true
    paranoia: 1
    match_mode: conditions
    condition_logic: AND
    conditions:
      - field: Request Path
        operator: contains
        value: /wp-admin
    description: Block access to WordPress admin panel
    tags:
      - wordpress
Direct array format (JSON):
[
  {
    "name": "Block SQLi in Query",
    "category": "sqli",
    "severity": "critical",
    "action": "block",
    "match_mode": "regex",
    "pattern": "(?i)(union\\s+select|sleep\\s*\\(|benchmark\\s*\\()",
    "targets": ["query", "body"],
    "enabled": true,
    "paranoia": 1
  }
]

Import Behavior

  • IDs are reset — imported rules receive new IDs; existing rules are not overwritten
  • Host ID is cleared — all imported rules become global (not host-specific)
  • Defaults applied — missing fields are normalized:
    • Category defaults to custom
    • Severity defaults to medium
    • Action defaults to block
    • Paranoia defaults to 1
    • Regex rules with no targets default to path, query, body, headers
  • Validation — each rule is validated through the same logic used by the UI (regex compilation, condition field/operator checks, etc.)
  • Proxy reload — after import, the proxy manager reloads all rule chains

Rule Schema Reference

FieldTypeDescription
namestringRule display name (required)
descriptionstringDetailed description
categorystringClassification (e.g., sqli, xss, custom)
severitystringlow, medium, high, or critical
actionstringblock, allow, challenge, log, or redirect
enabledbooleanWhether the rule is active
paranoiaintegerParanoia level (1-4)
match_modestringconditions, regex, or correlated
correlation_configobjectCorrelation configuration (for correlated mode — see Mnemos)
condition_logicstringAND or OR (for condition mode)
conditionsarrayList of condition objects (for condition mode)
patternstringRE2 regex pattern (for regex mode)
targetsarrayRequest surfaces to inspect (for regex mode)
tagsarrayFree-form string tags
owasp_idsarrayAssociated OWASP identifiers
cve_idsarrayAssociated CVE identifiers

Condition Object Schema

FieldTypeDescription
fieldstringRequest field to inspect
operatorstringComparison operator
valuestringValue to compare against
case_sensitivebooleanEnable case-sensitive matching
negatedbooleanInvert the condition result

Bundled Rule Sets

Aegis ships with importable rule sets in the rules/ directory. These can be imported via the admin API or loaded from the CLI.

PayloadsAllTheThings Rule Set

The payloads-all-the-things.yaml rule set provides 35 detection rules derived from the PayloadsAllTheThings repository. It covers attack categories beyond the 26 built-in rules, including:
CategoryRulesCoverage
SQL Injection5Auth bypass, time-based blind, error-based extraction, polyglots, stacked queries
NoSQL Injection2MongoDB operator injection, server-side JavaScript injection
Command Injection3Shellshock, newline injection, backtick/subshell execution
XXE Injection3Entity declaration, Billion Laughs, XInclude
GraphQL2Introspection probing, batching attacks
Server Side Includes2SSI directives, Edge Side Includes (ESI)
XSLT Injection1XSLT code execution and information disclosure
File Inclusion2Remote file inclusion, PHP wrapper exploitation
Open Redirect1Parameter-based redirect manipulation
Request Smuggling1Transfer-Encoding desync
CSV Injection1Spreadsheet formula injection
SAML Injection1Signature stripping and wrapping
JWT Attacks1Algorithm confusion (alg: none, key confusion)
Prototype Pollution1proto and constructor.prototype manipulation
Web Cache Deception1Static extension appended to dynamic paths
HTTP Parameter Pollution1Duplicate parameter injection
File Upload1Dangerous extension and null byte injection
LaTeX Injection1File read and command execution via LaTeX
Prompt Injection1LLM instruction override and jailbreak
Spring Boot Actuator1Exposed management endpoints
CSS Injection1Attribute selector exfiltration
Source Code Exposure1.git, .svn, .hg directory access
OAuth1Redirect URI manipulation
LDAP (Extended)1Blind LDAP and attribute extraction
DNS Rebinding1Known rebinding service domains
Type Juggling1PHP loose comparison bypass
Race Condition1Last-byte sync headers
WebSocket1Cross-site WebSocket hijacking
IDOR1Sequential ID enumeration patterns
Dependency Confusion1Internal package name probing
The rule set also includes 3 Mnemos correlation rules that link reconnaissance and exploitation patterns:
  • Recon to Exploitation Campaign — introspection/actuator probing followed by active injection
  • Multi-Vector Injection Campaign — 4+ distinct injection techniques from the same client in 3 minutes
  • Auth Attack Campaign — JWT, SAML, OAuth, and type juggling attacks correlated within 5 minutes

Mnemos OOB SQLi and Exfiltration Rule Set

The mnemos-oob-sqli-and-exfil.yaml rule set provides detection chains for:
  • Out-of-Band SQL Injection — OOB function primitives + DNS/UNC exfil, correlated by Mnemos
  • Data Exfiltration Campaigns — sensitive endpoint access + bulk extraction + schema recon, correlated by Mnemos

Importing a Rule Set

curl -X POST http://127.0.0.1:9443/api/v1/rules/import \
  -H "Cookie: kwaf_session=<session>" \
  -H "X-CSRF-Token: <token>" \
  -F "file=@rules/payloads-all-the-things.yaml"