Para más información sobre este servicio, consulta:
{{#ref}}
../az-services/az-static-web-apps.md
@@ -12,164 +12,153 @@ For more information about this service check:
### Microsoft.Web/staticSites/snippets/write
It's possible to make a static web page load arbitary HTML code by creating a snippet. This could allow an attacker to inject JS code inside the web app and steal sensitive information such as credentials or mnemonic keys (in web3 wallets).
The fllowing command create an snippet that will always be loaded by the web app::
Es posible hacer que una página web estática cargue código HTML arbitrario creando un snippet. Esto podría permitir a un atacante inyectar código JS dentro de la aplicación web y robar información sensible como credenciales o claves mnemotécnicas (en billeteras web3).
El siguiente comando crea un snippet que siempre será cargado por la aplicación web::
Running the following command it's possible to **read the third party credentials** configured in the current account. Note that if for example some Github credentials are configured in a different user, you won't be able to access the token from a different one.
Ejecutando el siguiente comando es posible **leer las credenciales de terceros** configuradas en la cuenta actual. Ten en cuenta que si, por ejemplo, algunas credenciales de Github están configuradas en un usuario diferente, no podrás acceder al token desde otro.
Es posible **sobrescribir un archivo dentro del repositorio de Github** que contiene la aplicación a través de Azure enviando un **token de Github** en una solicitud como la siguiente, que indicará la ruta del archivo a sobrescribir, el contenido del archivo y el mensaje de confirmación.
It's possible to **overwrite a file inside the Github repo** containing the app through Azure having the **Github token** sending a request such as the following which will indicate the path of the file to overwrite, the content of the file and the commit message.
This can be abused by attackers to basically **change the content of the web app** to serve malicious content (steal credentials, mnemonic keys...) or just to **re-route certain paths** to their own servers by overwriting the `staticwebapp.config.json` file.
Esto puede ser abusado por atacantes para básicamente **cambiar el contenido de la aplicación web** para servir contenido malicioso (robar credenciales, claves mnemotécnicas...) o simplemente para **redirigir ciertas rutas** a sus propios servidores sobrescribiendo el archivo `staticwebapp.config.json`.
> [!WARNING]
> Note that if an attacker manages to compromise the Github repo in any way, they can also overwrite the file directly from Github.
> Tenga en cuenta que si un atacante logra comprometer el repositorio de Github de alguna manera, también puede sobrescribir el archivo directamente desde Github.
```bash
curl -X PUT "https://functions.azure.com/api/github/updateGitHubContent"\
-H "Content-Type: application/json"\
-d '{
"commit": {
"message": "Update static web app route configuration",
With this permission, it's possible to **modify the password** protecting a static web app or even unprotect every environment by sending a request such as the following:
Con este permiso, es posible **modificar la contraseña** que protege una aplicación web estática o incluso desproteger cada entorno enviando una solicitud como la siguiente:
Luego, para **actualizar una aplicación usando el token** podrías ejecutar el siguiente comando. Ten en cuenta que este comando fue extraído al verificar **cómo funciona Github Action [https://github.com/Azure/static-web-apps-deploy](https://github.com/Azure/static-web-apps-deploy)**, ya que es el que Azure establece por defecto para usar. Así que la imagen y los parámetros podrían cambiar en el futuro.
Then, in order to **update an app using the token** you could run the following command. Note that this command was extracted checking **how to Github Action [https://github.com/Azure/static-web-apps-deploy](https://github.com/Azure/static-web-apps-deploy) works**, as it's the one Azure set by default ot use. So the image and paarements could change in the future.
1. Download the repo [https://github.com/staticwebdev/react-basic](https://github.com/staticwebdev/react-basic) (or any other repo you want to deploy) and run `cd react-basic`.
2. Change the code you want to deploy
3. Deploy it running (Remember to change the `<api-token>`):
> [!TIP]
> Para desplegar la aplicación podrías usar la herramienta **`swa`** de [https://azure.github.io/static-web-apps-cli/docs/cli/swa-deploy#deployment-token](https://azure.github.io/static-web-apps-cli/docs/cli/swa-deploy#deployment-token) o seguir los siguientes pasos en bruto:
1. Descarga el repositorio [https://github.com/staticwebdev/react-basic](https://github.com/staticwebdev/react-basic) (o cualquier otro repositorio que desees desplegar) y ejecuta `cd react-basic`.
2. Cambia el código que deseas desplegar.
3. Despliega ejecutando (Recuerda cambiar el `<api-token>`):
> Even if you have the token you won't be able to deploy the app if the **Deployment Authorization Policy** is set to **Github**. For using the token you will need the permission `Microsoft.Web/staticSites/write` to change the deployment method to use th APi token.
> [!WARNING]
> Incluso si tienes el token, no podrás desplegar la aplicación si la **Política de Autorización de Despliegue** está configurada en **Github**. Para usar el token, necesitarás el permiso `Microsoft.Web/staticSites/write` para cambiar el método de despliegue y usar el token de la API.
### Microsoft.Web/staticSites/write
With this permission it's possible to **change the source of the static web app to a different Github repository**, however, it won't be automatically provisioned as this must be done from a Github Action.
Con este permiso es posible **cambiar la fuente de la aplicación web estática a un repositorio de Github diferente**, sin embargo, no se aprovisionará automáticamente ya que esto debe hacerse desde una Acción de Github.
However, if the **Deployment Authotization Policy** is set to**Github**, it's possible to **update the app from the new source repository!**.
In case the **Deployment Authorization Policy** is not set to Github, you can change it with the same permission `Microsoft.Web/staticSites/write`.
Sin embargo, si la **Política de Autorización de Despliegue** está configurada en**Github**, ¡es posible **actualizar la aplicación desde el nuevo repositorio fuente!**.
En caso de que la **Política de Autorización de Despliegue** no esté configurada en Github, puedes cambiarla con el mismo permiso `Microsoft.Web/staticSites/write`.
```bash
# Change the source to a different Github repository
az staticwebapp update --name my-first-static-web-app --resource-group Resource_Group_1 --source https://github.com/carlospolop/my-first-static-web-app -b main
"repositoryToken": "<github_token>" # az rest --method GET --url "https://management.azure.com/providers/Microsoft.Web/sourcecontrols?api-version=2024-04-01"
}
"properties": {
"allowConfigFileUpdates": true,
"stagingEnvironmentPolicy": "Enabled",
"buildProperties": {
"appLocation": "/",
"apiLocation": "",
"appArtifactLocation": "build"
},
"deploymentAuthPolicy": "GitHub",
"repositoryToken": "<github_token>" # az rest --method GET --url "https://management.azure.com/providers/Microsoft.Web/sourcecontrols?api-version=2024-04-01"
}
}'
```
Example Github Action to deploy the app:
Ejemplo de Github Action para desplegar la aplicación:
azure_static_web_apps_api_token:"12345cbb198a77a092ff885782a62a15d5aef5e3654cac1234509ab54547270704-4140ccee-e04f-424f-b4ca-3d4dd123459c00f0702071d12345"# A valid formatted token is needed although it won't be used for authentication
action:"upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location:"/"# App source code path
api_location:""# Api source code path - optional
output_location:"build"# Built app content directory - optional
azure_static_web_apps_api_token:"12345cbb198a77a092ff885782a62a15d5aef5e3654cac1234509ab54547270704-4140ccee-e04f-424f-b4ca-3d4dd123459c00f0702071d12345"# A valid formatted token is needed although it won't be used for authentication
action:"upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location:"/"# App source code path
api_location:""# Api source code path - optional
output_location:"build"# Built app content directory - optional
With this permision it's possible to **reset the API key of the static web app** potentially DoSing the workflows that automatically deploy the app.
Con este permiso es posible **restablecer la clave API de la aplicación web estática**, potencialmente DoSing los flujos de trabajo que implementan automáticamente la aplicación.
This permission allows to**create an invitation to a user**to access protected paths inside a static web app ith a specific given role.
The login is located in a path such as `/.auth/login/github` for github or `/.auth/login/aad` for Entra ID and a user can be invited with the following command:
Este permiso permite**crear una invitación a un usuario**para acceder a rutas protegidas dentro de una aplicación web estática con un rol específico dado.
El inicio de sesión se encuentra en una ruta como `/.auth/login/github` para github o `/.auth/login/aad` para Entra ID y un usuario puede ser invitado con el siguiente comando:
--domain mango-beach-071d9340f.4.azurestaticapps.net # Domain of the app \
--invitation-expiration-in-hours 168# 7 days is max \
--name my-first-static-web-app # Name of the app\
--roles "contributor,administrator"# Comma sepparated list of roles\
--user-details username # Github username in this case\
--resource-group Resource_Group_1 # Resource group of the app
```
### Pull Requests
By default Pull Requests from a branch in the same repo will be automatically compiled and build in a staging environment. This could be abused by an attacker with write access over the repo but without being able to bypass branch protections of the production branch (usually`main`) to**deploy a malicious version of the app**in the statagging URL.
Por defecto, las Pull Requests de una rama en el mismo repositorio se compilarán y construirán automáticamente en un entorno de staging. Esto podría ser abusado por un atacante con acceso de escritura sobre el repositorio pero sin poder eludir las protecciones de rama de la rama de producción (generalmente`main`) para**desplegar una versión maliciosa de la app**en la URL de staging.
The staging URL has this format: `https://<app-subdomain>-<PR-num>.<region>.<res-of-app-domain>`like: `https://ambitious-plant-0f764e00f-2.eastus2.4.azurestaticapps.net`
La URL de staging tiene este formato: `https://<app-subdomain>-<PR-num>.<region>.<res-of-app-domain>`como: `https://ambitious-plant-0f764e00f-2.eastus2.4.azurestaticapps.net`
> [!TIP]
> Note that by default external PRs won't run workflows unless they have merged at least 1 PR into the repository. An attacker could send a valid PR to the repo and **then send a malicious PR** to the repo to deploy the malicious app in the stagging environment. HOWEVER, there is an unexpected protection, the default Github Action to deploy into the static web app need access to the secret containing the deployment token (like `secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_PLANT_0F764E00F`) eve if the deployment is done with the IDToken. This means that because an external PR won't have access to this secret and an external PR cannot change the Workflow to place here an arbitrary token without a PR getting accepted, **this attack won't really work**.
> Ten en cuenta que, por defecto, las PR externas no ejecutarán flujos de trabajo a menos que hayan fusionado al menos 1 PR en el repositorio. Un atacante podría enviar una PR válida al repositorio y **luego enviar una PR maliciosa** al repositorio para desplegar la app maliciosa en el entorno de staging. SIN EMBARGO, hay una protección inesperada, la acción de Github por defecto para desplegar en la aplicación web estática necesita acceso al secreto que contiene el token de despliegue (como `secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_PLANT_0F764E00F`) incluso si el despliegue se realiza con el IDToken. Esto significa que, dado que una PR externa no tendrá acceso a este secreto y una PR externa no puede cambiar el flujo de trabajo para colocar aquí un token arbitrario sin que una PR sea aceptada, **este ataque realmente no funcionará**.
Esta es una extensión de VM que permitiría ejecutar runbooks en VMs desde una cuenta de automatización. Para más información, consulta el [servicio de Cuentas de Automatización](../az-services/az-automation-account/index.html).
Esta es una extensión de VM que permitiría ejecutar runbooks en VMs desde una cuenta de automatización. Para más información, consulta el [Automation Accounts service](../az-services/az-automation-account/index.html).
</details>
@@ -308,7 +308,7 @@ Este permiso permite a un usuario **iniciar sesión como usuario en una VM a tra
Inicie sesión a través de **SSH** con **`az ssh vm --name <vm-name> --resource-group <rsc-group>`** y a través de **RDP** con sus **credenciales regulares de Azure**.
Todos estos son los permisos necesarios para **crear una VM con una identidad administrada específica** y dejar un **puerto abierto** (22 en este caso). Esto permite a un usuario crear una VM y conectarse a ella y **robar tokens de identidad administrada** para escalar privilegios a ella.
Entonces, el atacante necesita haber **comprometido de alguna manera la VM** para robar tokens de las identidades administradas asignadas. Consulta **más información en**:
Luego, el atacante necesita haber **comprometido de alguna manera la VM** para robar tokens de las identidades administradas asignadas. Consulta **más información en**:
Según la [**documentación**](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/compute#microsoftcompute), este permiso te permite gestionar el sistema operativo de tu recurso a través de Windows Admin Center como administrador. Así que parece que esto da acceso al WAC para controlar las VMs...
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.