Skip to content

Conversation

cx-andre-pereira
Copy link
Contributor

@cx-andre-pereira cx-andre-pereira commented Jul 16, 2025

Reason for Proposed Changes

  • These queries are meant to detect azurerm network rules that expose sensitive ports: port 22(ssh) and port 3389(rdp), however they are not taking into account azurerm_network_security_group´s.
  • This has bestowed upon the queries a massive blind spot for this dangerous vulnerabilities; inside these groups one or both ports could be explicitly exposed.

Proposed Changes

  • To allow for complete thorough search for network rules i have implemented an extra valid pattern for the CxPolicy to scan and detect these statements when inside an azurerm_network_security_group block.
  • The implementations specifically searches for "security_rule"´s inside groups because that is the singular allowed identifier for rules defined inside these groups. Other identifiers are disregarded. doc
  • All the tests have been updated to ensure results are consistent whether rules are defined inside or outside of a group.

Note: The searchKey uses rule names for traceability. This approach was chosen over index-based referencing due to consistent misalignment between idx values and the actual rule objects, which led to duplicate or misplaced warnings.

originalPR

I submit this contribution under the Apache-2.0 license.

@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner July 16, 2025 11:00
@github-actions github-actions bot added community Community contribution query New query feature terraform Terraform query labels Jul 16, 2025
Copy link
Contributor

@cx-eduardo-semanas cx-eduardo-semanas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@cx-artur-ribeiro cx-artur-ribeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cx-artur-ribeiro cx-artur-ribeiro merged commit 17aef90 into Checkmarx:master Jul 17, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution query New query feature terraform Terraform query
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants