How do we prevent our KEY to communicate between Azure AI & our APP from being compromised if the mobile app user intercepts the packet?

Shafeen Charania 20 Reputation points
2025-05-05T10:32:08.2233333+00:00

Hello - we are building a mobile app that connects to our Azure AI service. Consumers using the app might interact via conversational AI, and if they are savvy enough, could intercept the packet, and trap our KEY, which would allow them to use our Azure AI service for their own needs, but at our cost.

We can avoid this by using our cloud backend to talk to Azure AI, but that increases response time.

Is it possible for us to request a set of short term tokens and then provision one to the app client or is there another way for us to protect our key if the user intercepts the packet?

Thank you

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,409 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sina Salam 19,936 Reputation points
    2025-05-05T16:39:15.3766667+00:00

    Hello Shafeen Charania,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    Regarding your question on how you can prevent our KEY to communicate between Azure AI and our APP from being compromised if the mobile app user intercepts the packet. Based on the problem statement you described, it appears that the mobile app is currently using a static API key for backend authentication.

    If that is right, follow the below guides for best practices security:

    Firstly, understand that static keys in mobile apps are easily extracted. You will need to use public/private key pairs or certificate pinning:

    https://owasp.org/www-community/controls/Certificate_and_Public_Key_Pinning

    Secondly, single identity for all users is not a good choice, use Azure AD B2C or OAuth 2.0 Device Flow to authenticate end users. Use this link for more details. - https://learn.microsoft.com/en-us/azure/ai-services/authentication#authenticate-with-azure-active-directory

    Thirdly, in the case of token replay attacks. Bind tokens to device fingerprints using x5t#S256 (certificate thumbprint) or cnf (proof-of-possession) claims - https://datatracker.ietf.org/doc/html/rfc8705

    Fourthly, to reduce Token Lifespan to 5-10 Minutes. You can configure a custom token lifetime policy in Azure AD - https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-configurable-token-lifetimes:

    • Set AccessTokenLifetime = 300 (5 minutes) in the policy.
    • NOTE: This requires Azure AD Premium P1/P2.

    Finally, you can monitor & Rate-Limit Token Requests and Token abuse detection by using Azure AD Conditional Access to block abnormal token requests - https://learn.microsoft.com/en-us/azure/active-directory/conditional-access and you can implement rate-limiting on the backend’s token endpoint e.g., 1 token/5 minutes per user.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.