Detection rules › Sublime MQL

DLP - PCI: US Credit Card Number (Any Network)

Severity
high
Type
rule
Source
github.com/sublime-security/sublime-rules

Detects outbound emails containing credit card numbers from any of the four major US payment networks — Visa, Mastercard (5-series and 2-series BINs), American Express, and Discover — in the message body or text-parseable attachments. This combined rule is suitable for broad PCI DLP coverage. For granular per-network alerting or tuning, use the individual network-specific rules instead: - dlp_pci_visa_credit_card.yml - dlp_pci_mastercard_credit_card.yml - dlp_pci_amex_credit_card.yml - dlp_pci_discover_credit_card.yml Card number formats matched (spaces and dashes as separators are supported): - Visa: 4XXX XXXX XXXX XXXX (16-digit) or 4XXX XXXX XXXXX (13-digit legacy) - Mastercard: 5[1-5]XX XXXX XXXX XXXX | 2[221-720]X XXXX XXXX XXXX - Amex: 3[47]XX XXXXXX XXXXX (15-digit, standard 4-6-5 grouping) - Discover: 6011 / 65XX / 64[4-9]X / 622126-622925 XXXX XXXX XXXX Regex engine: RE2 (Golang). No PCRE lookbehind — word boundaries (\b) are used instead. Attachment content is extracted via file.explode() / .scan.strings.strings. Deploy with the "Block Delivery" action to prevent PCI data exfiltration, or run passively for monitoring and audit logging.

Event coverage

Rule body MQL

type.outbound
and (
  // ── Body scanning ─────────────────────────────────────────────────────────

  // Visa 16-digit
  regex.contains(body.current_thread.text, '\b4\d{3}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')

  // Visa 13-digit (legacy)
  or regex.contains(body.current_thread.text, '\b4\d{3}[\s-]?\d{4}[\s-]?\d{5}\b')

  // Mastercard 5-series (51–55)
  or regex.contains(body.current_thread.text, '\b5[1-5]\d{2}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')

  // Mastercard 2-series BINs (2221–2720)
  or regex.contains(body.current_thread.text,
    '\b(?:222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b'
  )

  // Amex 15-digit (34 or 37 prefix, 4-6-5 grouping)
  or regex.contains(body.current_thread.text, '\b3[47]\d{2}[\s-]?\d{6}[\s-]?\d{5}\b')

  // Discover 6011
  or regex.contains(body.current_thread.text, '\b6011[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')

  // Discover 65xx
  or regex.contains(body.current_thread.text, '\b65\d{2}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')

  // Discover 644–649
  or regex.contains(body.current_thread.text, '\b64[4-9]\d[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')

  // Discover/UnionPay co-branded 622126–622925
  or regex.contains(body.current_thread.text,
    '\b622(?:1(?:2[6-9]|[3-9]\d)|[2-8]\d{2}|9(?:[01]\d|2[0-5]))\d{2}[\s-]?\d{4}[\s-]?\d{4}\b'
  )

  // ── Attachment scanning ────────────────────────────────────────────────────

  or any(attachments,
    .file_extension in~ ('pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt', 'csv', 'eml', 'msg')
    and any(file.explode(.),
      any(.scan.strings.strings,
        // Visa 16-digit
        regex.contains(., '\b4\d{3}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')
        // Visa 13-digit
        or regex.contains(., '\b4\d{3}[\s-]?\d{4}[\s-]?\d{5}\b')
        // Mastercard 5-series
        or regex.contains(., '\b5[1-5]\d{2}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')
        // Mastercard 2-series
        or regex.contains(.,
          '\b(?:222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b'
        )
        // Amex
        or regex.contains(., '\b3[47]\d{2}[\s-]?\d{6}[\s-]?\d{5}\b')
        // Discover 6011
        or regex.contains(., '\b6011[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')
        // Discover 65xx
        or regex.contains(., '\b65\d{2}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')
        // Discover 644-649
        or regex.contains(., '\b64[4-9]\d[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')
        // Discover/UnionPay 622126-622925
        or regex.contains(.,
          '\b622(?:1(?:2[6-9]|[3-9]\d)|[2-8]\d{2}|9(?:[01]\d|2[0-5]))\d{2}[\s-]?\d{4}[\s-]?\d{4}\b'
        )
      )
    )
  )
)

Detection logic

Scope: outbound message.

