Skip to content

feat(933100): add detection of smarty template php tag#4447

Merged
fzipi merged 14 commits into
coreruleset:mainfrom
touchweb-vincent:patch-13
Feb 15, 2026
Merged

feat(933100): add detection of smarty template php tag#4447
fzipi merged 14 commits into
coreruleset:mainfrom
touchweb-vincent:patch-13

Conversation

@touchweb-vincent
Copy link
Copy Markdown
Contributor

@touchweb-vincent touchweb-vincent commented Feb 8, 2026

Proposed changes

Hello

It appears that nothing prevents PHP tags inserted into Smarty templates on versions 2 up to 3.1.20 - and probably other template engines as well.

https://www.smarty.net/docsv2/fr/language.function.php.tpl

No rule currently detects this in PL2.

curl -H "x-format-output: txt-matched-rules" -H "x-crs-paranoia-level:4" "http://sandbox.coreruleset.org/" -d "payload={php}test{/php}"

I’m not aware of any modern CMS that uses this; however, that doesn’t mean none exist. What do you think? Should we leave it as is, or add support for it?

Thanks

PR Checklist

  • I have read the CONTRIBUTING doc
  • I have added positive tests proving my fix/feature works as intended.
  • I have added negative tests that prove my fix/feature considers common cases that might end in false positives
  • In case you changed a regular expression, you are not adding a ReDOS for pcre. You can check this using regexploit
  • My test use the comment field to write the expected behavior
  • I have added documentation for the rule or change (when appropriate)

Further comments

For the reviewer

  • Positive and negative tests were added
  • Tests cover the intended fix/feature properly
  • No usage of dangerous constructs like ctl:requestBodyAccess=Off were used in the rule
  • In case a regular expression was changed, there is no ReDOS
  • Documentation is clear for the rule/change

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 8, 2026

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

fzipi and others added 2 commits February 8, 2026 17:49
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
@fzipi
Copy link
Copy Markdown
Member

fzipi commented Feb 9, 2026

@azurit Can you review this one? Seems like you have more experience in PHP than myself 😄

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends CRS rule 933100 (PHP open tag detection) to also detect Smarty-style {php} / {/php} template tags, and adds regression tests for additional PHP open-tag variants and non-matching cases.

Changes:

  • Update rule 933100 regex to match {php}-style tags in addition to existing <?... and [php] patterns.
  • Expand regression tests for 933100 with new positive and negative cases.
  • Update the corresponding regex-assembly source for rule 933100.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
rules/REQUEST-933-APPLICATION-ATTACK-PHP.conf Extends rule 933100 regex to include curly-brace {php} tag detection.
regex-assembly/933100.ra Updates regex-assembly definition intended to generate the new bracket/brace matching.
tests/regression/tests/REQUEST-933-APPLICATION-ATTACK-PHP/933100.yaml Adds extensive positive/negative coverage for PHP open tags and {php} tags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rules/REQUEST-933-APPLICATION-ATTACK-PHP.conf Outdated
Comment thread regex-assembly/933100.ra
@touchweb-vincent
Copy link
Copy Markdown
Contributor Author

@fzipi Thanks for your trust :)

I’ve seen your change in the .ra file, which results in a mix of curly braces and square brackets that triggers Copilot warnings. However, I don’t see any case where this could actually have an impact, so we can leave it as is.

As for all the unit tests you’re adding one after another ^^ are you using Claude for that? Maybe Copilot itself ?

Comment thread tests/regression/tests/REQUEST-933-APPLICATION-ATTACK-PHP/933100.yaml Outdated
Comment thread tests/regression/tests/REQUEST-933-APPLICATION-ATTACK-PHP/933100.yaml Outdated
Comment thread tests/regression/tests/REQUEST-933-APPLICATION-ATTACK-PHP/933100.yaml Outdated
@azurit
Copy link
Copy Markdown
Member

azurit commented Feb 13, 2026

Rule is blocking also invalid patterns like {\php}. This should be fixed.

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Feb 14, 2026

@touchweb-vincent I'm using Claude code, with a skill.

Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
@fzipi
Copy link
Copy Markdown
Member

fzipi commented Feb 14, 2026

@azurit Thanks for that. Fixed.

@fzipi fzipi added this pull request to the merge queue Feb 15, 2026
@fzipi fzipi added the release:new-feature This PR introduces a new feature label Feb 15, 2026
Merged via the queue into coreruleset:main with commit 6f4014d Feb 15, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:new-feature This PR introduces a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants