Skip to content

Commit 67e4b70

Browse files
committed
feat(query): Add Public Resource
1 parent 8763b8c commit 67e4b70

File tree

5 files changed

+59
-0
lines changed

5 files changed

+59
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Internal Resource is Public to the Internet
2+
3+
This query detects Azure resources that are inadvertently exposed to the public internet. Publicly accessible resources can be targeted by attackers, leading to data breaches, service disruption, or unauthorized access. It is a security best practice to restrict access to internal resources by using private endpoints, network security groups, or firewalls to limit exposure.
4+
5+
## Bad Example: Publicly Accessible Resource
6+
7+
```bicep
8+
resource storage 'Microsoft.Storage/storageAccounts@2021-02-01' = {
9+
name: 'publicstorage'
10+
location: 'eastus'
11+
properties: {
12+
allowBlobPublicAccess: true // BAD: Public access is enabled
13+
}
14+
}
15+
```
16+
17+
## Good Example: Internal-Only Resource
18+
19+
```bicep
20+
resource storage 'Microsoft.Storage/storageAccounts@2021-02-01' = {
21+
name: 'privatestorage'
22+
location: 'eastus'
23+
properties: {
24+
allowBlobPublicAccess: false // GOOD: Public access is disabled
25+
}
26+
}
27+
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @name Internal Resource Public to the Internet
3+
* @description Internal resources should not be publicly accessible to the Internet.
4+
* @kind problem
5+
* @problem.severity error
6+
* @security-severity 8.0
7+
* @precision high
8+
* @id bicep/public-resource
9+
* @tags security
10+
* bicep
11+
* azure
12+
*/
13+
14+
import bicep
15+
16+
from PublicResource resource
17+
select resource.getPublicAccessProperty(),
18+
"Resource '" + resource.getName() + "' is publicly accessible to the Internet."
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
| app.bicep:6:26:6:34 | String | Resource 'publicdbserver' is publicly accessible to the Internet. |
2+
| app.bicep:6:26:6:34 | String | Resource 'publicdbserver' is publicly accessible to the Internet. |
3+
| app.bicep:6:26:6:34 | String | Resource 'publicdbserver' is publicly accessible to the Internet. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
security/CWE-200/PublicResource.ql
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
resource db 'Microsoft.Sql/servers@2021-02-01-preview' = {
2+
name: 'publicdbserver'
3+
location: 'eastus'
4+
properties: {
5+
version: '12.0'
6+
publicNetworkAccess: 'Enabled' // BAD: Database is publicly accessible
7+
minimalTlsVersion: '1.0' // BAD: Weak TLS version
8+
sslEnforcement: 'Disabled' // BAD: SSL enforcement is disabled
9+
}
10+
}

0 commit comments

Comments
 (0)