Use the Conformity Knowledge Base AI to help improve your Cloud Posture

Check for Latest Version of Python

Trend Micro Cloud One™ – Conformity is a continuous assurance tool that provides peace of mind for your cloud infrastructure, delivering over 750 automated best practice checks.

Risk Level: Low (generally tolerable level of risk)
Rule ID: AppService-001

Ensure that all Microsoft Azure App Service web applications developed with Python programming language are using the latest available version of Python in order to take advantage of the latest security fixes, performance improvements, and new functionalities and features.

This rule resolution is part of the Conformity Security & Compliance tool for Azure.

Security
Reliability
Performance
efficiency

Newer versions of Python programming language are released regularly to address security vulnerabilities, add performance enhancements or include additional functionality. Cloud Conformity strongly recommends enabling the latest version of Python supported by Azure App Service to apply the most recent security patches and take advantage of the new software enhancements and capabilities.


Audit

To determine if your Azure App Service web applications are using the latest version of Python, perform the following actions:

Using Azure Console

01 Sign in to Azure Management Console.

02 Navigate to App Services blade at https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Web%2Fsites.

03 Click on the name of the App Service web application that you want to examine.

04 In the navigation menu, under Settings, select Configuration to access the configuration settings defined for the selected application.

05 On the Configuration panel, select General settings tab to access the application general settings.

06 In the Stack settings section, check the Stack setting value to determine the type of the software stack used by the selected web application. If Stack is set to Python, check the software version available in the Python version dropdown list. If Python version does not show the latest version available in the list (for example, 3.4), the selected Azure App Service Python web application is not configured to use the latest version of Python programming language.

07 Repeat steps no. 3 – 6 for each Azure App Service web application launched in the current subscription.

08 Repeat steps no. 3 – 7 for other subscriptions created in your Microsoft Azure cloud account.

Using Azure CLI

01 Run webapp list-runtimes command (Windows/macOS/Linux) using custom query filters to list the Python versions currently supported by Microsoft Azure App Service:

az webapp list-runtimes | grep python

02 The command output should return the supported versions of the Python programming language:

"python|2.7",
"python|3.4"

03 Run webapp list command (Windows/macOS/Linux) using custom query filters to list the IDs of all App Service web applications deployed in the current Azure subscription:

az webapp list
	--query '[*].id'

04 The command output should return the requested Azure App Service application IDs:

[
"/subscriptions/1234abcd-1234-abcd-1234-abcd1234abcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Web/sites/cc-mobile-webapp",
"/subscriptions/1234abcd-1234-abcd-1234-abcd1234abcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Web/sites/cc-java-main-app",
"/subscriptions/1234abcd-1234-abcd-1234-abcd1234abcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Web/sites/cc-production-app"
]

05 Run webapp config show command (Windows/macOS/Linux) using the ID of the application that you want to examine as identifier parameter and custom query filters to describe the Python version configured for the selected Azure App Service web application:

az webapp config show
	--ids "/subscriptions/1234abcd-1234-abcd-1234-abcd1234abcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Web/sites/cc-mobile-webapp"
	--query '{"pythonVersion":pythonVersion}'

06 The command output should return the Python version currently in use:

{
  "pythonVersion": "2.7"
}

If the value returned by the webapp config show command output for "pythonVersion" configuration attribute is null or an empty string (i.e. ""), the verified web application is not using a Python software stack. Otherwise, check the returned attribute value and compare it with each version returned at step no. 2. If "pythonVersion" value is not equal to the latest version of Python software returned at step no. 2, the selected Azure App Service web application is not using the latest version of the Python for its software stack.

07 Repeat steps no. 3 – 6 for each Azure App Service web application available in the current subscription.

08 Repeat steps no. 3 – 7 for each subscription created in your Microsoft Azure cloud account.

Remediation / Resolution

To reconfigure your Azure App Service web applications in order to enable the latest stable version of Python, perform the following actions:

Using Azure Console

01 Sign in to Azure Management Console.

02 Navigate to App Services blade at https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Web%2Fsites.

03 Click on the name of the web application that you want to reconfigure (see Audit section part I to identify the right Python application).

04 In the navigation menu, under Settings, select Configuration to access the configuration settings defined for the selected application.

05 On the Configuration panel, select General settings tab to access the web application general settings.

06 In the Stack settings section, select the latest version of Python available in the Python version dropdown list.

07 Click Save to apply the changes. Once the configuration changes become active, the Azure Management Console should display the following confirmation message: "Successfully updated web app settings".

08 Repeat steps no. 3 – 7 for each Azure App Service Python web application available in the current subscription.

09 Repeat steps no. 3 – 8 for each subscription created in your Microsoft Azure cloud account.

Using Azure CLI

01 Run webapp list-runtimes command (Windows/macOS/Linux) using custom query filters to list the Python versions currently supported by Microsoft Azure App Service:

az webapp list-runtimes | grep python

02 The command output should return the Python software versions supported by Azure App Service:

"python|2.7",
"python|3.4"

03 Run webapp config set command (Windows/macOS/Linux) using the ID of the Azure App Service web application that you want to reconfigure as identifier parameter (see Audit section part I to identify the right application) to enable the latest version of Python programming language (as described at step no. 2) for the selected web application:

az webapp config set
	--ids "/subscriptions/1234abcd-1234-abcd-1234-abcd1234abcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Web/sites/cc-mobile-webapp"
	--python-version "3.4"

04 The command output should return the metadata available for the reconfigured Microsoft Azure App Service application:

{
  "alwaysOn": false,
  "apiDefinition": null,
  "appCommandLine": "",
  "appSettings": null,
  "autoHealEnabled": false,
  "autoHealRules": null,
  "loadBalancing": "LeastRequests",
  "localMySqlEnabled": false,
  "location": "West Europe",
  "logsDirectorySizeLimit": 35,
  "machineKey": null,
  "managedPipelineMode": "Integrated",
  "managedServiceIdentityId": null,
  "minTlsVersion": "1.2",
  "name": "cc-mobile-webapp",
 
  ...
 
  "pythonVersion": "3.4",
  "remoteDebuggingEnabled": false,
  "remoteDebuggingVersion": "VS2017",
  "requestTracingEnabled": false,
  "requestTracingExpirationTime": null,
  "reservedInstanceCount": 0,
  "resourceGroup": "cloud-shell-storage-westeurope",
  "scmIpSecurityRestrictionsUseMain": false,
  "scmType": "None",
  "tracingOptions": null,
  "type": "Microsoft.Web/sites",
  "use32BitWorkerProcess": true,
  "vnetName": "",
  "webSocketsEnabled": false,
  "windowsFxVersion": null,
  "xManagedServiceIdentityId": null
}

05 Repeat step no. 3 and 4 for each Azure App Service Python web application deployed in the current subscription.

06 Repeat steps no. 3 – 5 for each subscription created in your Microsoft Azure cloud account.

References

Publication date Sep 30, 2019

Unlock the Remediation Steps


Free 30-day Trial

Automatically audit your configurations with Conformity
and gain access to our cloud security platform.

Confirmity Cloud Platform

No thanks, back to article

You are auditing:

Check for Latest Version of Python

Risk Level: Low