跳到正文
DEV Community· CVE Reports·· 20 小時前AI 評分47

Inscriptis HTML 轉文字程式庫的 CVE-2026-132277:二次方記憶體增長及拒絕服務漏洞

CVE-2026-132277: CVE-2026-132277: Quadratic Memory Growth and Denial of Service in Inscriptis HTML-to-Text Library

AI 導讀

Inscriptis Python 程式庫 2.0.0 至 2.7.5 版本存在 CVE-2026-132277,處理區塊容器內的同級 HTML 表格時會累積縮排,令記憶體用量按表格數量呈二次方增長並可引發拒絕服務。約 240 KB、含 16,000 個空表格的 HTML 可產生約 10 億個字元(約 1 GB 記憶體);修補版本為 2.7.6。

正文

CVE Reports

CVE-2026-132277: Quadratic Memory Growth and Denial of Service in Inscriptis HTML-to-Text Library

Vulnerability ID: CVE-2026-132277
CVSS Score: 5.3
Published: 2026-11-20

CVE-2026-132277 (also tracked as GHSA-q87h-c5m7-659j) is an uncontrolled resource consumption and algorithmic complexity vulnerability in the Inscriptis Python library (versions 2.0.0 through 2.7.5). When rendering sibling HTML table elements inside a block-level parent container, the parser fails to pop the parent block's inline padding prefix from the internal canvas prefix stack upon closing the block. Consequently, each subsequent sibling table inherits and accumulates the indentation prefixes of all preceding tables. This causes the output string length and memory allocation of get_text() to grow quadratically with the number of sibling tables, allowing a compact untrusted HTML payload to trigger denial of service via memory exhaustion.

TL;DR

An unbalanced prefix stack operation in Inscriptis versions 2.0.0 through 2.7.5 causes sibling

tags within a block-level parent element to accumulate indentation quadratically. Processing an HTML payload of approximately 240 KB containing 16,000 empty sibling tables generates roughly 1 billion characters (~1 GB of memory), resulting in denial of service. Users must upgrade to version 2.7.6.




⚠️ Exploit Status: POC



Technical Details

  • Vulnerability ID: CVE-2026-132277 / GHSA-q87h-c5m7-659j
  • Weakness Class: CWE-400 (Uncontrolled Resource Consumption) / CWE-407 (Algorithmic Complexity)
  • CVSS v3.1 Score: 5.3 Medium (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L)
  • Affected Versions: inscriptis >= 2.0.0, < 2.7.6
  • Patched Version: inscriptis 2.7.6
  • Attack Vector: Network / Untrusted HTML Input containing sibling

tags

  • Impact: Denial of Service via O(N^2) quadratic memory and CPU exhaustion
  • Exploit & KEV Status: Public PoC Available; Not Listed in CISA KEV


  • Affected Systems

    • weblyzard inscriptis (Python library, versions 2.0.0 through 2.7.5)
    • inscriptis-api web service instances using inscriptis < 2.7.6
    • Python web crawlers, RAG/LLM ingestion pipelines, and HTML-to-text services utilizing inscriptis >= 2.0.0, < 2.7.6
    • inscriptis: >= 2.0.0, < 2.7.6 (Fixed in: 2.7.6)



    Code Analysis



    Commit: dc12289

    fix: balance the verbatim-text block prefix so sibling tables do not accumulate padding

    diff --git a/src/inscriptis/model/tag/table_tag.py b/src/inscriptis/model/tag/table_tag.py
    index e634567..a123456 100644
    --- a/src/inscriptis/model/tag/table_tag.py
    +++ b/src/inscriptis/model/tag/table_tag.py
    @@ -1,6 +1,7 @@
    """Handle the <table>, <tr> and <td> tags."""

    from inscriptis.annotation import Annotation
    +from inscriptis.html_properties import Display
    from inscriptis.model.canvas import Canvas
    from inscriptis.model.html_document_state import HtmlDocumentState
    from inscriptis.model.table import Table, TableCell
    @@ -63,3 +64,8 @@ def table_end_handler(state: HtmlDocumentState) -> None:

     # transfer in-table annotations
     state.tags[-2].canvas.annotations.extend(table.get_annotations(start_idx, state.tags[-2].canvas.left_margin))
    

    +
    + # write_verbatim_text() opened a block whose prefix is read above for the
    + # annotation offsets; drop it now so sibling tables do not accumulate padding
    + if state.tags[-2].display == Display.block:
    + state.tags[-2].canvas.current_block.prefix.remove_last_prefix()



    Exploit Details

    • GitHub: Public proof-of-concept repository containing local Python reproduction harness and remote verification scripts demonstrating quadratic memory exhaustion in inscriptis 2.0.0-2.7.5.



    Mitigation Strategies

    • Upgrade the inscriptis Python library to version 2.7.6 or later to ensure balanced prefix stack management during table serialization.
    • Apply pre-parsing input validation or WAF rules to inspect and reject untrusted HTML documents containing excessive numbers of consecutive

    tags.

  • Enforce process-level memory limits (cgroups, ulimit/resource.setrlimit) and strict execution timeouts on worker processes executing inscriptis.get_text() or inscriptis.get_annotated_text().
  • Remediation Steps:

    1. Audit application dependencies (requirements.txt, Pipfile.lock, poetry.lock) to identify installations of inscriptis within the vulnerable range (>= 2.0.0, < 2.7.6).
    2. Run pip install --upgrade "inscriptis>=2.7.6" in all affected Python environments and rebuild container images.
    3. If immediate package upgrade is not possible, manually backport commit dc122894cd671a0227f8fdad60464acddaf40fc8 into src/inscriptis/model/tag/table_tag.py.
    4. Run regression tests (such as passing '<div>' + '<table></table>' * 2000 + '</div>' to get_text()) to verify that output size remains below 40,000 characters.



    References


    Read the full report for CVE-2026-132277 on our website for more details including interactive diagrams and full exploit analysis.

    來源:DEV Community · dev.to