Skip to content

[Security] Document the new expose_security_errors option #21008

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

Merged
merged 1 commit into from
May 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion reference/configuration/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ key in your application configuration.

* `access_denied_url`_
* `erase_credentials`_
* `hide_user_not_found`_
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we keep it here and maybe sufis it with (deprecated) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! Let's do that.

* `expose_security_errors`_
* `hide_user_not_found`_ (deprecated)
* `session_fixation_strategy`_

**Advanced Options**:
Expand Down Expand Up @@ -71,11 +72,39 @@ after authentication::
Since Symfony 7.3, ``eraseCredentials()`` methods are deprecated and are
not called if they have the ``#[\Deprecated]`` attribute.

expose_security_errors
----------------------

**type**: ``string`` **default**: ``'none'``

.. deprecated:: 7.3

The ``expose_security_errors`` option was introduced in Symfony 7.3

User enumeration is a common security issue where attackers infer valid usernames
based on error messages. For example, a message like "This user does not exist"
shown by your login form reveals whether a username exists.

This option lets you hide some or all errors related to user accounts
(e.g. blocked or expired accounts) to prevent this issue. Instead, these
errors will trigger a generic ``BadCredentialsException``. The value of this
option can be one of the following:

* ``'none'``: hides all user-related security exceptions;
* ``'account_status'``: shows account-related exceptions (e.g. blocked or expired
accounts) but only for users who provided the correct password;
* ``'all'``: shows all security-related exceptions.

hide_user_not_found
-------------------

**type**: ``boolean`` **default**: ``true``

.. deprecated:: 7.3

The ``hide_user_not_found`` option was deprecated in favor of the
``expose_security_errors`` option in Symfony 7.3.

If ``true``, when a user is not found a generic exception of type
:class:`Symfony\\Component\\Security\\Core\\Exception\\BadCredentialsException`
is thrown with the message "Bad credentials".
Expand Down
Loading