Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent twig extension XSS vulnerabilities #563

Merged
merged 7 commits into from Jul 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/config/config_dev.yml
Expand Up @@ -16,3 +16,6 @@ framework:
web_profiler:
toolbar: true
intercept_redirects: false

twig:
cache: false
Expand Up @@ -31,9 +31,9 @@ class Debug extends Twig_Extension
public function getFunctions()
{
return [
new TwigFunction('var_export', [$this, 'varExport'], ['is_safe' => ['html']]),
new TwigFunction('var_dump', [$this, 'varDump'], ['is_safe' => ['html']]),
new TwigFunction('print_r', [$this, 'printHumanReadable'], ['is_safe' => ['html']]),
new TwigFunction('var_export', [$this, 'varExport']),
new TwigFunction('var_dump', [$this, 'varDump']),
new TwigFunction('print_r', [$this, 'printHumanReadable']),
];
}

Expand Down
Expand Up @@ -38,8 +38,8 @@ public function __construct(EngineBlock_ApplicationSingleton $application)
public function getFunctions()
{
return [
new TwigFunction('feedbackInfo', [$this, 'getFeedbackInfo'], ['is_safe' => ['html']]),
new TwigFunction('flushLog', [$this, 'flushLog'], ['is_safe' => ['html']]),
new TwigFunction('feedbackInfo', [$this, 'getFeedbackInfo']),
new TwigFunction('flushLog', [$this, 'flushLog']),
];
}

Expand Down
Expand Up @@ -48,9 +48,9 @@ public function __construct(RequestStack $requestStack, $defaultLocale)
public function getFunctions()
{
return [
new TwigFunction('locale', [$this, 'getLocale'], ['is_safe' => ['html']]),
new TwigFunction('postData', [$this, 'getPostData'], ['is_safe' => ['html']]),
new TwigFunction('queryStringFor', [$this, 'getQueryStringFor'], ['is_safe' => ['html']])
new TwigFunction('locale', [$this, 'getLocale']),
new TwigFunction('postData', [$this, 'getPostData']),
new TwigFunction('queryStringFor', [$this, 'getQueryStringFor'])
];
}

Expand Down
Expand Up @@ -57,8 +57,7 @@ public function getFunctions()
),
new TwigFunction(
'attributeSourceLogoUrl',
[$this, 'getAttributeSourceLogoUrl'],
['is_safe' => ['html']]
[$this, 'getAttributeSourceLogoUrl']
),
new TwigFunction(
'attributeSourceDisplayName',
Expand Down
Expand Up @@ -44,8 +44,7 @@ public function getFunctions()
return [
new TwigFunction(
'userAgent',
[$this, 'userAgent'],
['is_safe' => ['html']]
[$this, 'userAgent']
)
];
}
Expand Down
12 changes: 6 additions & 6 deletions theme/material/templates/layouts/scripts/default.html.twig
@@ -1,11 +1,11 @@
{% import "@themeLayouts/scripts/language-switcher.html.twig" as languageSwitcher %}
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie10 lt-ie9 lt-ie8 lt-ie7" lang="{{ locale() }}"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 lt-ie10 lt-ie9 lt-ie8" lang="{{ locale() }}"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 lt-ie10 lt-ie9" lang="{{ locale() }}"> <![endif]-->
<!--[if IE 9]> <html class="no-js ie9 lt-ie10" lang="{{ locale() }}"> <![endif]-->
<!--[if gt IE 9]> <html class="no-js" lang="{{ locale() }}"> <![endif]-->
<!--[if !IE]><!--> <html class="no-js {{ userAgent('safari') }}" lang="{{ locale() }}"> <!--<![endif]-->
<!--[if lt IE 7]> <html class="no-js lt-ie10 lt-ie9 lt-ie8 lt-ie7" lang="{{ locale()|escape('html_attr') }}"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 lt-ie10 lt-ie9 lt-ie8" lang="{{ locale()|escape('html_attr') }}"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 lt-ie10 lt-ie9" lang="{{ locale()|escape('html_attr') }}"> <![endif]-->
<!--[if IE 9]> <html class="no-js ie9 lt-ie10" lang="{{ locale()|escape('html_attr') }}"> <![endif]-->
<!--[if gt IE 9]> <html class="no-js" lang="{{ locale()|escape('html_attr') }}"> <![endif]-->
<!--[if !IE]><!--> <html class="no-js {{ userAgent('safari')|escape('html_attr') }}" lang="{{ locale()|escape('html_attr') }}"> <!--<![endif]-->
<head>
<title>{% block title %}{{ defaultTitle }}{% endblock %}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Expand Down
Expand Up @@ -2,7 +2,7 @@
{% if postData is not empty %}
<form method="post" action="">
{% for name, value in postData %}
<input type="hidden" name="{{ name }}" value="{{ value }}">
<input type="hidden" name="{{ name|escape('html_attr') }}" value="{{ value|escape('html_attr') }}">
{% endfor %}
<ul class="comp-language">
<li>
Expand All @@ -16,10 +16,10 @@
{% else %}
<ul class="comp-language">
<li>
<a{% if currentLanguage == 'en' %} class="selected"{% endif %} href="{{ queryStringFor('en') }}">EN</a>
<a{% if currentLanguage == 'en' %} class="selected"{% endif %} href="{{ queryStringFor('en')|escape('html_attr') }}">EN</a>
</li>
<li>
<a{% if currentLanguage == 'nl' %} class="selected"{% endif %} href="{{ queryStringFor('nl') }}">NL</a>
<a{% if currentLanguage == 'nl' %} class="selected"{% endif %} href="{{ queryStringFor('nl')|escape('html_attr') }}">NL</a>
</li>
</ul>
{% endif %}
Expand Down
Expand Up @@ -49,7 +49,7 @@
alt=""/>
<h2>{{ 'suite_name'|trans }}</h2>
{% elseif attributeSource != 'idp' %}
<img width="30" height="30" src="{{ attributeSourceLogoUrl(attributeSource) }}"
<img width="30" height="30" src="{{ attributeSourceLogoUrl(attributeSource)|escape('html_attr') }}"
alt=""/>
<h2>{{ attributeSourceDisplayName(attributeSource) }}</h2>
{% else %}
Expand Down