fix(anatomy): V1-2.2 path numbers bounded by the frame magnitude

Fresh security review and verifier (MEDIUM): browsers read path data in
f32 and draw nothing for an arc radius or rotation past f32::MAX (WebKit
from 1e30) while the endpoints kept the verdict green. Every path and
viewBox number is now read within 2^20, else the path is unreadable.
Docs: section 12.12 transform table, mutation record, open zone finding.
This commit is contained in:
bchanot committed 2026-11-01 01:49:49 +01:00
1 parent 96b99784b5
commit 76ead9567c
4 files changed
+51 -6

No files matched your search

+11 -2
View File
@@ -4,6 +4,12 @@
//! number, a bad flag, an unknown command, a trailing comma, a number out of range) answers
//! `None`, never a guess. Curves and arcs are measured on their shape, not on their control
//! points; a moveto counts, as a subpath may start there.
//!
//! Every number is bounded by `frame::MAX_FRAME_MAGNITUDE` (owner brief 2026-11-01, security
//! review): browsers read path data in `f32` and draw nothing for a path holding a number past
//! `f32::MAX` (Chromium, WebKit; WebKit already for an arc radius of `1e30`), while a radius or a
//! rotation that big leaves the bounds unchanged. A coordinate past the bound is outside every
//! usable frame, a radius past it draws a straight segment on one.
/// The smallest box holding a set of points.
#[derive(Debug, Clone, Copy, PartialEq)]
@@ -139,7 +145,8 @@ impl<'a> Cursor<'a> {
Some(byte)
}
/// `sign? (digits ('.' digits?)? | '.' digits) (('e'|'E') sign? digits)?`, finite.
/// `sign? (digits ('.' digits?)? | '.' digits) (('e'|'E') sign? digits)?`, within
/// `±MAX_FRAME_MAGNITUDE`.
fn number(&mut self) -> Option<f64> {
let start = self.at;
if matches!(self.peek(), Some(b'+' | b'-')) {
@@ -165,7 +172,9 @@ impl<'a> Cursor<'a> {
}
}
let text = std::str::from_utf8(&self.bytes[start..self.at]).ok()?;
text.parse::<f64>().ok().filter(|n| n.is_finite())
text.parse::<f64>()
.ok()
.filter(|n| n.abs() <= super::frame::MAX_FRAME_MAGNITUDE)
}
fn digits(&mut self) -> usize {