T09 · Insecure Skill Coding Practices
- Location
scripts/lib/NarrativeTemplates.txt:40- Finding
Untrusted BloodHound Data Is Rendered as Raw Markdown and HTML
- Content
View full analysis
Vulnerability Details
File Location:
scripts/lib/NarrativeTemplates.txt, lines 40–54, 68–76, 482–483, and 540–550
Vulnerability Type: Markdown/HTML content injection
Risk Level: MediumVulnerable Code
powershell $lines.Add("## Executive Summary`n") $lines.Add("An automated analysis of Active Directory attack paths in **${Domain}** identified **${total} exploitable path(s)** that could allow an attacker to escalate privileges within the environment.`n")powershell $lines.Add("### ${emoji} ${label}: $($ClassifiedPath.Description)`n") $lines.Add("**Source:** ``$($ClassifiedPath.SourceNode)`` | **Target:** ``$($ClassifiedPath.TargetNode)`` | **Hops:** $($ClassifiedPath.HopCount)`n") $lines.Add("**Attack chain:** ``$($ClassifiedPath.EdgeChain)```n") $lines.Add("**Business risk:**`n") foreach ($reason in $ClassifiedPath.Reasons) { $lines.Add("- ${reason}") }powershell $lines.Add("### Path: $($ClassifiedPath.PathId) — $($ClassifiedPath.Description)`n") $lines.Add("**Severity:** $($Script:SeverityLabels[$ClassifiedPath.Severity]) (Score: $($ClassifiedPath.Score)) | **Chain:** ``$($ClassifiedPath.EdgeChain)```n")powershell [void]$report.AppendLine("# BloodHound Attack Path Assessment — ${Domain}") [void]$report.AppendLine("") [void]$report.AppendLine("**Report generated:** $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')") if ($ExportDate) { [void]$report.AppendLine("**Data collected:** ${ExportDate}") } if ($BHVersion) { [void]$report.AppendLine("**BloodHound version:** ${BHVersion}") }Technical Analysis
The report generator interpolates fields originating from the input BloodHound JSON directly into Markdown without contextual escaping or validation. Affected data includes the domain, export date, BloodHound version, path description, path ID, node names, edge labels, and node descriptions incorporated into risk reasons.
Markdown code delimiters do not provide adequate protection because an attacker ca ...[truncated 2458 chars]
- Remediation
View remediation
Remediation Suggestions
-
Implement centralized, context-specific encoding for every value derived from the JSON input:
- Escape Markdown metacharacters used in ordinary text.
- Escape pipes and line breaks in table cells.
- Escape backticks inside inline-code spans or render values in fenced blocks with safe delimiters.
- Encode HTML-sensitive characters such as
&,<, and>.
-
Normalize or reject dangerous input constructs:
- Remove disallowed control characters.
- Reject embedded carriage returns and line feeds where fields should be single-line.
- Reject or neutralize raw HTML tags.
- Reject Markdown image and link URI syntax where it is not operationally required.
- Apply reasonable length limits to metadata, descriptions, names, IDs, and labels.
-
Separate trusted report templates from untrusted values. Prefer a Markdown-generation library with safe text-node handling rather than constructing the entire report through string interpolation.
-
Configure the intended report renderer to disable raw HTML and remote-resource loading. Document that generated reports should be opened in a hardened renderer until output encoding is implemented.
-
Add adversarial regression tests covering:
- Newlines and injected headings.
- Backticks and code-fence termination.
- Markdown links and remote images.
- Raw HTML, including
iframe,img, and event-handler attributes. - Table delimiters.
- ANSI and bidirectional control characters.
- Excessively long values.
-
Ensure tests verify that attacker-controlled strings are displayed only as inert literal text and cannot change report structure or produce active links or remote resources.
-
