Skip to Content
Web Application Defender's Cookbook
book

Web Application Defender's Cookbook

by Ryan C. Barnett, Jeremiah Grossman
December 2012
Intermediate to advanced
552 pages
13h 16m
English
Wiley
Content preview from Web Application Defender's Cookbook
Recipe 13-1: Tracking Anomaly Scores
This recipe shows you how to utilize anomaly scoring to track suspicious behavior across multiple requests.
Ingredients
  • ModSecurity
    • TX:ANOMALY_SCORE variable
    • IP:ANOMALY_SCORE variable
    • SESSION:ANOMALY_SCORE variable
    • @gt operator
    • @ge operator
    • @lt operator
    • setvar action
    • initcol action
    • setsid action
Per-Transaction Anomaly Scores
Many detection recipes in Part II showed examples of using transactional anomaly scores. This is done by using the ModSecurity setvar action to increment the anomaly_score variable in the transient TX collection. Here is an example taken from the modsecurity_crs_41_sql_injection.conf file:
# # -=[ SQL Tautologies ]=- # SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/| REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* \ "(?i:([\s'\"'´''\(\)]*)([\d\w]++)([\s'\"'´''\(\)]*)(?:(?:=|<=>|r?lik e|sounds\s+like|regexp)([\s'\"'´''\(\)]*)\2|(?:!=|<=|>=|<>|<|>|\^|is \s+not|not\s+like|not\s+regexp)([\s'\"'´''\(\)]*)(?!\2)([\d\w]+)))"\ "phase:2,rev:'2',ver:'OWASP_CRS/2.2.6',maturity:'9',accuracy :'8',capture,multiMatch,t:none,t:urlDecodeUni,t:replaceComments, ctl:auditLogParts=+E,block,msg:'SQL Injection Attack',id:'950901', logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',severity:'2', tag:'OWASP_CRS/WEB_ATTACK/SQL_INJECTION', tag:'WASCTC/WASC-19',tag:'OWASP_TOP_10/A1', tag:'OWASP_AppSensor/CIE1', tag:'PCI/6.5.2',setvar:'tx.msg=%{rule.msg}', setvar:tx.sql_injection_score=+%{tx.critical_anomaly_score}, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Web Site Cookbook

Web Site Cookbook

Doug Addison

Publisher Resources

ISBN: 9781118417058Purchase book