Repository navigation
Conversation
- elements rendered through <use> references are counted, more than 100,000 throw (like librsvg's limit): nine levels of ten uses each made a billion rectangles from a 1 kB file and killed the process - dash patterns of more than a million dashes stroke the path solid, as Skia does (stroke-dasharray="0.0001" on a long line took any memory) - the document walk that collects ids and style sheets uses a stack, so 100,000 nested elements no longer overflow it Found with crafted SVGs and 540 damaged variants of the test SVGs (no hangs or slow cases left); test renders are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Image.renderSVGcould be made to use unbounded time or memory with small crafted SVGs. This PR adds three limits against that.<use>each (1 kB, 10⁹ rectangles)stroke-dasharray="0.0001"on a long line<g>Maximum call stack size exceededChanges (
src/render/svg.ts)<use>limit: elements rendered through<use>references are counted, and the render throws after 100,000. librsvg has a similar limit. Only instanced elements count, because only they can multiply; direct elements are bounded by the file size, so large plain SVGs are unaffected.Reference cycles (
use→use, gradients, clip paths, masks) were already caught. The tests confirm that.Testing
tests/regressions.js: covers billion laughs, the fine dash pattern and deep nesting.🤖 Generated with Claude Code
https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