Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Character Bigram
Cyber Security

Character Bigram

← Back to Glossary
By NHI Mgmt Group Updated October 31, 2026 Domain: Cyber Security

A character bigram is a pair of adjacent characters used as a text feature in machine learning. In PowerShell analysis, bigrams help capture low level structure that survives obfuscation better than whole words do. This makes them useful for distinguishing normal scripts from manipulated ones.

What Character Bigrams Capture in Text Analysis

Character bigrams model local character-to-character structure rather than whole words, so they can surface patterns that survive spelling variation, casing changes, inserted separators and many forms of obfuscation. That makes them especially useful when the goal is to detect repeated low-level text signals instead of relying on dictionary meaning.

Because they operate at the character level, bigrams are less sensitive to token boundaries than word features. In security analysis, that often makes them a stronger signal when scripts, commands or payloads have been manipulated to evade simpler text matching.

Why Character Bigrams Work Well for Obfuscated PowerShell

PowerShell analysis is a good fit for character bigrams because malicious or suspicious scripts are often altered just enough to defeat exact word matching while leaving recurring character patterns intact. Bigrams can still represent fragments of cmdlets, operators, quoting styles, parameter patterns and concatenation habits even when the script has been reformatted.

This does not make bigrams a full understanding mechanism. They are a statistical feature, not a semantic one, so they work best as part of a broader detection pipeline that can compare many examples and learn which local sequences tend to appear in benign or malicious code.

In practice, their value is that they preserve signal when an analyst needs resilience against surface-level evasion. The same idea also applies beyond PowerShell, wherever an attacker may try to disguise intent by changing spacing, punctuation or character order without fully changing the underlying structure.

How Character Bigrams Are Used in Machine Learning Pipelines

To use character bigrams, text is typically converted into overlapping two-character pairs, then counted or weighted so a model can learn which pairs occur frequently in each class. That representation turns raw text into a numeric feature space that supports classification, clustering or anomaly detection.

The approach is often paired with other features, because bigrams capture only local context. They are strong at recognising patterns of form, but weaker at representing long-range meaning, command intent or execution logic on their own.

For security work, that trade-off is useful. A model can pick up character-level signatures of obfuscation, scripting habits and unusual formatting even when higher-level parsing is incomplete or unreliable.

Strengths and Limits of Character Bigram Features

Character bigrams are robust against many small text changes, which is why they are popular in malware classification, language identification and tamper-aware text analysis. They are also simple to compute and easy to feed into classical machine learning models.

Their main limitation is precision. Because they ignore broader syntax, they can overgeneralise and may miss deeper differences between benign and malicious content when those differences are not visible in short character windows. They also depend heavily on good feature engineering and representative training data.

For that reason, character bigrams are usually most effective when treated as one layer in a layered detection design, not as a standalone verdict. They help expose patterns, but they do not replace structural parsing, behavioural analysis or analyst review.

Risk and Threat Considerations

Character bigrams themselves are not a threat, but the security value of the technique comes from detecting text that has been deliberately altered to avoid easier inspection. If defenders rely only on whole-word matching, small edits can hide suspicious PowerShell activity, reduce detection quality and create blind spots in triage.

Failure mechanism: Obfuscation changes the visible form of a script while preserving enough low-level character structure for a bigram model to notice. When tuned well, that model can flag manipulated commands that would otherwise slip past simple signatures or naïve keyword filters.

Impact: Better bigram-based detection can improve identification of suspicious scripts, reduce false negatives in malware and abuse screening, and give analysts earlier visibility into encoded, fragmented or intentionally noisy content.

Standards & Framework Alignment

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

MITRE ATT&CK addresses the attack and risk surface, while CIS Controls v8, NIST SP 800-53 Rev 5 and OWASP ASVS set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
MITRE ATT&CKT1027 — Obfuscated Files or InformationCharacter bigrams help detect obfuscated script text that ATT&CK treats as a common evasion pattern.
Recommendation — Map obfuscated script patterns to T1027 and tune detections for text-level evasion.
CIS Controls v8CIS-13 — Data ProtectionBigram-based analysis supports detection of suspicious script content as part of defensive monitoring and analysis.
Recommendation — Use CIS-13 to improve detection of manipulated script content in monitoring pipelines.
NIST SP 800-53 Rev 5SI-4 — System MonitoringCharacter-bigram detection supports monitoring for suspicious scripts and anomalous text patterns.
Recommendation — Apply SI-4 to monitor script activity and alert on abnormal text patterns.
OWASP ASVSV15 — Secure Coding and ArchitectureFeature extraction for security analytics fits secure architecture decisions around resilient detection inputs.
Recommendation — Use V15 to design detection inputs that remain effective against basic obfuscation.

Practitioner Guidance

Why practitioners should care: Character bigrams are most useful when you expect adversaries to change surface text faster than they can change underlying behaviour. They are a practical feature choice for detection problems where local form matters more than human-readable meaning.

What to watch for: Bigram performance depends on preprocessing decisions such as casing, normalisation and token handling. Small changes there can materially alter model behaviour, so the feature pipeline should be treated as part of the control, not just a technical detail.

Practitioner takeaway: Use character bigrams to complement, not replace, higher-level script analysis, especially when the detection problem is shaped by evasion and text manipulation.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 31, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org