Az - Static Web Apps
Reading time: 7 minutes
tip
AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE)
Azure 해킹 배우기 및 연습하기:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks 지원하기
- 구독 계획 확인하기!
- **💬 Discord 그룹 또는 텔레그램 그룹에 참여하거나 Twitter 🐦 @hacktricks_live를 팔로우하세요.
- HackTricks 및 HackTricks Cloud 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.
Static Web Apps Basic Information
Azure Static Web Apps는 GitHub와 같은 리포지토리에서 자동 CI/CD를 통해 정적 웹 앱을 호스팅하는 클라우드 서비스입니다. 전 세계 콘텐츠 배포, 서버리스 백엔드 및 내장 HTTPS를 제공하여 안전하고 확장 가능합니다. 그러나 서비스가 "정적"이라고 해서 완전히 안전하다는 의미는 아닙니다. 위험 요소로는 잘못 구성된 CORS, 불충분한 인증 및 콘텐츠 변조가 있으며, 적절히 관리되지 않으면 XSS 및 데이터 유출과 같은 공격에 노출될 수 있습니다.
Deployment Authentication
tip
Static App이 생성될 때 배포 인증 정책으로 배포 토큰과 GitHub Actions 워크플로우 중에서 선택할 수 있습니다.
- 배포 토큰: 토큰이 생성되어 배포 프로세스를 인증하는 데 사용됩니다. 이 토큰만 있으면 앱의 새 버전을 배포할 수 있습니다. 리포지토리가 업데이트될 때마다 앱의 새 버전을 배포하기 위해 비밀에 토큰이 포함된 Github Action이 자동으로 리포에 배포됩니다.
- GitHub Actions 워크플로우: 이 경우 매우 유사한 Github Action이 리포에 배포되며 토큰도 비밀에 저장됩니다. 그러나 이 Github Action은
actions/github-script@v6
액션을 사용하여 리포지토리의 IDToken을 가져오고 이를 사용하여 앱을 배포하는 차이점이 있습니다. - 두 경우 모두
Azure/static-web-apps-deploy@v1
액션이azure_static_web_apps_api_token
매개변수에 있는 토큰과 함께 사용되지만, 두 번째 경우에는github_id_token
매개변수의 IDToken으로 인증이 이루어지므로12345cbb198a77a092ff885781a62a15d51ef5e3654ca11234509ab54547270704-4140ccee-e04f-424f-b4ca-3d4dd123459c00f0702071d12345
와 같은 유효한 형식의 임의 토큰만으로도 앱을 배포할 수 있습니다.
Web App Basic Authentication
웹 앱에 접근하기 위해 비밀번호를 구성할 수 있습니다. 웹 콘솔을 통해 스테이징 환경만 보호하거나 스테이징 및 프로덕션 환경 모두를 보호하도록 구성할 수 있습니다.
작성 시점에서 비밀번호로 보호된 웹 앱은 다음과 같습니다:

