azure-nsg-oracle-db-unrestricted: Unrestricted Oracle Database Access in Azure NSGs

2025-08-01 oracle database PoC Public

Description

Ensure that Microsoft Azure network security groups (NSGs) do not allow unrestricted inbound access on TCP port 1521, used for Oracle Database, to protect against unauthorized database access.

PoC

id: azure-nsg-oracle-db-unrestricted
info:
  name: Unrestricted Oracle Database Access in Azure NSGs
  author: princechaddha
  severity: high
  description: |
    Ensure that Microsoft Azure network security groups (NSGs) do not allow unrestricted inbound access on TCP port 1521, used for Oracle Database, to protect against unauthorized database access.
  impact: |
    Unrestricted access on TCP port 1521 can expose Oracle databases to potential cyber-attacks, leading to data breaches or loss.
  remediation: |
    Modify NSG rules to restrict access on TCP port 1521. Implement strict access controls and monitor connections to ensure only authorized access.
  reference:
    - https://docs.microsoft.com/en-us/azure/virtual-network/network-security-groups-overview
  tags: cloud,devops,azure,microsoft,nsg,azure-cloud-config

flow: |
  code(1);
  for (let NsgData of iterate(template.nsgdata)) {
    NsgData = JSON.parse(NsgData)
    set("nsg", NsgData.name)
    set("resourcegroup", NsgData.resourceGroup)
    code(2)
  }

self-contained: true
code:
  - engine:
      - sh
      - bash
    source: |
      az network nsg list --query '[*].{name:name, resourceGroup:resourceGroup}' --output json

    extractors:
      - type: json
        name: nsgdata
        internal: true
        json:
          - '.[]'

  - engine:
      - sh
      - bash
    source: |
      az network nsg rule list --nsg-name $nsg --resource-group $resourcegroup --query "[?direction=='Inbound' && access=='Allow' && protocol=='TCP' && (destinationPortRange=='1521')]"

    matchers:
      - type: word
        words:
          - '"sourceAddressPrefix": "*"'
          - '"sourceAddressPrefix": "internet"'
          - '"sourceAddressPrefix": "any"'

    extractors:
      - type: dsl
        dsl:
          - 'nsg + " has unrestricted access on TCP port 1521"'
# digest: 490a004630440220592326102ef1481ce348fab6a908adce4d462338a37fd12f1e1064b987e4e3490220454550f326f325c90833157b258dc837c93a6d9d4322e07fe1e77591ccdf8703:922c64590222798bb761d5b6d8e72950

# Visit https://trap.biu.life/ to view exploit trends for this vulnerability.

References

Related Vulnerabilities