and ?\n", "text": "How could a Suricata rule detect the XSS payloads and ?\n", "dateModified": "2026-11-26T12:35:10+00:00", "answerCount": 1, "acceptedAnswer": { "@type": "Answer", "text": "Match an HTML tag opening in literal or URL-encoded form (< or %3C) followed by a tag name and a closing >/%3E, with a PCRE that ignores case. For example: pcre:\"/((\\%3C)|<)((\\%2F)|\\/)*[a-z0-9\\%]+((\\%3E)|>)/ix\";\nCross-site scripting injects HTML or JavaScript that the victim's browser executes. The common element of both payloads is an HTML tag inside user input where none belongs.\nalert tcp any any -> $HOME_NET any (msg:\"XSS attempt\"; flow:to_server,established; pcre:\"/((\\%3C)|<)((\\%2F)|\\/)*[a-z0-9\\%]+((\\%3E)|>)/ix\"; classtype:web-application-attack; sid:1000018; rev:1;)\n\n\n((\\%3C)|<): an opening angle bracket, literal or encoded.\n((\\%2F)|\\/)*: an optional slash (closing tags like ).\n[a-z0-9\\%]+: the tag name.\n((\\%3E)|>): the closing bracket.\n\nA narrower variant targets the image trick specifically: <, then img in any case or encoding, then anything up to >, which catches . Variants with script or javascript: are possible too.\nThe trade-off is the same as for SQL injection. A generic tag pattern catches many variants but also any legitimate HTML in form input, so real deployments scope it to specific parameters or pair it with content keywords such as script or javascript.\nGo deeper:\n\n Mookhey: Detection of SQL Injection and Cross-site Scripting Attacks (Black Hat USA 2004) — the origin of the tag regex and of the variant, with the reasoning behind each.\n OWASP XSS Filter Evasion Cheat Sheet — the encodings and tricks attackers use to slip past exactly this kind of signature.\n Cross-site scripting (Wikipedia) — reflected vs stored XSS and what an attacker gains from each.\n\n", "dateModified": "2026-11-26T12:35:10+00:00" } } }

LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

How could a Suricata rule detect the XSS payloads <script>alert(document.cookie);</script> and <img src="javascript:document.write('XSS')" />?

Match an HTML tag opening in literal or URL-encoded form (< or %3C) followed by a tag name and a closing >/%3E, with a PCRE that ignores case. For example: pcre:"/((\%3C)|<)((\%2F)|\/)*[a-z0-9\%]+((\%3E)|>)/ix";

Cross-site scripting injects HTML or JavaScript that the victim's browser executes. The common element of both payloads is an HTML tag inside user input where none belongs.

alert tcp any any -> $HOME_NET any (msg:"XSS attempt"; flow:to_server,established; pcre:"/((\%3C)|<)((\%2F)|\/)*[a-z0-9\%]+((\%3E)|>)/ix"; classtype:web-application-attack; sid:1000018; rev:1;)
  • ((\%3C)|<): an opening angle bracket, literal or encoded.
  • ((\%2F)|\/)*: an optional slash (closing tags like </script>).
  • [a-z0-9\%]+: the tag name.
  • ((\%3E)|>): the closing bracket.

A narrower variant targets the image trick specifically: <, then img in any case or encoding, then anything up to >, which catches <img src="javascript:…">. Variants with script or javascript: are possible too.

The trade-off is the same as for SQL injection. A generic tag pattern catches many variants but also any legitimate HTML in form input, so real deployments scope it to specific parameters or pair it with content keywords such as script or javascript.

Go deeper:

From Quiz: ISLAB / Network Security Monitoring | Updated: Nov 26, 2026