Join our Newsletter — 33% off our NHI Course

Bigram And Trigram Features

Bigram and trigram features break a domain into two character and three character sequences for analysis. These ngram patterns help a model compare the structure of a domain with normal language or known benign naming patterns. Generated domains often look statistically different, which makes these features useful for classification.

How Bigram and Trigram Features Work

Bigram and trigram features split a domain string into short character sequences, then count or score the patterns they produce. This captures local structure such as repeated syllables, unusual letter pairings, and the rhythm of a generated label.

Because the model is analyzing small slices of the string rather than the whole domain at once, these features are useful when the domain is too short or too noisy for more semantic methods to work well. They are often a lightweight baseline for lexical analysis and classification.

Why They Are Useful for Domain Classification

These features help distinguish human-made domains from algorithmically generated ones by comparing a candidate domain to typical language-like patterns. A real brand or product name often contains more stable character combinations, while synthetic domains may show odd transitions, random-looking fragments, or repeated structural motifs.

The value is not that any single bigram or trigram proves maliciousness. The value is that many weak signals, considered together, can improve ranking, filtering, or clustering in a detection pipeline. In practice, they are often combined with length, vowel-consonant balance, dictionary overlap, and entropy-like measures.

Where They Fit in Security Analytics

Bigram and trigram features are a classic text-mining technique, but in security they are most often used for lexical analysis of domain names, identifiers, or similar strings. That makes them relevant in areas such as domain reputation scoring, phishing defense, and detection of generated or suspicious naming patterns.

They are typically most effective as part of a broader model rather than a standalone decision rule. On their own, they can overflag short, unusual, or brand-specific names, so the surrounding classifier needs contextual features and threshold tuning to keep false positives manageable.

Limitations and Practical Trade-offs

Character n-grams are strong at finding surface irregularities, but they do not understand intent, ownership, or business context. A malicious-looking pattern can be benign, and a polished-looking domain can still be harmful, so these features should support judgment rather than replace it.

They also become less informative when attackers mimic natural language more carefully, reuse familiar naming conventions, or register domains that resemble legitimate products. For that reason, their main strength is early-stage triage and statistical comparison, not definitive attribution.

Risk and Threat Considerations

Generated or carefully crafted domains can evade simple allowlists, blacklist checks, and human review by looking superficially normal. Bigram and trigram analysis helps expose that mismatch by measuring whether the character structure fits common language or known naming patterns.

Failure mechanism: Attackers exploit the fact that many domains are judged quickly and at scale, so a string that “looks right” can slip past coarse filters even when it is statistically unusual. N-gram features reduce that blind spot, but only if they are paired with other signals and model review.

Impact: Better lexical detection can improve phishing blocking, malware infrastructure triage, and domain-risk scoring. Poor tuning, however, can create false positives that burden analysts or miss sophisticated lookalike domains that imitate normal naming structure.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK and OWASP API Security Top 10 address the attack and risk surface, while NIST CSF 2.0 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
MITRE ATT&CK T1583 — Acquire Infrastructure Domain string patterns help identify infrastructure used in adversary staging.
Recommendation — Map suspicious domain patterns to T1583 and hunt for staging activity in your detection pipeline.
NIST CSF 2.0 DE.AE-02 — Anomalies are analyzed to support incident response N-gram features support anomaly analysis for suspicious domains and strings.
DE.CM-01 — Networks and network services are monitored to detect potentially adverse events Domain-pattern analysis is a monitoring aid for detecting adverse network indicators.
Recommendation — Use DE.AE-02 to analyze lexical anomalies that indicate suspicious or generated domains. Apply DE.CM-01 to monitor domain indicators with lexical features and raise suspicious matches for review.
CIS Controls v8 CIS-13 — Network Monitoring and Defense Character-level domain analysis supports network defense and suspicious traffic triage.
Recommendation — Use CIS-13 to enrich network monitoring with lexical domain features for suspicious activity detection.
OWASP API Security Top 10 API9 — Improper Inventory Management Domain classification can help inventory and flag unexpected or unapproved externally reachable endpoints.
Recommendation — Use API9 to inventory exposed domains and flag unusual naming patterns for review.

Practitioner Guidance

Why practitioners should care: Bigram and trigram features are most valuable when you need fast, explainable lexical signals for large-scale string classification. They work best as one layer in a feature set, not as the whole detection strategy.

Common misunderstanding: Similar character patterns do not equal malicious intent. Treat these features as probabilistic indicators that should be calibrated against real examples, not as a universal rule for blocking domains.