mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-05 01:07:11 -08:00
Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az
This commit is contained in:
@@ -2,114 +2,113 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Informazioni di base
|
||||
|
||||
**Azure Function Apps** are a **serverless compute service** that allow you to run small pieces of code, called **functions**, without managing the underlying infrastructure. They are designed to execute code in response to various triggers, such as **HTTP requests, timers, or events from other Azure services** like Blob Storage or Event Hubs. Function Apps support multiple programming languages, including C#, Python, JavaScript, and Java, making them versatile for building **event-driven applications**, automating workflows, or integrating services. They are cost-effective, as you usually only pay for the compute time used when your code runs.
|
||||
**Azure Function Apps** sono un **servizio di calcolo serverless** che consente di eseguire piccoli pezzi di codice, chiamati **funzioni**, senza gestire l'infrastruttura sottostante. Sono progettate per eseguire codice in risposta a vari trigger, come **richieste HTTP, timer o eventi da altri servizi Azure** come Blob Storage o Event Hubs. Le Function Apps supportano più linguaggi di programmazione, tra cui C#, Python, JavaScript e Java, rendendole versatili per costruire **applicazioni basate su eventi**, automatizzare flussi di lavoro o integrare servizi. Sono economiche, poiché di solito si paga solo per il tempo di calcolo utilizzato quando il codice viene eseguito.
|
||||
|
||||
> [!NOTE]
|
||||
> Note that **Functions are a subset of the App Services**, therefore, a lot of the features discussed here will be used also by applications created as Azure Apps (`webapp` in cli).
|
||||
> Nota che **le Funzioni sono un sottoinsieme dei Servizi App**, pertanto, molte delle funzionalità discusse qui saranno utilizzate anche dalle applicazioni create come Azure Apps (`webapp` in cli).
|
||||
|
||||
### Different Plans
|
||||
### Piani diversi
|
||||
|
||||
- **Flex Consumption Plan**: Offers **dynamic, event-driven scaling** with pay-as-you-go pricing, adding or removing function instances based on demand. It supports **virtual networking** and **pre-provisioned instances** to reduce cold starts, making it suitable for **variable workloads** that don’t require container support.
|
||||
- **Traditional Consumption Plan**: The default serverless option, where you **pay only for compute resources when functions run**. It automatically scales based on incoming events and includes **cold start optimizations**, but does not support container deployments. Ideal for **intermittent workloads** requiring automatic scaling.
|
||||
- **Premium Plan**: Designed for **consistent performance**, with **prewarmed workers** to eliminate cold starts. It offers **extended execution times, virtual networking**, and supports **custom Linux images**, making it perfect for **mission-critical applications** needing high performance and advanced features.
|
||||
- **Dedicated Plan**: Runs on dedicated virtual machines with **predictable billing** and supports manual or automatic scaling. It allows running multiple apps on the same plan, provides **compute isolation**, and ensures **secure network access** via App Service Environments, making it ideal for **long-running applications** needing consistent resource allocation.
|
||||
- **Container Apps**: Enables deploying **containerized function apps** in a managed environment, alongside microservices and APIs. It supports custom libraries, legacy app migration, and **GPU processing**, eliminating Kubernetes cluster management. Ideal for **event-driven, scalable containerized applications**.
|
||||
- **Piano di consumo flessibile**: Offre **scalabilità dinamica e basata su eventi** con prezzi pay-as-you-go, aggiungendo o rimuovendo istanze di funzione in base alla domanda. Supporta **rete virtuale** e **istanze pre-provisionate** per ridurre i cold start, rendendolo adatto per **carichi di lavoro variabili** che non richiedono supporto per container.
|
||||
- **Piano di consumo tradizionale**: L'opzione serverless predefinita, in cui **si paga solo per le risorse di calcolo quando le funzioni vengono eseguite**. Si scala automaticamente in base agli eventi in arrivo e include **ottimizzazioni per i cold start**, ma non supporta le distribuzioni di container. Ideale per **carichi di lavoro intermittenti** che richiedono scalabilità automatica.
|
||||
- **Piano Premium**: Progettato per **prestazioni costanti**, con **lavoratori pre-riscaldati** per eliminare i cold start. Offre **tempi di esecuzione estesi, rete virtuale** e supporta **immagini Linux personalizzate**, rendendolo perfetto per **applicazioni critiche** che necessitano di alte prestazioni e funzionalità avanzate.
|
||||
- **Piano Dedicato**: Esegue su macchine virtuali dedicate con **fatturazione prevedibile** e supporta scalabilità manuale o automatica. Consente di eseguire più app sullo stesso piano, fornisce **isolamento di calcolo** e garantisce **accesso sicuro alla rete** tramite App Service Environments, rendendolo ideale per **applicazioni a lungo termine** che necessitano di allocazione costante delle risorse.
|
||||
- **Container Apps**: Consente di distribuire **app di funzione containerizzate** in un ambiente gestito, insieme a microservizi e API. Supporta librerie personalizzate, migrazione di app legacy e **elaborazione GPU**, eliminando la gestione del cluster Kubernetes. Ideale per **applicazioni containerizzate scalabili e basate su eventi**.
|
||||
|
||||
### **Storage Buckets**
|
||||
### **Bucket di archiviazione**
|
||||
|
||||
When creating a new Function App not containerised (but giving the code to run), the **code and other Function related data will be stored in a Storage account**. By default the web console will create a new one per function to store the code.
|
||||
Quando si crea una nuova Function App non containerizzata (ma si fornisce il codice da eseguire), il **codice e altri dati relativi alla funzione saranno memorizzati in un account di archiviazione**. Per impostazione predefinita, la console web creerà un nuovo account per ogni funzione per memorizzare il codice.
|
||||
|
||||
Moreover, modifying the code inside the bucket (in the different formats it could be stored), the **code of the app will be modified to the new one and executed** next time the Function is called.
|
||||
Inoltre, modificando il codice all'interno del bucket (nei diversi formati in cui potrebbe essere memorizzato), il **codice dell'app verrà modificato con il nuovo e verrà eseguito** la prossima volta che la funzione viene chiamata.
|
||||
|
||||
> [!CAUTION]
|
||||
> This is very interesting from an attackers perspective as **write access over this bucket** will allow an attacker to **compromise the code and escalate privileges** to the managed identities inside the Function App.
|
||||
> Questo è molto interessante dal punto di vista di un attaccante poiché **l'accesso in scrittura su questo bucket** consentirà a un attaccante di **compromettere il codice e aumentare i privilegi** alle identità gestite all'interno della Function App.
|
||||
>
|
||||
> More on this in the **privilege escalation section**.
|
||||
> Maggiori informazioni su questo nella **sezione sull'escalation dei privilegi**.
|
||||
|
||||
It's also possible to find the **master and functions keys** stored in the storage account in the container **`azure-webjobs-secrets`** inside the folder **`<app-name>`** in the JSON files you can find inside.
|
||||
È anche possibile trovare le **chiavi master e delle funzioni** memorizzate nell'account di archiviazione nel container **`azure-webjobs-secrets`** all'interno della cartella **`<app-name>`** nei file JSON che puoi trovare all'interno.
|
||||
|
||||
Note that Functions also allow to store the code in a remote location just indicating the URL to it.
|
||||
Nota che le Funzioni consentono anche di memorizzare il codice in una posizione remota semplicemente indicando l'URL.
|
||||
|
||||
### Networking
|
||||
|
||||
Using a HTTP trigger:
|
||||
Utilizzando un trigger HTTP:
|
||||
|
||||
- It's possible to give **access to a function to from all Internet** without requiring any authentication or give access IAM based. Although it’s also possible to restrict this access.
|
||||
- It's also possible to **give or restrict access** to a Function App from **an internal network (VPC)**.
|
||||
- È possibile dare **accesso a una funzione da tutto Internet** senza richiedere alcuna autenticazione o dare accesso basato su IAM. Sebbene sia anche possibile limitare questo accesso.
|
||||
- È anche possibile **dare o limitare l'accesso** a una Function App da **una rete interna (VPC)**.
|
||||
|
||||
> [!CAUTION]
|
||||
> This is very interesting from an attackers perspective as it might be possible to **pivot to internal networks** from a vulnerable Function exposed to the Internet.
|
||||
> Questo è molto interessante dal punto di vista di un attaccante poiché potrebbe essere possibile **pivotare verso reti interne** da una Function vulnerabile esposta a Internet.
|
||||
|
||||
### **Function App Settings & Environment Variables**
|
||||
### **Impostazioni della Function App e variabili di ambiente**
|
||||
|
||||
It's possible to configure environment variables inside an app, which could contain sensitive information. Moreover, by default the env variables **`AzureWebJobsStorage`** and **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** (among others) are created. These are specially interesting because they **contain the account key to control with FULL permissions the storage account containing the data of the application**. These settings are also needed to execute the code from the Storage Account.
|
||||
È possibile configurare variabili di ambiente all'interno di un'app, che potrebbero contenere informazioni sensibili. Inoltre, per impostazione predefinita, le variabili di ambiente **`AzureWebJobsStorage`** e **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** (tra le altre) vengono create. Queste sono particolarmente interessanti perché **contengono la chiave dell'account per controllare con PERMESSI COMPLETI l'account di archiviazione contenente i dati dell'applicazione**. Queste impostazioni sono anche necessarie per eseguire il codice dall'Account di Archiviazione.
|
||||
|
||||
These env variables or configuration parameters also controls how the Function execute the code, for example if **`WEBSITE_RUN_FROM_PACKAGE`** exists, it'll indicate the URL where the code of the application is located.
|
||||
Queste variabili di ambiente o parametri di configurazione controllano anche come la Funzione esegue il codice, ad esempio se **`WEBSITE_RUN_FROM_PACKAGE`** esiste, indicherà l'URL in cui si trova il codice dell'applicazione.
|
||||
|
||||
### **Function Sandbox**
|
||||
### **Sandbox della Funzione**
|
||||
|
||||
Inside the linux sandbox the source code is located in **`/home/site/wwwroot`** in the file **`function_app.py`** (if python is used) the user running the code is **`app`** (without sudo permissions).
|
||||
All'interno della sandbox linux, il codice sorgente si trova in **`/home/site/wwwroot`** nel file **`function_app.py`** (se viene utilizzato Python) l'utente che esegue il codice è **`app`** (senza permessi sudo).
|
||||
|
||||
In a **Windows** function using NodeJS the code was located in **`C:\home\site\wwwroot\HttpTrigger1\index.js`**, the username was **`mawsFnPlaceholder8_f_v4_node_20_x86`** and was part of the **groups**: `Mandatory Label\High Mandatory Level Label`, `Everyone`, `BUILTIN\Users`, `NT AUTHORITY\INTERACTIVE`, `CONSOLE LOGON`, `NT AUTHORITY\Authenticated Users`, `NT AUTHORITY\This Organization`, `BUILTIN\IIS_IUSRS`, `LOCAL`, `10-30-4-99\Dwas Site Users`.
|
||||
In una **funzione Windows** che utilizza NodeJS, il codice si trovava in **`C:\home\site\wwwroot\HttpTrigger1\index.js`**, il nome utente era **`mawsFnPlaceholder8_f_v4_node_20_x86`** ed era parte dei **gruppi**: `Mandatory Label\High Mandatory Level Label`, `Everyone`, `BUILTIN\Users`, `NT AUTHORITY\INTERACTIVE`, `CONSOLE LOGON`, `NT AUTHORITY\Authenticated Users`, `NT AUTHORITY\This Organization`, `BUILTIN\IIS_IUSRS`, `LOCAL`, `10-30-4-99\Dwas Site Users`.
|
||||
|
||||
### **Managed Identities & Metadata**
|
||||
### **Identità gestite e metadati**
|
||||
|
||||
Just like [**VMs**](vms/), Functions can have **Managed Identities** of 2 types: System assigned and User assigned.
|
||||
Proprio come [**VM**](vms/), le Funzioni possono avere **Identità Gestite** di 2 tipi: Assegnate dal sistema e Assegnate dall'utente.
|
||||
|
||||
The **system assigned** one will be a managed identity that **only the function** that has it assigned would be able to use, while the **user assigned** managed identities are managed identities that **any other Azure service will be able to use**.
|
||||
L'**identità assegnata dal sistema** sarà un'identità gestita che **solo la funzione** a cui è assegnata potrà utilizzare, mentre le **identità gestite assegnate dall'utente** sono identità gestite che **qualsiasi altro servizio Azure potrà utilizzare**.
|
||||
|
||||
> [!NOTE]
|
||||
> Just like in [**VMs**](vms/), Functions can have **1 system assigned** managed identity and **several user assigned** ones, so it's always important to try to find all of them if you compromise the function because you might be able to escalate privileges to several managed identities from just one Function.
|
||||
> Proprio come in [**VM**](vms/), le Funzioni possono avere **1 identità gestita assegnata dal sistema** e **diverse identità assegnate dall'utente**, quindi è sempre importante cercare di trovare tutte se comprometti la funzione perché potresti essere in grado di aumentare i privilegi a diverse identità gestite da una sola Funzione.
|
||||
>
|
||||
> If a no system managed identity is used but one or more user managed identities are attached to a function, by default you won’t be able to get any token.
|
||||
> Se non viene utilizzata un'identità gestita dal sistema ma una o più identità gestite dall'utente sono collegate a una funzione, per impostazione predefinita non sarà possibile ottenere alcun token.
|
||||
|
||||
It's possible to use the [**PEASS scripts**](https://github.com/peass-ng/PEASS-ng) to get tokens from the default managed identity from the metadata endpoint. Or you could get them **manually** as explained in:
|
||||
È possibile utilizzare gli [**script PEASS**](https://github.com/peass-ng/PEASS-ng) per ottenere token dall'identità gestita predefinita dall'endpoint dei metadati. Oppure potresti ottenerli **manualmente** come spiegato in:
|
||||
|
||||
{% embed url="https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#azure-vm" %}
|
||||
|
||||
Note that you need to find out a way to **check all the Managed Identities a function has attached** as if you don't indicate it, the metadata endpoint will **only use the default one** (check the previous link for more info).
|
||||
Nota che devi trovare un modo per **controllare tutte le Identità Gestite a cui una funzione è collegata** poiché se non lo indichi, l'endpoint dei metadati utilizzerà **solo quella predefinita** (controlla il link precedente per ulteriori informazioni).
|
||||
|
||||
## Access Keys
|
||||
## Chiavi di accesso
|
||||
|
||||
> [!NOTE]
|
||||
> Note that there aren't RBAC permissions to give access to users to invoke the functions. The **function invocation depends on the trigger** selected when it was created and if a HTTP Trigger was selected, it might be needed to use an **access key**.
|
||||
> Nota che non ci sono permessi RBAC per dare accesso agli utenti per invocare le funzioni. L'**invocazione della funzione dipende dal trigger** selezionato quando è stata creata e se è stato selezionato un Trigger HTTP, potrebbe essere necessario utilizzare una **chiave di accesso**.
|
||||
|
||||
When creating an endpoint inside a function using a **HTTP trigger** it's possible to indicate the **access key authorization level** needed to trigger the function. Three options are available:
|
||||
Quando si crea un endpoint all'interno di una funzione utilizzando un **trigger HTTP**, è possibile indicare il **livello di autorizzazione della chiave di accesso** necessario per attivare la funzione. Sono disponibili tre opzioni:
|
||||
|
||||
- **ANONYMOUS**: **Everyone** can access the function by the URL.
|
||||
- **FUNCTION**: Endpoint is only accessible to users using a **function, host or master key**.
|
||||
- **ADMIN**: Endpoint is only accessible to users a **master key**.
|
||||
- **ANONYMOUS**: **Tutti** possono accedere alla funzione tramite l'URL.
|
||||
- **FUNCTION**: L'endpoint è accessibile solo agli utenti che utilizzano una **chiave di funzione, host o master**.
|
||||
- **ADMIN**: L'endpoint è accessibile solo agli utenti con una **chiave master**.
|
||||
|
||||
**Type of keys:**
|
||||
**Tipo di chiavi:**
|
||||
|
||||
- **Function Keys:** Function keys can be either default or user-defined and are designed to grant access exclusively to **specific function endpoints** within a Function App allowing a more fine-grained access over the endpoints.
|
||||
- **Host Keys:** Host keys, which can also be default or user-defined, provide access to **all function endpoints within a Function App with FUNCTION access level**.
|
||||
- **Master Key:** The master key (`_master`) serves as an administrative key that offers elevated permissions, including access to all function endpoints (ADMIN access lelvel included). This **key cannot be revoked.**
|
||||
- **System Keys:** System keys are **managed by specific extensions** and are required for accessing webhook endpoints used by internal components. Examples include the Event Grid trigger and Durable Functions, which utilize system keys to securely interact with their respective APIs.
|
||||
- **Chiavi di Funzione:** Le chiavi di funzione possono essere predefinite o definite dall'utente e sono progettate per concedere accesso esclusivamente a **endpoint di funzione specifici** all'interno di una Function App consentendo un accesso più dettagliato sugli endpoint.
|
||||
- **Chiavi Host:** Le chiavi host, che possono essere anch'esse predefinite o definite dall'utente, forniscono accesso a **tutti gli endpoint di funzione all'interno di una Function App con livello di accesso FUNCTION**.
|
||||
- **Chiave Master:** La chiave master (`_master`) funge da chiave amministrativa che offre permessi elevati, inclusi l'accesso a tutti gli endpoint di funzione (livello di accesso ADMIN incluso). Questa **chiave non può essere revocata.**
|
||||
- **Chiavi di Sistema:** Le chiavi di sistema sono **gestite da estensioni specifiche** e sono necessarie per accedere agli endpoint webhook utilizzati dai componenti interni. Esempi includono il trigger Event Grid e le Funzioni Durature, che utilizzano chiavi di sistema per interagire in modo sicuro con le rispettive API.
|
||||
|
||||
> [!TIP]
|
||||
> Example to access a function API endpoint using a key:
|
||||
> Esempio per accedere a un endpoint API di funzione utilizzando una chiave:
|
||||
>
|
||||
> `https://<function_uniq_name>.azurewebsites.net/api/<endpoint_name>?code=<access_key>`
|
||||
|
||||
### Basic Authentication
|
||||
### Autenticazione di base
|
||||
|
||||
Just like in App Services, Functions also support basic authentication to connect to **SCM** and **FTP** to deploy code using a **username and password in a URL** provided by Azure. More information about it in:
|
||||
Proprio come nei Servizi App, le Funzioni supportano anche l'autenticazione di base per connettersi a **SCM** e **FTP** per distribuire codice utilizzando un **nome utente e una password in un URL** fornito da Azure. Maggiori informazioni su questo in:
|
||||
|
||||
{{#ref}}
|
||||
az-app-service.md
|
||||
{{#endref}}
|
||||
|
||||
### Github Based Deployments
|
||||
### Distribuzioni basate su Github
|
||||
|
||||
When a function is generated from a Github repo Azure web console allows to **automatically create a Github Workflow in a specific repository** so whenever this repository is updated the code of the function is updated. Actually the Github Action yaml for a python function looks like this:
|
||||
Quando una funzione viene generata da un repo Github, la console web di Azure consente di **creare automaticamente un Workflow Github in un repository specifico** in modo che ogni volta che questo repository viene aggiornato, il codice della funzione venga aggiornato. In realtà, il file yaml dell'azione Github per una funzione Python appare così:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Github Action Yaml</summary>
|
||||
|
||||
```yaml
|
||||
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
|
||||
# More GitHub Actions for Azure: https://github.com/Azure/actions
|
||||
@@ -118,95 +117,93 @@ When a function is generated from a Github repo Azure web console allows to **au
|
||||
name: Build and deploy Python project to Azure Function App - funcGithub
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
AZURE_FUNCTIONAPP_PACKAGE_PATH: "." # set this to the path to your web app project, defaults to the repository root
|
||||
PYTHON_VERSION: "3.11" # set this to the python version to use (supports 3.6, 3.7, 3.8)
|
||||
AZURE_FUNCTIONAPP_PACKAGE_PATH: "." # set this to the path to your web app project, defaults to the repository root
|
||||
PYTHON_VERSION: "3.11" # set this to the python version to use (supports 3.6, 3.7, 3.8)
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python version
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
- name: Setup Python version
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: Create and start virtual environment
|
||||
run: |
|
||||
python -m venv venv
|
||||
source venv/bin/activate
|
||||
- name: Create and start virtual environment
|
||||
run: |
|
||||
python -m venv venv
|
||||
source venv/bin/activate
|
||||
|
||||
- name: Install dependencies
|
||||
run: pip install -r requirements.txt
|
||||
- name: Install dependencies
|
||||
run: pip install -r requirements.txt
|
||||
|
||||
# Optional: Add step to run tests here
|
||||
# Optional: Add step to run tests here
|
||||
|
||||
- name: Zip artifact for deployment
|
||||
run: zip release.zip ./* -r
|
||||
- name: Zip artifact for deployment
|
||||
run: zip release.zip ./* -r
|
||||
|
||||
- name: Upload artifact for deployment job
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: python-app
|
||||
path: |
|
||||
release.zip
|
||||
!venv/
|
||||
- name: Upload artifact for deployment job
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: python-app
|
||||
path: |
|
||||
release.zip
|
||||
!venv/
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
|
||||
permissions:
|
||||
id-token: write #This is required for requesting the JWT
|
||||
permissions:
|
||||
id-token: write #This is required for requesting the JWT
|
||||
|
||||
steps:
|
||||
- name: Download artifact from build job
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: python-app
|
||||
steps:
|
||||
- name: Download artifact from build job
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: python-app
|
||||
|
||||
- name: Unzip artifact for deployment
|
||||
run: unzip release.zip
|
||||
- name: Unzip artifact for deployment
|
||||
run: unzip release.zip
|
||||
|
||||
- name: Login to Azure
|
||||
uses: azure/login@v2
|
||||
with:
|
||||
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_6C3396368D954957BC58E4C788D37FD1 }}
|
||||
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_7E50AEF6222E4C3DA9272D27FB169CCD }}
|
||||
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_905358F484A74277BDC20978459F26F4 }}
|
||||
- name: Login to Azure
|
||||
uses: azure/login@v2
|
||||
with:
|
||||
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_6C3396368D954957BC58E4C788D37FD1 }}
|
||||
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_7E50AEF6222E4C3DA9272D27FB169CCD }}
|
||||
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_905358F484A74277BDC20978459F26F4 }}
|
||||
|
||||
- name: "Deploy to Azure Functions"
|
||||
uses: Azure/functions-action@v1
|
||||
id: deploy-to-function
|
||||
with:
|
||||
app-name: "funcGithub"
|
||||
slot-name: "Production"
|
||||
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
|
||||
- name: "Deploy to Azure Functions"
|
||||
uses: Azure/functions-action@v1
|
||||
id: deploy-to-function
|
||||
with:
|
||||
app-name: "funcGithub"
|
||||
slot-name: "Production"
|
||||
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
Moreover, a **Managed Identity** is also created so the Github Action from the repository will be able to login into Azure with it. This is done by generating a Federated credential over the **Managed Identity** allowing the **Issuer** `https://token.actions.githubusercontent.com` and the **Subject Identifier** `repo:<org-name>/<repo-name>:ref:refs/heads/<branch-name>`.
|
||||
Inoltre, viene creata un'**Identità Gestita** affinché l'azione di Github del repository possa accedere ad Azure con essa. Questo avviene generando una credenziale federata sull'**Identità Gestita** che consente all'**Emittente** `https://token.actions.githubusercontent.com` e all'**Identificatore del Soggetto** `repo:<org-name>/<repo-name>:ref:refs/heads/<branch-name>`.
|
||||
|
||||
> [!CAUTION]
|
||||
> Therefore, anyone compromising that repo will be able to compromise the function and the Managed Identities attached to it.
|
||||
> Pertanto, chiunque comprometta quel repository sarà in grado di compromettere la funzione e le Identità Gestite ad essa collegate.
|
||||
|
||||
### Container Based Deployments
|
||||
### Distribuzioni Basate su Container
|
||||
|
||||
Not all the plans allow to deploy containers, but for the ones that do, the configuration will contain the URL of the container. In the API the **`linuxFxVersion`** setting will ha something like: `DOCKER|mcr.microsoft.com/...`, while in the web console, the configuration will show the **image settings**.
|
||||
Non tutti i piani consentono di distribuire container, ma per quelli che lo fanno, la configurazione conterrà l'URL del container. Nell'API, l'impostazione **`linuxFxVersion`** avrà qualcosa come: `DOCKER|mcr.microsoft.com/...`, mentre nella console web, la configurazione mostrerà le **impostazioni dell'immagine**.
|
||||
|
||||
Moreover, **no source code will be stored in the storage** account related to the function as it's not needed.
|
||||
|
||||
## Enumeration
|
||||
Inoltre, **nessun codice sorgente sarà memorizzato nell'account di archiviazione** relativo alla funzione poiché non è necessario.
|
||||
|
||||
## Enumerazione
|
||||
```bash
|
||||
# List all the functions
|
||||
az functionapp list
|
||||
@@ -218,15 +215,15 @@ az functionapp show --name <app-name> --resource-group <res-group>
|
||||
|
||||
# Get details about the source of the function code
|
||||
az functionapp deployment source show \
|
||||
--name <app-name> \
|
||||
--resource-group <res-group>
|
||||
--name <app-name> \
|
||||
--resource-group <res-group>
|
||||
## If error like "This is currently not supported."
|
||||
## Then, this is probalby using a container
|
||||
|
||||
# Get more info if a container is being used
|
||||
az functionapp config container show \
|
||||
--name <name> \
|
||||
--resource-group <res-group>
|
||||
--name <name> \
|
||||
--resource-group <res-group>
|
||||
|
||||
# Get settings (and privesc to the sorage account)
|
||||
az functionapp config appsettings list --name <app-name> --resource-group <res-group>
|
||||
@@ -242,7 +239,7 @@ az functionapp config access-restriction show --name <app-name> --resource-group
|
||||
|
||||
# Get more info about a function (invoke_url_template is the URL to invoke and script_href allows to see the code)
|
||||
az rest --method GET \
|
||||
--url "https://management.azure.com/subscriptions/<subscription>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/functions?api-version=2024-04-01"
|
||||
--url "https://management.azure.com/subscriptions/<subscription>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/functions?api-version=2024-04-01"
|
||||
|
||||
# Get source code with Master Key of the function
|
||||
curl "<script_href>?code=<master-key>"
|
||||
@@ -252,19 +249,14 @@ curl "https://newfuncttest123.azurewebsites.net/admin/vfs/home/site/wwwroot/func
|
||||
# Get source code
|
||||
az rest --url "https://management.azure.com/<subscription>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/hostruntime/admin/vfs/function_app.py?relativePath=1&api-version=2022-03-01"
|
||||
```
|
||||
|
||||
## Privilege Escalation
|
||||
## Escalation dei privilegi
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-functions-app-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## Riferimenti
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/azure-functions/functions-openapi-definition](https://learn.microsoft.com/en-us/azure/azure-functions/functions-openapi-definition)
|
||||
- [https://learn.microsoft.com/it-it/azure/azure-functions/functions-openapi-definition](https://learn.microsoft.com/it-it/azure/azure-functions/functions-openapi-definition)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user