Skip to content

Commit

Permalink
Fix XSS in layout h1
Browse files Browse the repository at this point in the history
the default layout does a `| raw` which can be exploited if the entity of your CRUD has a `__string()` method that uses some fields from the database.

example to reproduce. 


create an entity Article with a field 'title' and a method __string() which returns it. 

Then put as title `<script>alert('toto')</script>`  -> an XSS is triggered
  • Loading branch information
allan-simon authored Apr 2, 2024
1 parent df81f10 commit 6fc47af
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Resources/views/crud/detail.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{%- apply spaceless -%}
{% set custom_page_title = ea.crud.customPageTitle(pageName, entity ? entity.instance : null, ea.i18n.translationParameters) %}
{{ custom_page_title is null
? ea.crud.defaultPageTitle(null, null, ea.i18n.translationParameters)|trans|raw
? ea.crud.defaultPageTitle(null, null, ea.i18n.translationParameters)|trans
: custom_page_title|trans|raw }}
{%- endapply -%}
{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/crud/edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{%- apply spaceless -%}
{% set custom_page_title = ea.crud.customPageTitle(pageName, entity ? entity.instance : null, ea.i18n.translationParameters) %}
{{ custom_page_title is null
? ea.crud.defaultPageTitle(null, null, ea.i18n.translationParameters)|trans|raw
? ea.crud.defaultPageTitle(null, null, ea.i18n.translationParameters)|trans
: custom_page_title|trans|raw }}
{%- endapply -%}
{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/crud/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{%- apply spaceless -%}
{% set custom_page_title = ea.crud.customPageTitle('index', null, ea.i18n.translationParameters) %}
{{ custom_page_title is null
? ea.crud.defaultPageTitle('index', null, ea.i18n.translationParameters)|trans|raw
? ea.crud.defaultPageTitle('index', null, ea.i18n.translationParameters)|trans
: custom_page_title|trans|raw }}
{%- endapply -%}
{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/crud/new.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{%- apply spaceless -%}
{% set custom_page_title = ea.crud.customPageTitle('new', null, ea.i18n.translationParameters) %}
{{ custom_page_title is null
? ea.crud.defaultPageTitle('new', null, ea.i18n.translationParameters)|trans|raw
? ea.crud.defaultPageTitle('new', null, ea.i18n.translationParameters)|trans
: custom_page_title|trans|raw }}
{%- endapply -%}
{% endblock %}
Expand Down

0 comments on commit 6fc47af

Please sign in to comment.