Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set VIPS_BLOCK_UNTRUSTED by default #57

Open
jcupitt opened this issue Jan 12, 2025 · 4 comments
Open

Set VIPS_BLOCK_UNTRUSTED by default #57

jcupitt opened this issue Jan 12, 2025 · 4 comments

Comments

@jcupitt
Copy link

jcupitt commented Jan 12, 2025

Many libvips binaries ship with a range of poorly tested loaders, and these are all enabled by default.

If you are dealing with untrusted data (as most intervention users probably will be), it's best to disable these by default. An easy way to do this is to set the VIPS_BLOCK_UNTRUSTED env var on startup, and give users some way to reenable specific wonky loaders if they have to.

https://www.libvips.org/API/current/VipsOperation.html#vips-operation-block-set

@olivervogel
Copy link
Member

That's a good suggestion. Will be integrated.

@olivervogel olivervogel added this to the 1.0.0 milestone Jan 12, 2025
@olivervogel
Copy link
Member

olivervogel commented Jan 13, 2025

I have noticed that this causes, among other things, that svgload_buffer() can no longer be used and thus all "draw” operations no longer work because the shapes are defined in svg format. Is there a way to avoid this by using a different loader or any other way or is SVG simply “unsafe”?

$svg = '<svg viewBox="0 0 ' . $width . ' ' . $height . '" xmlns="http://www.w3.org/2000/svg">' .
'<' . $shape . ' ' . $xmlAttributes . ' />' .
'</svg>';
try {
return VipsImage::svgload_buffer($svg);
} catch (VipsException $e) {
throw new RuntimeException('Could not create shape: ' . $e->getMessage(), previous: $e);
}

@jcupitt
Copy link
Author

jcupitt commented Jan 13, 2025

From memory, it's tagged as untrusted because we've not been fuzzing it and support is not included in the web binary we distribute. Parts of librsvg used to be GPL as well, so that also prevented binary distribution. Though I think this is now fixed for most versions (I think?).

You're right, we should expose vips_block_untrusted_set() so that intervention can have more granular control. It'll need a new php-vips though, so maybe park this issue for now.

libvips 8.16 has a new way to draw shapes with signed distance fields:

https://www.libvips.org/2024/10/10/What's-new-in-8.16.html

They are must faster and need less memory than SVG, though they won't work with your createShape() API, sadly.

@olivervogel olivervogel removed this from the 1.0.0 milestone Jan 14, 2025
@olivervogel
Copy link
Member

Depends on #61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants