Skip to content

[Bug] JWE header alg attribute with value http://www.w3.org/2001/04/xmlenc#rsa-oaep instead of RSA-OAEP #2089

@RogerioWagner

Description

@RogerioWagner

Which version of Microsoft.IdentityModel are you using?

Microsoft.IdentityModel 6.30.1

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
  • [ X] 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 next release requires interoperability with other apps written in different languages (ie: GoLang)

Repro

*SigningCredentials and EncryptingCredentials was created using a X509Certificate2 with public and private keys

            SecurityTokenDescriptor tokenDescriptor = new SecurityTokenDescriptor
            {
                Issuer = _openIdConfigurationService.OpenIdConfiguration.Issuer,
                IssuedAt = issuedAt,
                Subject = request.Claims,
                NotBefore = issuedAt.AddSeconds(-1),
                Expires = expires,
                SigningCredentials = credentials.SigningCredentials,
                EncryptingCredentials = credentials.EncryptingCredentials,
                TokenType = "JWE"
            };

            JwtSecurityTokenHandler tokenHandler = new JwtSecurityTokenHandler();
            JwtSecurityToken token = tokenHandler.CreateJwtSecurityToken(tokenDescriptor);

Expected behavior

Algorithm (alg) should be one of the registered at IANA "JSON Web Signature and Encryption Algorithms" (https://www.iana.org/assignments/jose/jose.xhtml) as described on topic 4.1.1 of RFC7516 (https://datatracker.ietf.org/doc/html/rfc7516#page-12)

{
  "alg": "RSA-OAEP",
  "enc": "A128CBC-HS256",
  "kid": "0758B2A8DF6B980E569421870D7CFE29E65D26EB",
  "typ": "JWE",
  "cty": "JWT"
}

Actual behavior

{
  "alg": "http://www.w3.org/2001/04/xmlenc#rsa-oaep",
  "enc": "A128CBC-HS256",
  "kid": "0758B2A8DF6B980E569421870D7CFE29E65D26EB",
  "typ": "JWE",
  "cty": "JWT"
}

Possible solution
Change the KeyWrapper providers to declare header alg complaint to IANA document

Metadata

Metadata

Assignees

Labels

BugProduct is not functioning as expectedComplianceInternal build requires changesCustomer reportedIndicates issue was opened by customerP2High, but not urgent. Needs to be addressed within the next couple of sprints

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions