Function App Authentication Disabled
- Query id: e65a0733-94a0-4826-82f4-df529f4c593f
- Query name: Function App Authentication Disabled
- Platform: Terraform
- Severity: Medium
- Category: Access Control
- CWE: 284
- Risk score: 7.0
- URL: Github
Description¶
Azure Function App authentication settings should be enabled
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive test num. 1 - tf file
resource "azurerm_function_app" "positive1-1" {
name = "example-app-service"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
site_config {
dotnet_framework_version = "v4.0"
scm_type = "LocalGit"
}
}
resource "azurerm_function_app" "positive1-2" {
name = "example-app-service"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
site_config {
dotnet_framework_version = "v4.0"
scm_type = "LocalGit"
}
auth_settings {
enabled = false
}
}
Positive test num. 2 - tf file
resource "azurerm_linux_function_app" "positive2-1" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
site_config {}
}
resource "azurerm_linux_function_app" "positive2-2" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings {
enabled = false
}
site_config {}
}
resource "azurerm_linux_function_app" "positive2-3" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings_v2 {
login {}
}
site_config {}
}
resource "azurerm_linux_function_app" "positive2-4" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings_v2 {
login {}
auth_enabled = false
}
site_config {}
}
resource "azurerm_linux_function_app" "positive2-5" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings {
enabled = true
}
auth_settings_v2 {
login {}
}
site_config {}
}
resource "azurerm_linux_function_app" "positive2-6" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings {
enabled = true
}
auth_settings_v2 {
login {}
auth_enabled = false
}
site_config {}
}
Positive test num. 3 - tf file
resource "azurerm_windows_function_app" "positive3-1" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
site_config {}
}
resource "azurerm_windows_function_app" "positive3-2" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings {
enabled = false
}
site_config {}
}
resource "azurerm_windows_function_app" "positive3-3" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings_v2 {
login {}
}
site_config {}
}
resource "azurerm_windows_function_app" "positive3-4" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings_v2 {
login {}
auth_enabled = false
}
site_config {}
}
resource "azurerm_windows_function_app" "positive3-5" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings {
enabled = true
}
auth_settings_v2 {
login {}
}
site_config {}
}
resource "azurerm_windows_function_app" "positive3-6" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings {
enabled = true
}
auth_settings_v2 {
login {}
auth_enabled = false
}
site_config {}
}
Code samples without security vulnerabilities¶
Negative test num. 1 - tf file
resource "azurerm_function_app" "negative1" {
name = "example-app-service"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
auth_settings {
enabled = true
}
}
Negative test num. 2 - tf file
resource "azurerm_linux_function_app" "negative2-1" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings {
enabled = true
}
site_config {}
}
resource "azurerm_linux_function_app" "negative2-2" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings_v2 {
login {}
auth_enabled = true
}
site_config {}
}
resource "azurerm_linux_function_app" "negative2-3" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings {
enabled = false
}
auth_settings_v2 {
login {}
auth_enabled = true
}
site_config {}
}
Negative test num. 3 - tf file
resource "azurerm_windows_function_app" "negative3-1" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings {
enabled = true
}
site_config {}
}
resource "azurerm_windows_function_app" "negative3-2" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings_v2 {
login {}
auth_enabled = true
}
site_config {}
}
resource "azurerm_windows_function_app" "negative3-3" {
name = "example-app-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_service_plan.example.location
service_plan_id = azurerm_service_plan.example.id
auth_settings {
enabled = false
}
auth_settings_v2 {
login {}
auth_enabled = true
}
site_config {}
}