How the attack works
A function app runs code with the app's managed identity, and its HTTP functions are protected by access keys unless their authorization level is anonymous. Microsoft documents four kinds of key: function keys, host keys, the master key (_master), which also gives administrative access to the runtime REST APIs of the app, and system keys that extensions use. Keys are part of the app's secret store with their own lifecycle. Deleting a function does not remove them, and a key stays valid until it is renewed or deleted. Keys are created and renewed through Azure Resource Manager (microsoft.web/sites/host/functionkeys/write, microsoft.web/sites/functions/keys/write). The code of an app comes from its deployment source, and with continuous deployment the platform builds and deploys from a repository and branch that are stored in the app's source control settings (Microsoft.Web/sites/sourcecontrols/Write).
An attacker with a contributor role on the app uses these operations in two ways. A new key with a name that looks ordinary is a credential outside Microsoft Entra ID: whoever holds it can call the app's functions from anywhere, with no sign-in and no Conditional Access. A changed function or a changed deployment source puts the attacker's code into the app, where it runs with the app's managed identity and its settings. The Azure Activity log records these writes with their caller. It does not record what a key is or what the code does, and it sees only part of the ways code reaches an app. A deployment that is pushed to the app's SCM endpoint goes to that endpoint and not through Azure Resource Manager. Microsoft does not document which Activity log operations each deployment method produces, so the rules on this page match on the operation names alone.
What an attacker needs
- A role with the key or source control write actions on the app: Owner, Contributor or Website Contributor.
- For code execution with more than the app's own data: a managed identity on the app that has rights on other resources.
- For use of a key: a function with an HTTP trigger and network access to the app.
Impact
A key that calls the app's functions without a Microsoft Entra identity until somebody renews or deletes it, and with the master key, administrative access to the runtime APIs of the app. Changed code runs with the app's managed identity and can read the app's settings and connection strings. Both survive the removal of the attacker's Azure role.
Detection rules
Function App Access Key Created or Renewed
Detects a successful write of an access key of an Azure function app through Azure Resource Manager: a host key, a system key or the key of a single function, on the app or on a deployment slot. A key calls the app's functions with no Microsoft Entra sign-in and stays valid until it is renewed or deleted, so a key that an attacker adds is a lasting way back in. The rule matches on the operation names only, which is why its level is low. The event does not say whether the key is new or an existing one that was renewed, and the key name is in the resource ID of the event. Compare it with the key names you expect for the app.
title: Function App Access Key Created or Renewed
id: bad781a9-698a-4acf-96c9-b578b6b10631
status: experimental
description: >-
Detects a successful write of an access key of an Azure function app through
Azure Resource Manager: a host key, a system key or the key of a single
function, on the app or on a deployment slot. A key calls the app's
functions with no Microsoft Entra sign-in and stays valid until it is
renewed or deleted, so a key that an attacker adds is a lasting way back in.
The rule matches on the operation names only, which is why its level is
low. The event does not say whether the key is new or an existing one that
was renewed, and the key name is in the resource ID of the event. Compare it
with the key names you expect for the app.
references:
- https://attack.mitre.org/techniques/T1098/001/
- https://learn.microsoft.com/en-us/azure/azure-functions/function-keys-how-to
- https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/web-and-mobile
author: Forestall
date: 2026-11-18
tags:
- attack.persistence
- attack.privilege-escalation
- attack.t1098.001
logsource:
product: azure
service: activitylogs
detection:
selection:
OperationNameValue:
- MICROSOFT.WEB/SITES/HOST/FUNCTIONKEYS/WRITE
- MICROSOFT.WEB/SITES/HOST/SYSTEMKEYS/WRITE
- MICROSOFT.WEB/SITES/FUNCTIONS/KEYS/WRITE
- MICROSOFT.WEB/SITES/SLOTS/HOST/FUNCTIONKEYS/WRITE
- MICROSOFT.WEB/SITES/SLOTS/HOST/SYSTEMKEYS/WRITE
- MICROSOFT.WEB/SITES/SLOTS/FUNCTIONS/KEYS/WRITE
ActivityStatusValue:
- Success
- Succeeded
condition: selection
falsepositives:
- Scheduled key rotation, and infrastructure-as-code or deployment pipelines that set keys for an app. Exclude their identities in a filter_ selection by Caller once confirmed.
- Administrators who create a key for a new client of the app. Match the event to a request.
level: low
False positives
- Scheduled key rotation, and infrastructure-as-code or deployment pipelines that set keys for an app. Exclude their identities in a filter_ selection by Caller once confirmed.
- Administrators who create a key for a new client of the app. Match the event to a request.
Function or App Deployment Source Changed Through Resource Manager
Detects a successful write of a function of an Azure function app (microsoft.web/sites/functions/write) or of the source control settings of a web app or function app (Microsoft.Web/sites/sourcecontrols/Write, also on deployment slots) through Azure Resource Manager. Both change what code the app runs, and that code runs with the app's managed identity and settings. The rule matches on the operation names only, which is why its level is low. Microsoft does not document which Activity log operations each deployment method produces, and a deployment that is pushed to the app's SCM endpoint does not pass through Azure Resource Manager at all, so the rule sees part of the code changes and release pipelines produce the same events. Use it for a baseline of expected callers for each app.
title: Function or App Deployment Source Changed Through Resource Manager
id: 541f85b4-3514-4e98-b0b4-bd9fab91360b
status: experimental
description: >-
Detects a successful write of a function of an Azure function app
(microsoft.web/sites/functions/write) or of the source control settings of a
web app or function app (Microsoft.Web/sites/sourcecontrols/Write, also on
deployment slots) through Azure Resource Manager. Both change what code the
app runs, and that code runs with the app's managed identity and settings.
The rule matches on the operation names only, which is why its level is
low. Microsoft does not document which Activity log operations each
deployment method produces, and a deployment that is pushed to the app's
SCM endpoint does not pass through Azure Resource Manager at all, so the
rule sees part of the code changes and release pipelines produce the same
events. Use it for a baseline of expected callers for each app.
references:
- https://attack.mitre.org/techniques/T1648/
- https://learn.microsoft.com/en-us/azure/azure-functions/functions-deployment-technologies
- https://learn.microsoft.com/en-us/azure/app-service/deploy-continuous-deployment
- https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/web-and-mobile
author: Forestall
date: 2026-11-18
tags:
- attack.execution
- attack.t1648
logsource:
product: azure
service: activitylogs
detection:
selection:
OperationNameValue:
- MICROSOFT.WEB/SITES/FUNCTIONS/WRITE
- MICROSOFT.WEB/SITES/SOURCECONTROLS/WRITE
- MICROSOFT.WEB/SITES/SLOTS/SOURCECONTROLS/WRITE
ActivityStatusValue:
- Success
- Succeeded
condition: selection
falsepositives:
- Release pipelines, developer tools and the portal editor, which write functions and deployment settings as part of normal work. Exclude their identities in a filter_ selection by Caller, per app where possible.
level: low
False positives
- Release pipelines, developer tools and the portal editor, which write functions and deployment settings as part of normal work. Exclude their identities in a filter_ selection by Caller, per app where possible.
Triage
- Identify the Caller, the caller's IP address and the app, and whether this identity deploys to this app or manages its keys routinely. Pipelines and infrastructure-as-code tools do.
- For a key write, list the keys of the app and its functions and look for names you do not know. The resource ID of the event names the key.
- For a source control or function write, read the app's current deployment source, repository and branch, and compare the functions of the app with the last approved release.
- Check which managed identity the app has and review its activity after the change.
- Look for the keys or the publishing profile of the same app being listed by the same caller in the same period.
Response
Once the attack is confirmed:
- Delete keys that nobody can explain and renew the others, the master key included, then update the clients that call the app.
- Set the deployment source back and redeploy the app from the approved release.
- Contain the caller. Revoke its sessions, rotate its credentials and remove its role on the app.
- Rotate the secrets in the app's settings and review what the app's managed identity did after the change.
- Review the app's request logs for calls made with the new key.
Mitigation
- Protect HTTP functions with Microsoft Entra authentication on the app where clients allow it, and treat access keys as a second line.
- Limit Owner, Contributor and Website Contributor on function apps, and assign them through Privileged Identity Management.
- Give the app's managed identity only the rights its functions need.
- Rotate the access keys of important apps on a schedule and compare the list of key names with the ones you expect.
- Deploy only from a pipeline with a protected branch, and watch changes to the app's deployment source.
Frequently asked questions
Why does a new function key matter when the attacker already has a role on the app?
The role can be taken away in one step, and its use shows in sign-in and activity logs. A key is a shared secret that calls the app's functions with no Microsoft Entra sign-in. Microsoft documents that keys have their own lifecycle and must be explicitly rotated or deleted to revoke them, so a key that was added during an intrusion keeps working after the cleanup of roles.
Do these rules see every code deployment to a function app?
No. They see the Azure Resource Manager operations that write a function, the source control settings and the keys. A deployment that is pushed to the app's SCM endpoint does not pass through Azure Resource Manager. Microsoft does not document which Activity log operations each deployment method produces, so treat the rules as partial and compare the deployed code with your release.
Why are both rules low?
They match on operation names only. The event does not say whether a key is new or renewed, or what changed in a function. Deployment pipelines produce the same events on every release. The rules are meant for a baseline of expected callers for each app, and a write from an identity outside that baseline is the case to look at.
What can the master key of a function app do?
Microsoft describes the master key, named _master, as a special host key that also provides administrative access to the runtime REST APIs of the function app, and warns not to share it. It is required for the endpoints under the admin path of the app. Renew it whenever the keys of an app may have been exposed.
References
- MITRE ATT&CK T1648: Serverless Execution
- MITRE ATT&CK T1098.001: Additional Cloud Credentials
- Work with access keys in Azure Functions
- Deployment technologies in Azure Functions
- Configure continuous deployment to Azure App Service
- Use managed identities for App Service and Azure Functions
- Azure permissions for Web and Mobile
- Azure Activity Log event schema