어떤 비밀번호가 사용되고 있는지 및 어떤 환경이 보호되고 있는지 확인할 수 있습니다:
az rest --method GET \
--url "/subscriptions/<subscription-id>/resourceGroups/Resource_Group_1/providers/Microsoft.Web/staticSites/<app-name>/config/basicAuth?api-version=2024-04-01"
그러나, 이것은 비밀번호를 일반 텍스트로 표시하지 않습니다, 단지 다음과 같은 형태로 표시됩니다: "password": "**********************"
.
### 경로 및 역할
경로는 정적 웹 앱 내에서 수신 HTTP 요청이 처리되는 방법을 정의합니다. staticwebapp.config.json
파일에 구성되어 있으며, URL 재작성, 리디렉션, 접근 제한 및 역할 기반 권한 부여를 제어하여 적절한 리소스 처리 및 보안을 보장합니다.
몇 가지 예:
{
"routes": [
{
"route": "/",
"rewrite": "/index.html"
},
{
"route": "/about",
"rewrite": "/about.html"
},
{
"route": "/api/*",
"allowedRoles": ["authenticated"]
},
{
"route": "/admin",
"redirect": "/login",
"statusCode": 302
}
],
"navigationFallback": {
"rewrite": "/index.html",
"exclude": ["/api/*", "/assets/*"]
}
}
노트: 역할로 경로를 보호하는 것이 가능하다는 점에 유의하세요. 그러면 사용자는 앱에 인증하고 해당 역할을 부여받아야 경로에 접근할 수 있습니다. 또한, 초대장을 생성하여 특정 사용자에게 특정 역할을 부여하는 것도 가능하며, 이는 EntraID, Facebook, GitHub, Google, Twitter를 통해 로그인하는 사용자에게 유용할 수 있습니다. 이를 통해 앱 내에서 권한을 상승시킬 수 있습니다.
tip
앱을 구성하여 staticwebapp.config.json
파일에 대한 변경 사항이 수용되지 않도록 설정할 수 있다는 점에 유의하세요. 이 경우, 단순히 Github에서 파일을 변경하는 것만으로는 충분하지 않을 수 있으며, 앱의 설정을 변경해야 할 수도 있습니다.
스테이징 URL의 형식은 다음과 같습니다: https://<app-subdomain>-<PR-num>.<region>.<res-of-app-domain>
예: https://ambitious-plant-0f764e00f-2.eastus2.4.azurestaticapps.net
관리형 ID
Azure Static Web Apps는 관리형 ID를 사용하도록 구성할 수 있지만, 이 FAQ에서 언급했듯이, 인증 목적으로 Azure Key Vault에서 비밀을 추출하는 것만 지원되며, 다른 Azure 리소스에 접근하는 것은 지원되지 않습니다.
자세한 내용은 Azure 가이드를 참조하여 정적 앱에서 금고 비밀을 사용하는 방법을 확인할 수 있습니다: https://learn.microsoft.com/en-us/azure/static-web-apps/key-vault-secrets.
열거
{% tabs %} {% tab title="az cli" %} {% code overflow="wrap" %}
# List Static Webapps
az staticwebapp list --output table
# Get Static Webapp details
az staticwebapp show --name <name> --resource-group <res-group> --output table
# Get appsettings
az staticwebapp appsettings list --name <name>
# Get env information
az staticwebapp environment list --name <name>
az staticwebapp environment functions --name <name>
# Get API key
az staticwebapp secrets list --name <name>
# Get invited users
az staticwebapp users list --name <name>
# Get database connections
az rest --method GET \
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/staticSites/<app-name>/databaseConnections?api-version=2021-03-01"
## Once you have the database connection name ("default" by default) you can get the connection string with the credentials
az rest --method POST \
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/staticSites/<app-name>/databaseConnections/default/show?api-version=2021-03-01"
# Check connected backends
az staticwebapp backends show --name <name> --resource-group <res-group>
{% endcode %} {% endtab %}
{% tab title="Az PowerShell" %} {% code overflow="wrap" %}
Get-Command -Module Az.Websites
# Retrieves details of a specific Static Web App in the specified resource group.
Get-AzStaticWebApp -ResourceGroupName <ResourceGroupName> -Name <Name>
# Retrieves the build details for a specific Static Web App.
Get-AzStaticWebAppBuild -ResourceGroupName <ResourceGroupName> -Name <Name>
# Retrieves the application settings for a specific build environment in a Static Web App.
Get-AzStaticWebAppBuildAppSetting -ResourceGroupName <ResourceGroupName> -Name <Name> -EnvironmentName <EnvironmentName>
# Retrieves functions for a specific build environment in a Static Web App.
Get-AzStaticWebAppBuildFunction -ResourceGroupName <ResourceGroupName> -Name <Name> -EnvironmentName <EnvironmentName>
# Retrieves function app settings for a specific build environment in a Static Web App.
Get-AzStaticWebAppBuildFunctionAppSetting -ResourceGroupName <ResourceGroupName> -Name <Name> -EnvironmentName <EnvironmentName>
# Retrieves the configured roles for a Static Web App.
Get-AzStaticWebAppConfiguredRole -ResourceGroupName <ResourceGroupName> -Name <Name>
# Retrieves the custom domains configured for a Static Web App.
Get-AzStaticWebAppCustomDomain -ResourceGroupName <ResourceGroupName> -Name <Name>
# Retrieves details of the functions associated with a Static Web App.
Get-AzStaticWebAppFunction -ResourceGroupName <ResourceGroupName> -Name <Name>
# Retrieves the app settings for the function app associated with a Static Web App.
Get-AzStaticWebAppFunctionAppSetting -ResourceGroupName <ResourceGroupName> -Name <Name>
# Retrieves the secrets for a Static Web App.
Get-AzStaticWebAppSecret -ResourceGroupName <ResourceGroupName> -Name <Name>
# Retrieves general app settings for a Static Web App.
Get-AzStaticWebAppSetting -ResourceGroupName <ResourceGroupName> -Name <Name>
# Retrieves user details for a Static Web App with a specified authentication provider.
Get-AzStaticWebAppUser -ResourceGroupName <ResourceGroupName> -Name <Name> -AuthProvider <AuthProvider>
# Retrieves user-provided function apps associated with a Static Web App.
Get-AzStaticWebAppUserProvidedFunctionApp -ResourceGroupName <ResourceGroupName> -Name <Name>
{% endcode %} {% endtab %} {% endtabs %}
웹 앱 생성 예제
다음 링크에서 웹 앱을 생성하는 좋은 예제를 찾을 수 있습니다: https://learn.microsoft.com/en-us/azure/static-web-apps/get-started-portal?tabs=react&pivots=github
- https://github.com/staticwebdev/react-basic/generate 리포지토리를 포크하여 GitHub 계정에
my-first-static-web-app
이라는 이름으로 저장합니다. - Azure 포털에서 GitHub 접근을 구성하고 이전에 포크한 새 리포지토리를 선택하여 Static Web App을 생성합니다.
- 생성한 후 몇 분 기다리고 새 페이지를 확인하세요!
권한 상승 및 후속 활용
Azure Static Web Apps에서 권한 상승 및 후속 활용에 대한 모든 정보는 다음 링크에서 찾을 수 있습니다:
참고자료
- https://learn.microsoft.com/en-in/azure/app-service/overview
- https://learn.microsoft.com/en-us/azure/app-service/overview-hosting-plans
tip
AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE)
Azure 해킹 배우기 및 연습하기:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks 지원하기
- 구독 계획 확인하기!
- **💬 Discord 그룹 또는 텔레그램 그룹에 참여하거나 Twitter 🐦 @hacktricks_live를 팔로우하세요.
- HackTricks 및 HackTricks Cloud 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.