Development tools and frameworks usually have options to make debugging easier for developers. Although these features are useful during development, they should never be enabled for applications deployed in production. Debug instructions or error messages can leak detailed information about the system, like the application’s path or file names.

Ask Yourself Whether

There is a risk if you answered yes to any of those questions.

Recommended Secure Coding Practices

Do not enable debugging features on production servers or applications distributed to end users.

Sensitive Code Example

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
      {
          "type": "Microsoft.Resources/deployments",
          "apiVersion": "2022-09-01",
          "name": "templateDebug",
          "properties": {
              "debugSetting": { "detailLevel": "RequestContent, ResponseContent" }
          }
      }
  ]
}
resource templateDebug 'Microsoft.Resources/deployments@2022-09-01' = {
  name: 'templateDebug'
  properties: {
    debugSetting: {  // Noncompliant
      detailLevel: 'RequestContent, ResponseContent'
    }
  }
}

Compliant Solution

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
      {
          "type": "Microsoft.Resources/deployments",
          "apiVersion": "2022-09-01",
          "name": "templateDebug",
          "properties": {}
      }
  ]
}
resource templateDebug 'Microsoft.Resources/deployments@2022-09-01' = {
  name: 'templateDebug'
}

See