Skip to content
TheChatArchiveThe Chat Archive
gpt-4.1-mini-2025-04-14· OpenAIAi2 WildChat-4.8M (AI2)

Overview of Anomaly Scoring Anomaly scoring, also known as “collaborative detection”, is…

  1. User

    Overview of Anomaly Scoring

    Anomaly scoring, also known as “collaborative detection”, is a scoring mechanism used in CRS. It assigns a numeric score to HTTP transactions (requests and responses), representing how ‘anomalous’ they appear to be. Anomaly scores can then be used to make blocking decisions. The default CRS blocking policy, for example, is to block any transaction that meets or exceeds a defined anomaly score threshold. How Anomaly Scoring Mode Works

    Anomaly scoring mode combines the concepts of collaborative detection and delayed blocking. The key idea to understand is that the inspection/detection rule logic is decoupled from the blocking functionality.

    Individual rules designed to detect specific types of attacks and malicious behavior are executed. If a rule matches, no immediate disruptive action is taken (e.g. the transaction is not blocked). Instead, the matched rule contributes to a transactional anomaly score, which acts as a running total. The rules just handle detection, adding to the anomaly score if they match. In addition, an individual matched rule will typically log a record of the match for later reference, including the ID of the matched rule, the data that caused the match, and the URI that was being requested.

    Once all of the rules that inspect request data have been executed, blocking evaluation takes place. If the anomaly score is greater than or equal to the inbound anomaly score threshold then the transaction is denied. Transactions that are not denied continue on their journey.

    Diagram showing an example where the inbound anomaly score threshold is set to 5. A first example request accumulates an anomaly score of 2 and is allowed to pass at the blocking evaluation step. A second example request accumulates an anomaly score of 7 and is denied at the blocking evaluation step.

    Continuing on, once all of the rules that inspect response data have been executed, a second round of blocking evaluation takes place. If the outbound anomaly score is greater than or equal to the outbound anomaly score threshold, then the response is not returned to the user. (Note that in this case, the request is fully handled by the backend or application; only the response is stopped.) Info

    Having separate inbound and outbound anomaly scores and thresholds allows for request data and response data to be inspected and scored independently. Summary of Anomaly Scoring Mode

    To summarize, anomaly scoring mode in the CRS works like so:

    Execute all request rules
    Make a blocking decision using the inbound anomaly score threshold
    Execute all response rules
    Make a blocking decision using the outbound anomaly score threshold
    

    The Anomaly Scoring Mechanism In Action As described, individual rules are only responsible for detection and inspection: they do not block or deny transactions. If a rule matches then it increments the anomaly score. This is done using ModSecurity’s setvar

    action.

    Below is an example of a detection rule which matches when a request has a Content-Length header field containing something other than digits. Notice the final line of the rule: it makes use of the setvar

    action, which will increment the anomaly score if the rule matches:

    SecRule REQUEST_HEADERS:Content-Length "!@rx ^\d+$"
    "id:920160,
    phase:1,
    block,
    t:none,
    msg:'Content-Length HTTP header is not numeric',
    logdata:'%{MATCHED_VAR}',
    tag:'application-multi',
    tag:'language-multi',
    tag:'platform-multi',
    tag:'attack-protocol',
    tag:'paranoia-level/1',
    tag:'OWASP_CRS',
    tag:'capec/1000/210/272',
    ver:'OWASP_CRS/3.4.0-dev',
    severity:'CRITICAL',
    setvar:'tx.anomaly_score_pl1=+%{tx.critical_anomaly_score}'"

    Info

    Notice that the anomaly score variable name has the suffix pl1. Internally, CRS keeps track of anomaly scores on a per paranoia level basis. The individual paranoia level anomaly scores are added together before each round of blocking evaluation takes place, allowing the total combined inbound or outbound score to be compared to the relevant anomaly score threshold.

    Tracking the anomaly score per paranoia level allows for clever scoring mechanisms to be employed, such as the executing paranoia level feature.

    The rules files REQUEST-949-BLOCKING-EVALUATION.conf and RESPONSE-959-BLOCKING-EVALUATION.conf

    are responsible for executing the inbound (request) and outbound (response) rounds of blocking evaluation, respectively. The rules in these files calculate the total inbound or outbound transactional anomaly score and then make a blocking decision, by comparing the result to the defined threshold and taking blocking action if required. Configuring Anomaly Scoring Mode

    The following settings can be configured when using anomaly scoring mode:

    Anomaly score thresholds
    Severity levels
    Early blocking
    

    If using a native CRS installation on a web application firewall, these settings are defined in the file crs-setup.conf

    . If running CRS where it has been integrated into a commercial product or CDN then support varies. Some vendors expose these settings in the GUI while other vendors require custom rules to be written which set the necessary variables. Unfortunately, there are also vendors that don’t allow these settings to be configured at all. Anomaly Score Thresholds

    An anomaly score threshold is the cumulative anomaly score at which an inbound request or an outbound response will be blocked.

    Most detected inbound threats carry an anomaly score of 5 (by default), while smaller violations, e.g. protocol and standards violations, carry lower scores. An anomaly score threshold of 7, for example, would require multiple rule matches in order to trigger a block (e.g. one “critical” rule scoring 5 plus a lesser-scoring rule, in order to reach the threshold of 7). An anomaly score threshold of 10 would require at least two “critical” rules to match, or a combination of many lesser-scoring rules. Increasing the anomaly score thresholds makes the CRS less sensitive and hence less likely to block transactions.

    Rule coverage should be taken into account when setting anomaly score thresholds. Different CRS rule categories feature different numbers of rules. SQL injection, for example, is covered by more than 50 rules. As a result, a real world SQLi attack can easily gain an anomaly score of 15, 20, or even more. On the other hand, a rare protocol attack might only be covered by a single, specific rule. If such an attack only causes the one specific rule to match then it will only gain an anomaly score of 5. If the inbound anomaly score threshold is set to anything higher than 5 then attacks like the one described will not be stopped. As such, a CRS installation should aim for an inbound anomaly score threshold of 5. Warning

    Increasing the anomaly score thresholds may allow some attacks to bypass the CRS rules. Info

    An outbound anomaly score threshold of 4 (the default) will block a transaction if any single response rule matches. Tip

    A common practice when working with a new CRS deployment is to start in blocking mode from the very beginning with very high anomaly score thresholds (even as high as 10000). The thresholds can be gradually lowered over time as an iterative process.

    This tuning method was developed and advocated by Christian Folini, who documented it in detail, along with examples, in a popular tutorial titled Handling False Positives with OWASP CRS.

    CRS uses two anomaly score thresholds, which can be defined using the variables listed below: Threshold Variable Inbound anomaly score threshold tx.inbound_anomaly_score_threshold Outbound anomaly score threshold tx.outbound_anomaly_score_threshold

    A simple way to set these thresholds is to uncomment and use rule 900110:

    SecAction
    "id:900110,
    phase:1,
    nolog,
    pass,
    t:none,
    setvar:tx.inbound_anomaly_score_threshold=5,
    setvar:tx.outbound_anomaly_score_threshold=4"

    Severity Levels

    Each CRS rule has an associated severity level. Different severity levels have different anomaly scores associated with them. This means that different rules can increment the anomaly score by different amounts if the rules match.

    The four severity levels and their default anomaly scores are: Severity Level Default Anomaly Score CRITICAL 5 ERROR 4 WARNING 3 NOTICE 2

    For example, by default, a single matching CRITICAL rule would increase the anomaly score by 5, while a single matching WARNING

    rule would increase the anomaly score by 3.

    The default anomaly scores are rarely ever changed. It is possible, however, to set custom anomaly scores for severity levels. To do so, uncomment rule 900100 and set the anomaly scores as desired:

    SecAction
    "id:900100,
    phase:1,
    nolog,
    pass,
    t:none,
    setvar:tx.critical_anomaly_score=5,
    setvar:tx.error_anomaly_score=4,
    setvar:tx.warning_anomaly_score=3,
    setvar:tx.notice_anomaly_score=2"

    Info

    The CRS makes use of a ModSecurity feature called macro expansion to propagate the value of the severity level anomaly scores throughout the entire rule set. Early Blocking

    Early blocking is an optional setting which can be enabled to allow blocking decisions to be made earlier than usual.

    As summarized previously, anomaly scoring mode works like so:

    Execute all request rules
    Make a blocking decision using the inbound anomaly score threshold
    Execute all response rules
    Make a blocking decision using the outbound anomaly score threshold
    

    The early blocking option takes advantage of the fact that the request and response rules are actually split across different phases. A more detailed overview of anomaly scoring mode looks like so:

    Execute all phase 1 (request header) rules
    Execute all phase 2 (request body) rules
    Make a blocking decision using the inbound anomaly score threshold
    Execute all phase 3 (response header) rules
    Execute all phase 4 (response body) rules
    Make a blocking decision using the outbound anomaly score threshold
    

    More data from a transaction becomes available for inspection in each subsequent processing phase. In phase 1 the request headers are available for inspection. Detection rules that are only concerned with request headers are executed here. In phase 2 the request body also becomes available for inspection. Rules that need to inspect the request body, perhaps in addition to request headers, are executed here.

    If a transaction’s anomaly score already meets or exceeds the inbound anomaly score threshold by the end of phase 1 (due to causing phase 1 rules to match) then, in theory, the phase 2 rules don’t need to be executed. This saves the time and resources it would take to process the detection rules in phase 2 and also protects the server from being attacked when handling the body of the request. The majority of CRS rules take place in phase 2, which is also where the request body inspection rules are located. When dealing with large request bodies, it may be worthwhile to avoid executing the phase 2 rules in this way. The same logic applies to blocking responses that have already met the outbound anomaly score threshold in phase 3, before reaching phase 4. This saves the time and resources required to execute the phase 4 rules, which inspect the response body.

    Early blocking makes this possible by inserting two additional rounds of blocking evaluation: one after the phase 1 detection rules have finished executing, and another after the phase 3 detection rules:

    Execute all phase 1 (request header) rules
    Make an early blocking decision using the inbound anomaly score threshold
    Execute all phase 2 (request body) rules
    Make a blocking decision using the inbound anomaly score threshold
    Execute all phase 3 (response header) rules
    Make an early blocking decision using the outbound anomaly score threshold
    Execute all phase 4 (response body) rules
    Make a blocking decision using the outbound anomaly score threshold
    

    Give main conceptions

  2. Assistant

    Sure! Here are the main concepts of Anomaly Scoring Mode in the OWASP Core Rule Set (CRS):

    1. Anomaly Scoring Overview

    • Purpose: Assigns numeric scores to HTTP transactions (requests and responses) to measure how anomalous or suspicious they are.
    • Use: The cumulative anomaly score is used to decide whether to block a transaction.
    • Example: If the anomaly score ≥ a configured threshold, the transaction is blocked.

    2. How Anomaly Scoring Mode Works

    • Detection rules do not block immediately when they match.
    • Each matched rule adds to a running anomaly score based on its severity.
    • After all request rules run, the inbound anomaly score is checked against the inbound blocking threshold.
    • After all response rules run, the outbound anomaly score is checked against the outbound blocking threshold.
    • Separate evaluation for request (inbound) and response (outbound) allows fine-grained control.

    3. Rule Execution & Scoring

    • Each CRS rule is a detection rule that increases the anomaly score when matched.
    • Rules use ModSecurity’s setvar action to add values to anomaly scores.
    • Scores are tracked per paranoia level (different levels of rule strictness), then summed for evaluation.

    4. Anomaly Score Thresholds

    • Thresholds determine when anomaly scores become high enough to block.
    • Default inbound threshold: 5 (recommended starting point).
    • Default outbound threshold: 4.
    • Increasing thresholds reduces sensitivity (fewer blocks, higher false negative risk).
    • Lowering thresholds increases sensitivity (more blocks, higher false positive risk).

    5. Severity Levels & Scoring

    • Rules have associated severity levels that determine how much they increase the anomaly score:
      • CRITICAL = 5 points
      • ERROR = 4 points
      • WARNING = 3 points
      • NOTICE = 2 points
    • Severity to anomaly-score mapping can be customized but is rarely changed.

    6. Early Blocking

    • An optional feature allowing blocking decisions earlier in the request/response processing phases.
    • Instead of waiting until all request or response rules run, decision points occur:
      • After phase 1 (request headers),
      • After phase 3 (response headers).
    • Benefits:
      • Saves resources by stopping request/response processing early if anomaly score threshold is met.
      • Protects server from processing large payloads of already-blocked attacks.

    7. Configuration

    • Thresholds and severity levels are configured in CRS setup, often via crs-setup.conf.
    • Settings can be vendor-dependent in commercial WAFs or CDNs; some expose GUI options, others require rule tweaks.
    • Enabled via setting variables like tx.inbound_anomaly_score_threshold and tx.outbound_anomaly_score_threshold.
    • Early blocking is configurable and adds extra blocking evaluation phases.

    Summary Flow:

    StepDescription
    1. Execute request detection rules (phase 1 & 2)Rules increment inbound anomaly score.
    2. Inbound blocking evaluationBlock if inbound anomaly score ≥ inbound threshold.
    3. Execute response detection rules (phase 3 & 4)Rules increment outbound anomaly score.
    4. Outbound blocking evaluationBlock if outbound anomaly score ≥ outbound threshold.

    Early blocking adds interim evaluation after phase 1 and phase 3 for earlier blocking.


    This approach balances accurate detection with flexible and tunable blocking decisions, making CRS effective at identifying and stopping web attacks while minimizing false positives.

  3. User

    Rewrite on russian

  4. Assistant

    Конечно! Вот основные понятия режима оценки аномалий (Anomaly Scoring Mode) в OWASP Core Rule Set (CRS) на русском языке:


    1. Обзор оценки аномалий

    • Назначение: Присваивает числовые оценки HTTP-транзакциям (запросам и ответам), отражая степень их аномальности или подозрительности.
    • Применение: Суммарная оценка аномалии используется для принятия решения о блокировке.
    • Пример: если оценка аномалии ≥ заданного порога, транзакция блокируется.

    2. Как работает режим оценки аномалий

    • Правила обнаружения не блокируют сразу при срабатывании.
    • Каждое срабатывание правила увеличивает накопленную оценку аномалии в зависимости от уровня серьёзности.
    • После выполнения всех правил для запроса проверяется входящая (inbound) оценка аномалии и сравнивается с порогом для запросов.
    • Аналогично после выполнения правил для ответа проверяется исходящая (outbound) оценка аномалии и сравнивается с порогом для ответов.
    • Отдельная оценка для запросов и ответов даёт гибкость настройки.

    3. Выполнение правил и начисление очков

    • Каждое правило CRS — это правило обнаружения, которое добавляет баллы к оценке аномалии, если сработало.
    • Для увеличения оценки используется действие ModSecurity setvar.
    • Оценки ведутся отдельно по «уровням паранойи» (paranoia levels) и затем суммируются перед оценкой блокировки.

    4. Пороговые значения оценки аномалий

    • Порог определяет минимальное значение оценки аномалии, при достижении которого происходит блокировка.
    • Рекомендуемый порог для входящих запросов: 5.
    • Порог для исходящих ответов – 4.
    • Повышение порога снижает чувствительность (меньше блокировок, выше риск пропуска атак).
    • Понижение порога увеличивает чувствительность (больше блокировок, возможны ложные срабатывания).

    5. Уровни серьёзности и их влияние

    • Каждое правило связано с уровнем серьёзности, который определяет насколько сильно увеличивается оценка аномалии:
      • CRITICAL (Критический) = 5 баллов
      • ERROR (Ошибка) = 4 балла
      • WARNING (Предупреждение) = 3 балла
      • NOTICE (Уведомление) = 2 балла
    • Карта уровней и баллов по умолчанию редко меняется, но может быть настроена.

    6. Раннее блокирование (Early Blocking)

    • Опциональная функция, позволяющая принимать решения о блокировке раньше, не дожидаясь выполнения всех правил.
    • Вместо одной проверки после всех правил запроса и ответа добавляются проверки:
      • После фазы 1 — заголовки запроса,
      • После фазы 3 — заголовки ответа.
    • Преимущества:
      • Экономит ресурсы, останавливая обработку больших данных уже на ранних этапах.
      • Защищает сервер от лишней нагрузки при обнаружении атаки.

    7. Настройка

    • Пороговые значения и уровни серьёзности задаются в файле crs-setup.conf.
    • В коммерческих WAF/CDN настройки могут отличаться: некоторые имеют GUI, некоторые требуют создания пользовательских правил.
    • Используются переменные tx.inbound_anomaly_score_threshold и tx.outbound_anomaly_score_threshold.
    • Раннее блокирование включается отдельной настройкой и добавляет дополнительные этапы оценки.

    Итоговый порядок обработки:

    ШагОписание
    1. Выполнение правил запроса (фазы 1 и 2)Правила увеличивают входящую оценку аномалии.
    2. Оценка и возможная блокировка запросаБлокировка, если входящая оценка ≥ порога для запросов.
    3. Выполнение правил ответа (фазы 3 и 4)Правила увеличивают исходящую оценку аномалии.
    4. Оценка и возможная блокировка ответаБлокировка, если исходящая оценка ≥ порога для ответов.

    Раннее блокирование добавляет дополнительные проверки после фаз 1 и 3 для более быстрой блокировки.


    Таким образом, режим оценки аномалий обеспечивает гибкое и эффективное обнаружение атак с возможностью точной настройки чувствительности и своевременной блокировки.

  5. User

    Объясни коротко что за paranoia level ?

  6. Assistant

    Paranoia level (уровень паранойи) — это настройка в OWASP CRS, которая регулирует строгость и количество проверок (правил) при анализе HTTP-запросов и ответов. Чем выше уровень паранойи, тем больше правил включается, и тем строже проверяется трафик, что повышает вероятность выявления атак, но и увеличивает риск ложных срабатываний. Обычно уровни паранойи идут от 1 (базовый, менее агрессивный) до 4 (максимально строгий).