id: disable-empty-password

info:
  name: Disable SSH Empty Password
  author: pussycat0x
  severity: high
  description: |
    Allowing empty passwords in SSH poses a severe security risk, enabling unauthorized access, brute-force attacks, and potential system compromise. It should always be disabled to prevent unauthorized logins.
  remediation: |
    Set PermitEmptyPasswords no in /etc/ssh/sshd_config to disable empty password logins and restart the SSH service.
  reference:
    - https://vishalraj82.medium.com/hardening-openssh-security-37f5d634015f
    - https://docs.datadoghq.com/security/default_rules/xccdf-org-ssgproject-content-rule-sshd-disable-empty-passwords/
  metadata:
    verified: true
  tags: audit,config,ssh,auth

javascript:
  - pre-condition: |
      isPortOpen(Host,Port);
    code: |
      var m = require("nuclei/ssh");
      var c = m.SSHClient();
      c.Connect(Host,Port,User,Pass);
      const sshConfig = c.Run('cat /etc/ssh/sshd_config')
      sshConfig
      let result = "";
      if (sshConfig.includes('PermitEmptyPasswords yes')) {
      result += "Disable SSH Empty Password Access";
       }
      else{
      exit();
      }
      result

    args:
      Host: "{{Host}}"
      Port: "22"
      User: "{{usernames}}"
      Pass: "{{passwords}}"

    matchers:
      - type: dsl
        dsl:
          - "success == true"

    extractors:
      - type: dsl
        dsl:
          - response
# digest: 4b0a0048304602210090f1b075340725c5e0a63dc65dabe176c1185bccf08e593976fd35572de9100802210093ed51e2c2f2b957243fb609c5c987ec849446151f7e846ca72cb7b91a89a01f:922c64590222798bb761d5b6d8e72950