Keyvault JCA's AccessTokenUtil does not urlencode its parameters when getting an access token #40616
Closed
3 tasks done
Labels
azure-spring
All azure-spring related issues
bug
This issue requires a change to an existing behavior in the product in order to be resolved.
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
needs-team-attention
Workflow: This issue needs attention from Azure service team or SDK team
Milestone
Describe the bug
In our app, we get
NullPointerException
when first accessing a key through acom.azure.security.keyvault.jca.implementation.KeyVaultClient
method.We have all the reasons to believe our configuration is OK, as multiple other KeyVault-based elements in the stack work OK (e.g. KeyVault as property source, SecretClient instances...). The configuration / interaction mode with keyvault is client_id / client_secret based.
On top of it, the same code works on many environments (preproduction...) but the NPE occurs only in production, with the seemingly only relevant difference being the actual values client_id / client_secert.
Finally, it's pretty clear to me, having looked at it for a few hours that the issue is :
a) hidden by the fact that the HTTP interactions made by the library output nothing / no log / error when HTTP error occurs (40x, 50x, ...)
b) triggered while accessing the accessToken by tenant id / client id / client secret.
c) more excplicetly, because the
client_secret
is not URL-encoded, which triggers a (rightfull) signin failed error onhttps://login.microsoftonline.com
's side : the secret is "wrong"Exception or Stack Trace
Note : there is no stack trace for the HTTP-call that tries to retrieve the token but Azure Portal (Enterprise application sign-in logs) show a failed login attempt, in our case, with an
Invalid client secret
failure reason.To Reproduce
x-www-form-urlencoding
(eg@
or[]
come to mindcom.azure.security.keyvault.jca.implementation.KeyVaultClient
using the valid clientid / secret / tenant ID / keyvault URLCode Snippet
Expected behavior
Have a successfull login when the client secret (or any other authentication variable) require encoding to conform to the HTTP status
Screenshots
N/A
Setup (please complete the following information):
Additional context
The bug is pretty clear when looking at current implementation :
azure-sdk-for-java/sdk/keyvault/azure-security-keyvault-jca/src/main/java/com/azure/security/keyvault/jca/implementation/utils/AccessTokenUtil.java
Lines 93 to 111 in dcbfa34
Raw string concatenation may or may not work considering the request's content type.
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: