id: CVE-2026-4480

info:
  name: Samba Printing Subsystem - Remote Code Execution
  author: projectdiscovery
  severity: critical
  description: |
    A flaw was found in the Samba printing subsystem. Samba passes the client-controlled job description string to the command configured with the "print command" setting via the "%J" substitution character without escaping shell meta characters. A remote attacker could exploit this vulnerability by sending a specially crafted print job description that contains unescaped shell characters. This could lead to remote code execution on the affected system.
  impact: |
    Successful exploitation allows an unauthenticated remote attacker to execute arbitrary operating system commands on the Samba server, leading to full system compromise including data exfiltration, malware deployment, and lateral movement within the network.
  remediation: |
    Upgrade Samba to version 4.22.10, 4.23.8, or 4.24.3 or later, or as a workaround add single quotes directly around %J in the print command smb.conf entry or remove %J completely from the configuration.
  reference:
    - https://github.com/Vusal777/CVE-2026-4480-exploit-poc
    - https://www.samba.org/samba/security/CVE-2026-4480.html
    - https://nvd.nist.gov/vuln/detail/CVE-2026-4480
  classification:
    cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
    cvss-score: 9.8
    cve-id: CVE-2026-4480
    epss-score: 0.01169
    epss-percentile: 0.63284
    cwe-id: CWE-78
  metadata:
    max-request: 1
    vendor: samba
    product: samba
    shodan-query: "port:445 product:Samba"
    fofa-query: "protocol=smb && banner=Samba"
  tags: cve,cve2026,samba,rce,smb,printing,passive

javascript:
  - pre-condition: |
      isPortOpen(Host,Port);
    code: |
      let m = require("nuclei/smb");
      let c = new m.SMBClient();
      let response = c.ConnectSMBInfoMode(Host, Port);
      to_json(response);
    args:
      Host: "{{Host}}"
      Port: "445"

    matchers-condition: and
    matchers:
      - type: word
        words:
          - "Samba"

      - type: dsl
        dsl:
          - "compare_versions(version, '< 4.22.10') || compare_versions(version, '>= 4.23.0', '< 4.23.8') || compare_versions(version, '>= 4.24.0', '< 4.24.3')"

    extractors:
      - type: regex
        name: version
        group: 1
        regex:
          - "Samba ([0-9]+\\.[0-9]+\\.[0-9]+[a-z]*)"
# digest: 4b0a00483046022100874b2dc7216e981022074e1e8091bb2801e4615c77537adce7f5a56f7b35f072022100b24a351e6a0882e317bdfd54b1abe40fabe4920518e978a6491384de23534a13:922c64590222798bb761d5b6d8e72950