Skip to content

feat(934200): detect Server-Side Template Injection (SSTI) attacks#4600

Merged
fzipi merged 4 commits into
coreruleset:mainfrom
zoutjebot:fix/934175-ssti-detection
Apr 25, 2026
Merged

feat(934200): detect Server-Side Template Injection (SSTI) attacks#4600
fzipi merged 4 commits into
coreruleset:mainfrom
zoutjebot:fix/934175-ssti-detection

Conversation

@zoutjebot
Copy link
Copy Markdown
Contributor

What

New PL1 rule detecting SSTI payloads in Jinja2, Twig, ERB, and Expression Language. Requires code execution indicators inside template delimiters.

Context

Part of CVE-derived payload research FN improvements. See tracking issue #4584 for full context.

Refs: #4584

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 30, 2026

📊 Quantitative test results for language: eng, year: 2023, size: 10K, paranoia level: 1:
🚀 Quantitative testing did not detect new false positives

@HackingRepo
Copy link
Copy Markdown
Contributor

Good PR

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Apr 2, 2026

@zoutjebot Thanks for the PR.

Questions:

  • what is the difference between this rule and 934180?
  • can you provide the .ra file?
  • do not use "5" (e.g. 934175) for the rule, use IDs that are multiple of 10

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Apr 8, 2026

ping @zoutjebot

zoutjebot pushed a commit to zoutjebot/coreruleset that referenced this pull request Apr 17, 2026
- Add regex-assembly/934175.ra with documented pattern structure
- Regenerate .conf via crs-toolchain (optimized character classes)
- Add standard crs-toolchain header comment to rule block

Addresses review feedback from fzipi on PR coreruleset#4600.
@zoutjebot
Copy link
Copy Markdown
Contributor Author

Thanks for the review, Felipe. Addressing each point:

Difference between this rule and 934180:

934180 (PL2) matches {%...%} and <%...%> broadly — any content inside the delimiters triggers it. It does not cover {{...}} (that is partially in 941380 as XSS, not SSTI-specific) or #{...} (Expression Language).

This rule targets a narrower, higher-confidence pattern: it matches {{...}}, #{...}, and <%...%> but only when they contain code execution indicators — arithmetic (*), dunder access (__), or function call syntax (()). That strictness is what makes it viable at PL1 without introducing false positives from legitimate template usage like {{username}} or <%=title%>.

In short: 934180 catches broad template syntax at PL2, this rule catches template syntax with execution intent at PL1.

.ra file: Added in the latest push (regex-assembly/934175.ra), with .conf regenerated via crs-toolchain.

Rule ID: Will renumber to a multiple of 10. However, all PL1 slots from 934100 through 934170 are currently taken and 934180+ is PL2. Where would you like this placed?

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Apr 17, 2026

Thanks. It doesn't matter as rules aren't constrained to have an id smaller that the ones in PL2. So the next one free in the 934 is good.

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Apr 19, 2026

@zoutjebot Use 934200.

zoutjebot pushed a commit to zoutjebot/coreruleset that referenced this pull request Apr 20, 2026
- Add regex-assembly/934175.ra with documented pattern structure
- Regenerate .conf via crs-toolchain (optimized character classes)
- Add standard crs-toolchain header comment to rule block

Addresses review feedback from fzipi on PR coreruleset#4600.
@zoutjebot zoutjebot force-pushed the fix/934175-ssti-detection branch from 498c5ab to 05377bb Compare April 20, 2026 07:49
@zoutjebot
Copy link
Copy Markdown
Contributor Author

Done. Renumbered to 934200 — .ra file, .conf, and tests all updated. Rebased on latest main.

@HackingRepo
Copy link
Copy Markdown
Contributor

@zoutjebot, rename the title from feat(934175): detect Server-Side Template Injection (SSTI) attacks to feat(934200): detect Server-Side Template Injection (SSTI) attacks

@zoutjebot zoutjebot changed the title feat(934175): detect Server-Side Template Injection (SSTI) attacks feat(934200): detect Server-Side Template Injection (SSTI) attacks Apr 20, 2026
@zoutjebot
Copy link
Copy Markdown
Contributor Author

Updated the PR title. Thanks.

@HackingRepo
Copy link
Copy Markdown
Contributor

HackingRepo commented Apr 20, 2026

already

relunsec@relunsec:~$ curl https://sandbox.coreruleset.org/?q=%7B%7B7*7%7D%7D -H "X-Format-Output: txt-matched-rules" -H "x-crs-paranoia-level: 2"
941380 PL2 AngularJS client side template injection detected
949110 PL? Inbound Anomaly Score Exceeded (Total Score: 5)
980170 PL? Anomaly Scores: (Inbound Scores: blocking=5, detection=5, per_pl=0-5-0-0, threshold=5) - (Outbound Scores: blocking=0, detection=0, per_pl=0-0-0-0, threshold=4) - (SQLI=0, XSS=5, RFI=0, LFI=0, RCE=0, PHPI=0, HTTP=0, SESS=0, COMBINED_SCORE=5)
relunsec@relunsec:~$ 

and

relunsec@relunsec:~$ curl https://sandbox.coreruleset.org/?q=%7B%7B\'\'.__class__%7D%7D -H "X-Format-Output: txt-matched-rules" -H "x-crs-paranoia-level: 2"
941380 PL2 AngularJS client side template injection detected
949110 PL? Inbound Anomaly Score Exceeded (Total Score: 5)
980170 PL? Anomaly Scores: (Inbound Scores: blocking=5, detection=5, per_pl=0-5-0-0, threshold=5) - (Outbound Scores: blocking=0, detection=0, per_pl=0-0-0-0, threshold=4) - (SQLI=0, XSS=5, RFI=0, LFI=0, RCE=0, PHPI=0, HTTP=0, SESS=0, COMBINED_SCORE=5)
relunsec@relunsec:~$ 

detected

Zoutje added 4 commits April 25, 2026 11:02
Add new rule 934175 to detect SSTI attacks in template engines at PL1.

Detects code execution indicators inside template syntax:
- Jinja2/Twig: {{7*7}}, {{''.__class__.__mro__}}
- Ruby ERB: <%= system('id') %>
- Expression Language: #{runtime.exec('id')}

The regex requires arithmetic (*), dunder access (__), or function
call syntax (( ) inside template delimiters to minimize false
positives from legitimate template usage.

Refs: coreruleset#4584
- Add regex-assembly/934175.ra with documented pattern structure
- Regenerate .conf via crs-toolchain (optimized character classes)
- Add standard crs-toolchain header comment to rule block

Addresses review feedback from fzipi on PR coreruleset#4600.
- 6 positive tests: Jinja2/Twig (arithmetic, dunder), EL (function call,
  arithmetic), ERB (arithmetic, system command)
- 3 negative tests: legitimate template variables ({{username}},
  <%=title%>, #{name}) should not trigger

Fixes CI lint check: rule does not have any tests.
Per fzipi's review: rule IDs must be multiples of 10. fzipi
confirmed 934200 as the next free ID in the 934 family.

Renamed:
- regex-assembly/934175.ra -> 934200.ra
- tests/.../934175.yaml -> 934200.yaml
- Updated rule id in .conf
@fzipi fzipi force-pushed the fix/934175-ssti-detection branch from 05377bb to c32323e Compare April 25, 2026 14:02
@fzipi fzipi added this pull request to the merge queue Apr 25, 2026
Merged via the queue into coreruleset:main with commit 00613b1 Apr 25, 2026
8 checks passed
@fzipi fzipi added the release:new-detection In this PR we introduce a new detection label Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:new-detection In this PR we introduce a new detection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants