Search code examples
asp.net-coreoauth-2.0openid-connect.net-standard.net-standard-2.0

What information is logged by IdentityModel when ShowPii is set to true?


IdentityModelEventSource has a property called ShowPII that means that Personally Identifiable Information will be added to the logs (in relation to security). This value is used to decide when to log some OAuth2 sensitive data.

I am trying to understand what kind of Personally Identifiable Information will be logged:

  • Client ID? (aka Client Key, Consumer Key)
  • Client Secret? (aka Consumer Secret)
  • Json Web Tokens? (aka JWT)
  • Access Tokens?
  • Refresh Tokens?
  • Kerberos Tickets?
  • PKCE Values?
  • Authorization Codes?

I know it cannot get access to usernames and passwords because they are only exchanged directly with the IDP.

But but I need to know if I need to find a way to lock down my log files because it will have data that constitutes a security vulnerability.


Solution

  • This is possible log messages of IdentityModel: LogMessages.cs

    About

    I am trying to understand what kind of Personally Identifiable Information will be logged

    I won't copy-paste log messages from there (especially, as they can change at any moment). You can check them yourself and decide what should be considered as the PII.

    But here's an interesting example:

    "IDX10615: Encryption failed. No support for: Algorithm: '{0}', SecurityKey: '{1}'."
    

    and this is how it's used:

    throw LogHelper.LogExceptionMessage(new SecurityTokenEncryptionFailedException(LogHelper.FormatInvariant(TokenLogMessages.IDX10615, encryptingCredentials.Enc, encryptingCredentials.Key)));
    

    If you'll follow the track you'll find out that encryptingCredentials.Key will be logged if ShowPII = true and won't be logged if ShowPII = false.

    Of course, depending on your use case, this particular message may never appear in your logs. And not all messages so outrageously leaky. But you never know:

    1. your use case may change
    2. you may be mistaken about the set of messages IdentityModel can emit for your use case
    3. IdentityModel code may change, and you may forget to check if messages' set is still secure

    So about

    if I need to find a way to lock down my log files

    Yes, you definitely need to.

    Or better yet - don't use ShowPII = true in production for monitoring, use it only in development environment for debugging purposes.