1
1
---
2
- reviewed : 2022-05-14
2
+ reviewed : 2024-03-24
3
3
severity : Important
4
4
pillar : Security
5
- category : Deployment
5
+ category : SE:02 Secured development lifecycle
6
6
resource : App Service
7
7
online version : https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.AppService.PHPVersion/
8
8
---
@@ -16,62 +16,65 @@ Configure applications to use newer PHP runtime versions.
16
16
## DESCRIPTION
17
17
18
18
Within a App Service app, the version of PHP runtime used to run application/ site code is configurable.
19
- Older versions of PHP may not use the latest security features.
19
+
20
+ Overtime, a specific version of PHP may become outdated and no longer supported by Microsoft in Azure App Service.
21
+ This can lead to security vulnerabilities or are simply not able to use the latest security features.
22
+
23
+ PHP 8.0 and 8.1 are approaching end of support.
20
24
21
25
## RECOMMENDATION
22
26
23
- Consider updating the site to use a newer PHP runtime version such as ` 7.4 ` .
27
+ Consider updating the site to use a newer PHP runtime version such as ` 8.2 ` .
24
28
25
29
## EXAMPLES
26
30
27
31
### Configure with Azure template
28
32
29
33
To deploy App Services that pass this rule:
30
34
31
- - Set ` properties.siteConfig.phpVersion ` to a minimum of ` 7.0 ` .
35
+ - Set ` properties.siteConfig.linuxFxVersion ` to a minimum of ` PHP|8.2 ` .
32
36
33
37
For example:
34
38
35
39
``` json
36
40
{
37
- "type" : " Microsoft.Web/sites" ,
38
- "apiVersion" : " 2021-03-01" ,
39
- "name" : " [parameters('name')]" ,
40
- "location" : " [parameters('location')]" ,
41
- "identity" : {
42
- "type" : " SystemAssigned"
43
- },
44
- "kind" : " web" ,
45
- "properties" : {
46
- "serverFarmId" : " [resourceId('Microsoft.Web/serverfarms', parameters('planName'))]" ,
47
- "httpsOnly" : true ,
48
- "siteConfig" : {
49
- "alwaysOn" : true ,
50
- "minTlsVersion" : " 1.2" ,
51
- "ftpsState" : " FtpsOnly" ,
52
- "remoteDebuggingEnabled" : false ,
53
- "http20Enabled" : true ,
54
- "netFrameworkVersion" : " OFF" ,
55
- "phpVersion" : " 7.4"
56
- }
57
- },
58
- "tags" : " [parameters('tags')]" ,
59
- "dependsOn" : [
60
- " [resourceId('Microsoft.Web/serverfarms', parameters('planName'))]"
61
- ]
41
+ "type" : " Microsoft.Web/sites" ,
42
+ "apiVersion" : " 2023-01-01" ,
43
+ "name" : " [parameters('name')]" ,
44
+ "location" : " [parameters('location')]" ,
45
+ "identity" : {
46
+ "type" : " SystemAssigned"
47
+ },
48
+ "kind" : " web" ,
49
+ "properties" : {
50
+ "serverFarmId" : " [resourceId('Microsoft.Web/serverfarms', parameters('planName'))]" ,
51
+ "httpsOnly" : true ,
52
+ "clientAffinityEnabled" : false ,
53
+ "siteConfig" : {
54
+ "alwaysOn" : true ,
55
+ "minTlsVersion" : " 1.2" ,
56
+ "ftpsState" : " Disabled" ,
57
+ "http20Enabled" : true ,
58
+ "healthCheckPath" : " /healthz" ,
59
+ "linuxFxVersion" : " PHP|8.2"
60
+ }
61
+ },
62
+ "dependsOn" : [
63
+ " [resourceId('Microsoft.Web/serverfarms', parameters('planName'))]"
64
+ ]
62
65
}
63
66
```
64
67
65
68
### Configure with Bicep
66
69
67
70
To deploy App Services that pass this rule:
68
71
69
- - Set ` properties.siteConfig.phpVersion ` to a minimum of ` 7.0 ` .
72
+ - Set ` properties.siteConfig.linuxFxVersion ` to a minimum of ` PHP|8.2 ` .
70
73
71
74
For example:
72
75
73
76
``` bicep
74
- resource webAppPHP 'Microsoft.Web/sites@2021-03 -01' = {
77
+ resource php 'Microsoft.Web/sites@2023-01 -01' = {
75
78
name: name
76
79
location: location
77
80
identity: {
@@ -81,22 +84,35 @@ resource webAppPHP 'Microsoft.Web/sites@2021-03-01' = {
81
84
properties: {
82
85
serverFarmId: plan.id
83
86
httpsOnly: true
87
+ clientAffinityEnabled: false
84
88
siteConfig: {
85
89
alwaysOn: true
86
90
minTlsVersion: '1.2'
87
- ftpsState: 'FtpsOnly'
88
- remoteDebuggingEnabled: false
91
+ ftpsState: 'Disabled'
89
92
http20Enabled: true
90
- netFrameworkVersion : 'OFF '
91
- phpVersion : '7.4 '
93
+ healthCheckPath : '/healthz '
94
+ linuxFxVersion : 'PHP|8.2 '
92
95
}
93
96
}
94
- tags: tags
95
97
}
96
98
```
97
99
100
+ ### Configure with Azure Policy
101
+
102
+ To address this issue at runtime use the following policies:
103
+
104
+ - [ App Service apps that use PHP should use a specified 'PHP version'] ( https://github.com/Azure/azure-policy/blob/master/built-in-policies/policyDefinitions/App%20Service/Webapp_Audit_PHP_Latest.json )
105
+ ` /providers/Microsoft.Authorization/policyDefinitions/7261b898-8a84-4db8-9e04-18527132abb3 `
106
+ - [ App Service app slots that use PHP should use a specified 'PHP version'] ( https://github.com/Azure/azure-policy/blob/master/built-in-policies/policyDefinitions/App%20Service/Webapp_Slot_Audit_PHP_Latest.json )
107
+ ` /providers/Microsoft.Authorization/policyDefinitions/f466b2a6-823d-470d-8ea5-b031e72d79ae `
108
+
109
+ ## NOTES
110
+
111
+ From November 2022 - PHP is only supported on Linux-based plans.
112
+
98
113
## LINKS
99
114
100
- - [ Security design principles] ( https://learn.microsoft.com/azure/architecture/framework/security/security-principles#protect-against-code-level-vulnerabilities )
101
- - [ Set PHP Version] ( https://docs.microsoft.com/azure/app-service/configure-language-php#set-php-version )
102
- - [ Azure deployment reference] ( https://docs.microsoft.com/azure/templates/microsoft.web/sites#siteconfig )
115
+ - [ SE:02 Secured development lifecycle] ( https://learn.microsoft.com/azure/well-architected/security/secure-development-lifecycle )
116
+ - [ Set PHP Version] ( https://learn.microsoft.com/azure/app-service/configure-language-php?pivots=platform-linux#set-php-version )
117
+ - [ PHP on App Service] ( https://github.com/Azure/app-service-linux-docs/blob/master/Runtime_Support/php_support.md )
118
+ - [ Azure deployment reference] ( https://learn.microsoft.com/azure/templates/microsoft.web/sites )
0 commit comments