Detects outbound emails containing credit card numbers from any of the four major US payment networks — Visa, Mastercard (5-series and 2-series BINs), American Express, and Discover — in the message body or text-parseable attachments. This combined rule is suitable for broad PCI DLP coverage. For granular per-network alerting or tuning, use the individual network-specific rules instead: - dlp_pci_visa_credit_card.yml - dlp_pci_mastercard_credit_card.yml - dlp_pci_amex_credit_card.yml - dlp_pci_discover_credit_card.yml Card number formats matched (spaces and dashes as separators are supported): - Visa: 4XXX XXXX XXXX XXXX (16-digit) or 4XXX XXXX XXXXX (13-digit legacy) - Mastercard: 5[1-5]XX XXXX XXXX XXXX | 2[221-720]X XXXX XXXX XXXX - Amex: 3[47]XX XXXXXX XXXXX (15-digit, standard 4-6-5 grouping) - Discover: 6011 / 65XX / 64[4-9]X / 622126-622925 XXXX XXXX XXXX Regex engine: RE2 (Golang). No PCRE lookbehind — word boundaries (\b) are used instead. Attachment content is extracted via file.explode() / .scan.strings.strings. Deploy with the "Block Delivery" action to prevent PCI data exfiltration, or run passively for monitoring and audit logging.

  1. outbound message
  2. any of:
    • body.current_thread.text matches '\\b4\\d{3}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
    • body.current_thread.text matches '\\b4\\d{3}[\\s-]?\\d{4}[\\s-]?\\d{5}\\b'
    • body.current_thread.text matches '\\b5[1-5]\\d{2}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
    • body.current_thread.text matches '\\b(?:222[1-9]|22[3-9]\\d|2[3-6]\\d{2}|27[01]\\d|2720)[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
    • body.current_thread.text matches '\\b3[47]\\d{2}[\\s-]?\\d{6}[\\s-]?\\d{5}\\b'
    • body.current_thread.text matches '\\b6011[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
    • body.current_thread.text matches '\\b65\\d{2}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
    • body.current_thread.text matches '\\b64[4-9]\\d[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
    • body.current_thread.text matches '\\b622(?:1(?:2[6-9]|[3-9]\\d)|[2-8]\\d{2}|9(?:[01]\\d|2[0-5]))\\d{2}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
    • any of attachments where all hold:
      • .file_extension in ('pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt', 'csv', 'eml', 'msg')
      • any of file.explode(.) where:
        • any of .scan.strings.strings where any holds:
          • . matches '\\b4\\d{3}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
          • . matches '\\b4\\d{3}[\\s-]?\\d{4}[\\s-]?\\d{5}\\b'
          • . matches '\\b5[1-5]\\d{2}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
          • . matches '\\b(?:222[1-9]|22[3-9]\\d|2[3-6]\\d{2}|27[01]\\d|2720)[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
          • . matches '\\b3[47]\\d{2}[\\s-]?\\d{6}[\\s-]?\\d{5}\\b'
          • . matches '\\b6011[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
          • . matches '\\b65\\d{2}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
          • . matches '\\b64[4-9]\\d[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'
          • . matches '\\b622(?:1(?:2[6-9]|[3-9]\\d)|[2-8]\\d{2}|9(?:[01]\\d|2[0-5]))\\d{2}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b'

Inspects: attachments[].file_extension, body.current_thread.text, type.outbound. Sensors: file.explode, regex.contains.

Indicators matched (18)

FieldMatchValue
regex.containsregex\b4\d{3}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b
regex.containsregex\b4\d{3}[\s-]?\d{4}[\s-]?\d{5}\b
regex.containsregex\b5[1-5]\d{2}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b
regex.containsregex\b(?:222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b
regex.containsregex\b3[47]\d{2}[\s-]?\d{6}[\s-]?\d{5}\b
regex.containsregex\b6011[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b
regex.containsregex\b65\d{2}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b
regex.containsregex\b64[4-9]\d[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b
regex.containsregex\b622(?:1(?:2[6-9]|[3-9]\d)|[2-8]\d{2}|9(?:[01]\d|2[0-5]))\d{2}[\s-]?\d{4}[\s-]?\d{4}\b
attachments[].file_extensionmemberpdf
attachments[].file_extensionmemberdoc
attachments[].file_extensionmemberdocx
6 more
attachments[].file_extensionmemberxls
attachments[].file_extensionmemberxlsx
attachments[].file_extensionmembertxt
attachments[].file_extensionmembercsv
attachments[].file_extensionmembereml
attachments[].file_extensionmembermsg