How to hide "errorCode" in B2C SelfAsserted response

Marek 16 Reputation points
2022-12-30T14:19:30.123+00:00

Hi,

I would like to hide errorCode from SelfAsserted service response

275036-image.png

as per security remediation report from the third party company.

Possible other error codes could be error-codes

You can reproduce this issue with showing these error codes using this demo website authorize with already created account by trying:

  1. to log in using non existing email account
  2. to log in using existing email but wrong password

For these two above scenarios and many different I would like to have same message without letting the user know what is the error and what is exactly wrong.

Appreciate for any solution :)

Marek

Microsoft Security Microsoft Entra Microsoft Entra External ID
{count} votes

3 answers

Sort by: Most helpful
  1. Anton Staykov 1 Reputation point Microsoft Employee
    2023-01-02T11:08:22.757+00:00

    You can achieve this by using localization and changing the error messages. The concrete localization string ids are listed here, relevant are of type ErrorMessage and begin with "UserMessageIf..."

    Once you configure localization with your own messages you will see them:

    275335-image.png


  2. Anton Staykov 1 Reputation point Microsoft Employee
    2023-01-02T13:24:31.013+00:00

    That is true.
    Sorry for misinterpreting your question. The code cannot be hidden/changed/overwritten. Only the error message. In addition, the error code description does not reveal whether the username or password is wrong (AADB2C90052 and AADB2C90054) have identical descriptions. While AADB2C90053 is a little bit more specific, the other two do not say more about the credential.

    Although the error code cannot be changed, it does not pose a security risk for your service. The only plausible risk here is the risk of user enumeration. To be successfully exploited, an adversary must already have a list with compromised accounts (from other sites) or potential victims.

    Azure AD B2C does have built-in protections against credentials attacks (https://learn.microsoft.com/en-us/azure/active-directory-b2c/threat-management) which prevent brute-force or password spray attacks. It also has built in per-IP address restrictions (https://learn.microsoft.com/en-us/azure/active-directory-b2c/service-limits?pivots=b2c-custom-policy). And last, but not least, there is the Identity Protection combined with Conditional Access (https://learn.microsoft.com/en-us/azure/active-directory-b2c/conditional-access-identity-protection-overview) which will allow you to configure sign-in block in case of suspicious account activity.


  3. Frederic 35 Reputation points
    2023-09-20T13:58:50.1333333+00:00

    I wrote a similar question and got an answer to solve it with a custom OAuth2 error technical profile. I couldn't get it working yet but maybe it inspires you too: https://learn.microsoft.com/en-us/answers/questions/1371411/azure-b2c-should-not-leak-account-existence-on-sig

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.