CVE-2023-28631

5.3 MEDIUM

📋 TL;DR

CVE-2023-28631 is a vulnerability in the comrak Markdown parser where manually constructed AST nodes containing non-UTF-8 byte arrays can trigger crashes or undefined behavior when converted to HTML. This affects applications that programmatically build comrak ASTs without validating input data. The vulnerability allows potential denial of service or memory corruption.

💻 Affected Systems

Products:
  • comrak
Versions: Versions before 0.17.0
Operating Systems: All platforms running Rust applications using comrak
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications that manually construct AST nodes; parsing Markdown documents directly is not vulnerable

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Memory corruption leading to arbitrary code execution or complete service disruption

🟠

Likely Case

Application crashes or denial of service when processing malformed AST data

🟢

If Mitigated

No impact if AST data is properly validated or patched version is used

🌐 Internet-Facing: MEDIUM - Exploitation requires ability to influence AST construction, which may be possible through user input
🏢 Internal Only: LOW - Requires programmatic AST manipulation, less likely in typical internal use

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires programmatic AST manipulation; not directly exploitable via typical Markdown input

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 0.17.0 and later

Vendor Advisory: https://github.com/kivikakk/comrak/security/advisories/GHSA-5r3x-p7xx-x6q5

Restart Required: Yes

Instructions:

1. Update Cargo.toml to require comrak >=0.17.0
2. Run 'cargo update comrak'
3. Rebuild and redeploy application
4. Restart affected services

🔧 Temporary Workarounds

Validate UTF-8 in AST construction

all

Manually validate all byte arrays are valid UTF-8 before assigning to AST fields

// Rust code: validate strings before AST assignment
let validated_str = std::str::from_utf8(bytes).expect("Invalid UTF-8");

🧯 If You Can't Patch

  • Implement strict input validation for all data used in AST construction
  • Isolate comrak processing in sandboxed environments with resource limits

🔍 How to Verify

Check if Vulnerable:

Check Cargo.toml or Cargo.lock for comrak version <0.17.0

Check Version:

grep comrak Cargo.toml || grep -A2 -B2 comrak Cargo.lock

Verify Fix Applied:

Verify comrak version is >=0.17.0 in dependencies and rebuild application

📡 Detection & Monitoring

Log Indicators:

  • Application crashes during HTML generation
  • Panic messages related to UTF-8 validation

Network Indicators:

  • Sudden service unavailability of Markdown processing endpoints

SIEM Query:

source="application.log" AND ("panicked" OR "UTF-8" OR "comrak")

🔗 References

📤 Share & Export