Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,113 of 9,113 pages
About the help in other languages
All help pages

File uploads and SVG

For public bodies whose staff upload images and documents - how Exponential stops uploaded files from running code (no execution below the root, type read from content, SVG sanitizer, downloads through…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/government/security/file-uploads-and-svg.md

On this page

File uploads and SVG

This page is for administrators and developers. Uploads are a classic way into a web server: a script disguised as an image, an SVG or HTML file that runs script in the browser, or a huge file that exhausts the server. Exponential has defenses at each step (Security hardening: File upload abuse).

Warning

.htaccess slows down every request. When .htaccess files are enabled (AllowOverride anything but None), let alone used, Apache looks for them and reads and evaluates them on every request, in every directory of the path, and page loading times go up drastically (measured). The only real fix is to switch the feature off for the virtual host: AllowOverride None in the HTTPS virtual host, and the rules in the virtual host's own configuration as mod_rewrite rules. That is far faster in production speed tests and well worth the time it takes to optimize a production configuration. Switch over right away: copy the rules of the example HTTPS virtual host into your virtual host (with the static cache, also staticcache_offload.conf), set AllowOverride None, run apachectl configtest, reload Apache and test the site. The same rules for other servers: nginx, LiteSpeed, Caddy, IIS, Velocity (built in); where virtual host rules go in a control panel: Plesk, cPanel, DirectAdmin, ISPConfig. On LiteSpeed or OpenLiteSpeed, the server's own page cache can also answer anonymous visitors and crawlers without PHP: Page caching with LiteSpeed and OpenLiteSpeed.

Contents

  1. The defenses
  2. SVG images
  3. Keep them in place
  4. Checking
  5. Related pages

The defenses

StepDefenseWhere
Accepting an imagetype read from the file content with PHP's fileinfo, compared with an allow-listexpImageUploadValidator, image.ini [ImageUploadSettings] AllowedMIMETypes[]
Storing an SVGsanitized; only what is known to be safe is keptexpSvgSanitizer, image.ini [ImageUploadSettings] SanitizeSVG=enabled
Servingnothing below the document root executed (.php, .phtml, .phar answer 404); only image files served directly from the storage.htaccess_root
Serving other uploadsonly through content/download, which checks read permissionkernel
Serving SVG from the storagea sandboxing policy header (sandbox; default-src 'none').htaccess_root, needs mod_headers
Packagesuploads need package policies; ManagedByDeployment blocks themPackages

The allowed image types as shipped are JPEG, PNG, GIF, WebP, AVIF, TIFF, BMP and SVG (Security and audit, 1).

SVG images

Since 15 October 2026 the image datatype accepts SVG (.svg, .svgz) on every site. An SVG is a document a browser can run script from, so it is never stored as uploaded: the stored file is the sanitizer's output. Every path that stores an image sanitizes (edit form, upload module, multi-upload, editor upload dialog, AJAX uploader, WebDAV, package import). A file that claims to be SVG but is not recognized as one is not stored (SVG images).

Keep them in place

  • Keep the rewrite rules current after every upgrade (.htaccess_root, or the derived nginx block); never serve the installation with a "serve the file if it exists" configuration.
  • Keep SanitizeSVG=enabled.
  • Check that fileinfo is loaded in the web server's PHP: php -m | grep fileinfo on the command line, and the same for PHP-FPM. Without it an older check applies and the log says so.
  • Give upload rights only to roles that need them.
  • Keep TemporaryDir private to the site, for example below var/ (the shipped /tmp/ is shared with every user of the machine).
  • Documents and other files are not scanned for malware by Exponential. If your policy requires scanning, do it at the server or storage level.

Checking

./console exp:ini get 'image.ini/ImageUploadSettings/AllowedMIMETypes' --allow-root-user
for p in .env .git/config extension/expservices/ezinfo.php; do
  curl -s -o /dev/null -w "$p %{http_code}\n" https://www.example.gov/$p
done

Expected: the allow-list as you intend it, and 404 three times.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x