
====================================================================

                             CERT-Renater

                 Note d'Information No. 2020/VULN047
_____________________________________________________________________

DATE                : 27/01/2020

HARDWARE PLATFORM(S): /

OPERATING SYSTEM(S): Systems running SimpleSAMLphp versions prior to
                                   1.18.4.

=====================================================================
https://simplesamlphp.org/security/202001-01
https://simplesamlphp.org/security/202001-02
_____________________________________________________________________

202001-01

Cross-site scripting in error reports


Background

SimpleSAMLphp allows users to report errors and failures to the system
administrators via a web form. This web form gathers some contextual
information automatically, but it also allows the user to provide their
email address for follow-ups and a free-text explanation of what
happened. Once submitted, the report is sent as an email to the
administrative email address configured in the software.


Description

The www/erroreport.php script allows error reports to be submitted and
sent to the system administrator. Starting with SimpleSAMLphp 1.18.0, a
new SimpleSAML\Utils\EMail class was introduced to handle sending
emails, implemented as a wrapper of an external dependency.

This new wrapper allows us to use Twig templates in order to create the
email sent with an error report. Since Twig provides automatic escaping
of variables, manual escaping of the free-text field in
www/errorreport.php was removed to avoid double escaping. However, for
those not using the new user interface yet, an email template is
hardcoded into the class itself in plain PHP. Since no escaping is
provided in this template, it is then possible to inject HTML inside the
template by manually crafting the contents of the free-text field.


Affected versions

SimpleSAMLphp versions 1.18.0 to 1.18.3, both inclusive.


Impact

An attacker may take advantage of this issue to manually craft a
modified email sent via the error reporting mechanism, such as this
email might trick a system administrator into performing an action, such
as introducing their credentials into a phishing web site that resembles
the original.

Remote execution of javascript code is considered unfeasible since email
clients do not run javascript present in emails, although there might be
email clients which don't follow this rule, making the attack surface
grow.

_____________________________________________________________________

202001-02

Log injection


Background

SimpleSAMLphp has a logging functionality that allows system
administrators to keep track of the activity, errors, and statistics.
Additionally, it allows users to report errors, shall they happen. An
error report contains a report identifier, which is logged once
submitted.


Description

The www/errorreport.php script, which receives error reports and sends
them via email to the system administrator, didn't properly sanitize the
report identifier obtained from the request. This allows an attacker,
under specific circumstances, to inject new log lines by manually
crafting this report ID.

When configured to use the file logging handler, SimpleSAMLphp will
output all its logs by appending each log line to a given file. Since
the reportID parameter received in a request sent to www/errorreport.php
was not properly sanitized, it was possible to inject newline characters
into it, effectively allowing a malicious user to inject new log lines
with arbitrary content.


Affected versions

SimpleSAMLphp versions up to 1.18.3.


Impact

An attacker may use this issue to inject logs messages into a
SimpleSAMLphp log file, trying to trick or confuse system
administrators. However, the attack surface is considered small, as the
attack will only work with the file logging handler, which opens the log
file in append-only mode. This means an attacker cannot edit or remove
existing log messages, and even if non-ascii characters are written to
the log, the file will always be readable with a simple text editor.


Resolution

Upgrade the SimpleSAMLphp installation to version 1.18.4.


Credit

This vulnerability was discovered and reported by Frederic Vleminckx on
January 23, 2020.

=========================================================
+ CERT-RENATER        | tel : 01-53-94-20-44            +
+ 23/25 Rue Daviel    | fax : 01-53-94-20-41            +
+ 75013 Paris         | email:cert@support.renater.fr   +
=========================================================


