Answer accepted by question author
Hey
Thank you for reaching out to Microsoft Q&A.
As discussed on teams and with the Product team backend.
The validation is failing as expected now when n/e changes to some wrong value however when key id in policy is changed to some wrong value (aka. value not matching kid claim in JWT), the JWT validation passes which is an expected behavior. The Product team will update the Documentation accordingly.
If the resolution was helpful, kindly take a moment to click on 👁 210246-screenshot-2021-12-10-121802.png
and click on Yes for was this answer helpful. And, if you have any further query do let us know.
-
Neščivera Ján (ERNI) 65 Reputation points
Hello,
as written in my original question and as visible in provided policy configuration, there is no <openid-config> in our policy, so the suggestions you provided are not relewant
-
Pravallika KV 17,025 Reputation points • Microsoft External Staff • Moderator
@Neščivera Ján (ERNI) ,Could you please confirm the following:
- What is the
algvalue in the JWT header, for example RS256, HS256? - Is the policy fragment containing
<validate-jwt>definitely applied in the inbound processing pipeline of the API being tested?
- What is the
-
Neščivera Ján (ERNI) 65 Reputation points
Hello,
the
algvalue in our JWTs isRS256. The policy fragment is applied to in the inbound processing pipeline of our API operations that need the JWT validated (but seems to work for audience/issuer only, unfortunatelly).Is there a way to debug the pipeline processing and see why the policy fragment cosidered the JWT valid even with mismatched key id? It really seems that signature validation is for some reason skipped/ignored, only audience and issuer work.
-
Pravallika KV 17,025 Reputation points • Microsoft External Staff • Moderator
You can try debugging this using APIM Trace.
Enable Trace in the Azure Portal: Go to your API in APIM=> Open Test tab => Send a request with a valid JWT=>Enable Trace and inspect the
validate-jwtstep.You should see whether APIM is selecting the signing key (
kid), performing signature verification or only validating issuer/audience/claims.If there is no key resolution or signature validation step in the trace, then the
<issuer-signing-keys>block is not being applied during execution. Also verify the effective policy at runtime (API / operation / product level), since another policy layer can override or bypass signature validation. -
Neščivera Ján (ERNI) 65 Reputation points
hello,
I checked it with tracing and I can see that the policy fragmet is included as expected. If I change the audence in policy fragment I can see in trace that it evaluated the audience and failed. With correct audience I can see in trace the message "JWT validation succeeded". Nothing regarding evaluating the signature.
Even if i change the
kidto some wrong value, the only message in trace is "JWT validation succeeded", so the <issuer-sogning-key> is ignored for some reason.
Sign in to comment
