Detection rules › Sublime MQL

DLP - PCI: Discover Credit Card Number

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

Detects outbound emails containing Discover credit card numbers in the message body or text-parseable attachments. Discover PANs are 16 digits and start with one of the following BIN ranges: 6011, 622126–622925 (UnionPay co-branded), 644–649, or 65. Optional space or dash separators between digit groups are matched (e.g. 6011 1111 1111 1117 or 6011-1111-1111-1117). Deploy this rule with the "Block Delivery" action to prevent PCI data exfiltration, or in passive mode to monitor and audit outbound mail containing card numbers. Regex engine: RE2 (Golang). No PCRE lookbehind — word boundaries (\b) are used instead. Attachment content is extracted via file.explode() / .scan.strings.strings.

Event coverage

Rule body MQL

type.outbound
and (
  // Body: Discover 6011 prefix
  regex.contains(body.current_thread.text,
    '\b6011[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b'
  )

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

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

  // Body: 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'
  )

  // Attachments: scan extracted strings from PDFs, Office docs, CSVs, etc.
  or any(attachments,
    .file_extension in~ ('pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt', 'csv', 'eml', 'msg')
    and any(file.explode(.),
      any(.scan.strings.strings,
        regex.contains(., '\b6011[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')
        or regex.contains(., '\b65\d{2}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')
        or regex.contains(., '\b64[4-9]\d[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b')
        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 Discover credit card numbers in the message body or text-parseable attachments. Discover PANs are 16 digits and start with one of the following BIN ranges: 6011, 622126–622925 (UnionPay co-branded), 644–649, or 65. Optional space or dash separators between digit groups are matched (e.g. 6011 1111 1111 1117 or 6011-1111-1111-1117). Deploy this rule with the "Block Delivery" action to prevent PCI data exfiltration, or in passive mode to monitor and audit outbound mail containing card numbers. Regex engine: RE2 (Golang). No PCRE lookbehind — word boundaries (\b) are used instead. Attachment content is extracted via file.explode() / .scan.strings.strings.

  1. outbound message
  2. any of:
    • 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 '\\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 (13)

FieldMatchValue
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
attachments[].file_extensionmemberxls
attachments[].file_extensionmemberxlsx
attachments[].file_extensionmembertxt
attachments[].file_extensionmembercsv
attachments[].file_extensionmembereml
1 more
attachments[].file_extensionmembermsg