terraform.azure.security.appservice.azure-appservice-enabled-failed-request.azure-appservice-enabled-failed-request
semgrep
Author
unknown
Download Count*
License
Ensure that App service enables failed request tracing
Run Locally
Run in CI
Defintion
rules:
- id: azure-appservice-enabled-failed-request
message: Ensure that App service enables failed request tracing
patterns:
- pattern: resource
- pattern-not-inside: |
resource "azurerm_app_service" "..." {
...
logs {
...
failed_request_tracing_enabled = true
...
}
...
}
- pattern-inside: |
resource "azurerm_app_service" "..." {
...
}
metadata:
owasp:
- A10:2017 - Insufficient Logging & Monitoring
- A09:2021 - Security Logging and Monitoring Failures
cwe:
- "CWE-778: Insufficient Logging"
category: security
technology:
- terraform
- azure
references:
- https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures
subcategory:
- audit
likelihood: LOW
impact: LOW
confidence: LOW
license: Commons Clause License Condition v1.0[LGPL-2.1-only]
vulnerability_class:
- Insufficient Logging
languages:
- hcl
severity: WARNING
Examples
azure-appservice-enabled-failed-request.tf
# fail
# ruleid: azure-appservice-enabled-failed-request
resource "azurerm_app_service" "example" {
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
https_only = true
logs {
failed_request_tracing_enabled = false
}
}
# fail
# missing logs attribute
# ruleid: azure-appservice-enabled-failed-request
resource "azurerm_app_service" "example" {
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
https_only = true
site_config {
scm_type = "someValue"
}
}
# fail
# missing tracing enabled attribute
# ruleid: azure-appservice-enabled-failed-request
resource "azurerm_app_service" "example" {
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
https_only = true
site_config {
scm_type = "someValue"
}
logs {
application_logs = "test"
}
}
# pass
resource "azurerm_app_service" "example" {
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
https_only = true
logs {
failed_request_tracing_enabled = true
}
storage_account {
name = "test_name"
type = "AzureFiles"
account_name ="test_account_name"
share_name = "test_share_name"
access_key = "test_access_key"
}
}
Short Link: https://sg.run/XAbK