Skip to content

disable showerrors by default#2513

Merged
monkeyiq merged 1 commit intosimplesamlphp:masterfrom
mcdruid:do_not_showerrors
Oct 19, 2025
Merged

disable showerrors by default#2513
monkeyiq merged 1 commit intosimplesamlphp:masterfrom
mcdruid:do_not_showerrors

Conversation

@mcdruid
Copy link
Copy Markdown
Contributor

@mcdruid mcdruid commented Sep 10, 2025

SimpleSAMLphp has showerrors enabled by default.

     * When 'showerrors' is enabled, all error messages and stack traces will be output
     * to the browser.

Although this is no doubt convenient at times, it's risky from a security point of view. See, for example:

https://owasp.org/www-community/Improper_Error_Handling

The most common problem is when detailed internal error messages such as stack traces, database dumps, and error codes are displayed to the user (hacker).

A specific example of this in SimpleSAMLphp was CVE-2024-52596 whereby an attacker could induce a specific error condition via XXE that causes the application to reveal potentially sensitive information within an error message.

showerrors should be disabled by default to avoid such problems.

Filing this as a public PR as all of the details are public already; there is no novel information about an exploitable vulnerability here.

@tvdijen tvdijen added this to the 2.5 milestone Sep 10, 2025
@tvdijen
Copy link
Copy Markdown
Member

tvdijen commented Sep 10, 2025

We have to think about this a little bit, because some errors are meant to be shown (like SAML2 errors).
We don't show backtraces by default, so the only thing an attacker would gain is a slightly more descriptive error-message.

@mcdruid
Copy link
Copy Markdown
Contributor Author

mcdruid commented Sep 10, 2025

Fair enough if there's some nuance and it's desirable sometimes for a meaningful error message to be shown to users.

However in the case of the XXE vulnerability the display of verbose error messages can definitely be abused - happy to share more details if that would help.

Would it make sense to implement something like an additional verboseerrors flag or make showerrors a sliding scale (say from 0 to 3?) instead of a boolean?

The default could then be to show only very minimal error messages / those that would useful to an end user, but retain the ability to increase the verbosity e.g. for debugging during set up.

@tvdijen tvdijen closed this Sep 10, 2025
@tvdijen tvdijen reopened this Sep 10, 2025
monkeyiq added a commit to monkeyiq/simplesamlphp that referenced this pull request Oct 6, 2025
If this whitelist is not used then all errors are shown if showerrors
is true. If you use this new option then you have to list every error
you would like to be shown to the user with a description and
backtrace.

This was raised in
simplesamlphp#2513
@monkeyiq
Copy link
Copy Markdown
Contributor

monkeyiq commented Oct 6, 2025

A possible solution is #2521

In 2521 you can select explicitly which errors to show the description/backtrace for and if the error is not selected it doesn't get the backtrace.

I made the array allow picking explicitly so you can do the following to show no errors. A bit counter productive though since you could just not use the option and set showerrors = false;

'showerrors.whitelist' => [
        'ACSPARAMS' => false,
];

@monkeyiq
Copy link
Copy Markdown
Contributor

Focusing on 2.4.

I am tinkering with my config.php but it seems that debug traces are shown for me in the browser when using the default values. Sorry if I have something set in config.php that does this but I can't see what that might be when looking over a diff to config.php.dist. I have errorreporting=false in mine.

    'showerrors' => true,
    'errorreporting' => true,
    'production' => true,

In error.twig it is using if showerrors to work out if the message/trace is to be shown. That comes from error.exceptionTrace.

The exceptionTrace is output in src/SimpleSAML/Error/Error.php which comes from $this->format(true); and that ultimately leads to Exception::formatBacktrace which doesn't seem to have any other logic such as that in #2521 to limit which errors will produce a stack trace.

@mingsong-hu
Copy link
Copy Markdown
Contributor

mingsong-hu commented Oct 15, 2025

Given that, we have already had the 'backtraces' option for the debug setting. We can respect that setting with the error setting to surface the detailed debug information in the error page if desired.

The proposed changes are:

  • The 'showerrors' is disabled by default.
  • If no debug flags are configured, no additional information will appear on the error page. Currently, stack traces are always displayed whenever showerrors is enabled, regardless of the debug settings.
  • If 'backtraces' is enabled in the debug option, the stack traces information will display along with the error messages.

In a user case where the user does want to have the stack trace details in the logs, but does not want those information expose to the client side (a browser). The configuration should be set as:

'debug' => [
        'backtraces' => true,
    ],
'showerrors' => false,

which aligns with the current behaviour.

Proposed PR: #2540

@monkeyiq
Copy link
Copy Markdown
Contributor

Since this was the original PR to raise the issue and there seems consensus that setting showerrors to false is a good move for the default config I will merge this.

If showerrors is true in general then there is a potential to leak information to expressly nefarious users.

I will follow up discussion as to if the default is modified in the 2.5 series and/or how this might be communicated to administrators in general who have not changed the default setting.

@monkeyiq monkeyiq merged commit 6b1e2bf into simplesamlphp:master Oct 19, 2025
12 of 18 checks passed
@monkeyiq
Copy link
Copy Markdown
Contributor

@mcdruid thank you for the detailed PR.

monkeyiq added a commit to monkeyiq/simplesamlphp that referenced this pull request Oct 20, 2025
If this whitelist is not used then all errors are shown if showerrors
is true. You can use this new option to explicitly allow backtraces
and descriptions to be shown to the user for only select error events.

If you provide a list of errors to show then anything not on that list
will not be shown to the user. The error will be logged etc as normal.

This was raised in
simplesamlphp#2513
monkeyiq added a commit that referenced this pull request Oct 20, 2025
If this whitelist is not used then all errors are shown if showerrors
is true. You can use this new option to explicitly allow backtraces
and descriptions to be shown to the user for only select error events.

If you provide a list of errors to show then anything not on that list
will not be shown to the user. The error will be logged etc as normal.

This was raised in
#2513
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants