The security vulnerability in Docling is a code injection and Server-Side Request Forgery (SSRF) issue within its HTML rendering feature. The root cause is the unsafe use of the Playwright library for rendering HTML content. The analysis of the patch between version 2.90.1 and the fixed version 2.91.0 revealed that the core of the vulnerability is in the _render_with_browser method of the HTMLDocumentBackend class in docling/backend/html_backend.py.
Prior to the fix, this function would create a Playwright browser context that, by default, had JavaScript execution enabled and no network restrictions. When a user-provided HTML was rendered, any embedded JavaScript would be executed within the context of the server, and any network requests (e.g., via fetch or <img> tags) would be made from the server's network interface. This could be exploited by an attacker to execute arbitrary JavaScript, exfiltrate local data, or perform SSRF attacks against internal services.
The patch applied in commit 9813190ab4126c1ff2fde1e3e72322821530390b directly addresses this by modifying the browser.new_context() call inside _render_with_browser. It introduces two key security controls:
java_script_enabled=False: This explicitly disables JavaScript execution in the rendering context, preventing code injection.
offline=offline_mode: This puts the browser in an offline mode based on the enable_remote_fetch option, preventing all network requests when remote fetching is disabled, thus mitigating the SSRF risk.
Therefore, the HTMLDocumentBackend._render_with_browser function is the exact location where the vulnerability existed and is the function that would appear in a runtime profile during the exploitation of this vulnerability.