azure-activedirectory-identitymodel-extensions-for-dotnet icon indicating copy to clipboard operation
azure-activedirectory-identitymodel-extensions-for-dotnet copied to clipboard

[Bug] Duplicate or Unreachable code found inside JsonSerializerPrimitives and ConfigurationRetriever

Open Mayank-Soni-89 opened this issue 1 year ago • 3 comments

Which version of Microsoft.IdentityModel are you using? Note that to get help, you need to run the latest version.

Where is the issue?

  • [X] M.IM.JsonWebTokens
  • [ ] M.IM.KeyVaultExtensions
  • [ ] M.IM.Logging
  • [ ] M.IM.ManagedKeyVaultSecurityKey
  • [ ] M.IM.Protocols
  • [ ] M.IM.Protocols.OpenIdConnect
  • [ ] M.IM.Protocols.SignedHttpRequest
  • [ ] M.IM.Protocols.WsFederation
  • [ ] M.IM.TestExtensions
  • [ ] M.IM.Tokens
  • [ ] M.IM.Tokens.Saml
  • [ ] M.IM.Validators
  • [ ] M.IM.Xml
  • [X] S.IM.Tokens.Jwt
  • Other (please describe)

Is this a new or an existing app?

The app is in production and I have upgraded to a new version of Microsoft.IdentityModel.* and this code I used for work around for serialization issue and reported by security team.

Repro

var your = (code) => here;

Expected behavior A clear and concise description of what you expected to happen (or code). Duplicate code should not have to present.

Actual behavior A clear and concise description of what happens, e.g. an exception is thrown, UI freezes. Found duplicate code and cause the security alarm for that code.

Possible solution

Additional context / logs / screenshots / links to code

Add any other context about the problem here, such as logs and screenshots or links to code. image image

Mayank-Soni-89 avatar Mar 27 '24 06:03 Mayank-Soni-89

@Mayank-Soni-89 we need some additional detail here.

brentschmaltz avatar Mar 30 '24 18:03 brentschmaltz

@Mayank-Soni-89 Can you provide more information on what the issue is with the code you mentioned?

pmaytak avatar Sep 03 '24 23:09 pmaytak

Hello,

In JsonSerializerPrimitives.cs file, there is a method called TryCreateTypeFromJsonElement. Inside that method, "if else" condition statement is written. There is a elseif statement which is unreachable code. image check line number 216 and 476. If 216 is suttisfied then it will not reach to 476 linenumber i.e. else if statement in line number 476 will never be execute because 216 and 476 is same condition.

Similiar case for ConfigurationRetriever file.

Mayank-Soni-89 avatar Sep 04 '24 06:09 Mayank-Soni-89