Contents

Security

An editor produces HTML that your application stores and shows to other people. This chapter lists what VEditor does for you and what you have to do in your application.

What VEditor does

  • One content model. The editor schema (JavaScript) and HtmlSanitizer (PHP) share the same whitelist of tags, attributes, classes and CSS properties. See HTML sanitizer.
  • URLs are limited to http, https, mailto, tel and relative addresses, after removing control characters; every srcset entry is checked.
  • Ids must start with ve-, which prevents DOM clobbering of your page’s scripts and stolen anchors.
  • Links with any target always get rel="noopener noreferrer".
  • Embeds: an iframe is limited to YouTube (no-cookie) and Vimeo inside a figure, with sandbox and referrerpolicy forced on output. Native video and audio (also only inside a figure) accept any safe http(s) or relative address and always get controls; files from other domains need media-src in your CSP.
  • Size: LengthException above 1 MB by default, invalid UTF-8 scrubbed, linear processing time for large and deeply nested input.
  • CSP: the editor needs no eval and no inline event handlers. The integrations pass your nonce to the editor script.
  • AI: the API key stays on the server, prompts are server-side, the browser sends only content and whitelisted names, and model output is sanitized before the preview. AiApi requires POST and a CSRF token and limits the request size. An image, video, audio or frame stays in the result only if its exact address was in a src, poster, data or srcset attribute of the HTML sent to the AI (addresses typed as text do not count; a srcset stays only if the whole value was in the input). This applies to the result and to every preview, so instructions hidden in the text cannot make the model leak the document through such requests. The API key never appears in error messages or stack traces, and provider error details go only to the server log.
  • Licence: verified locally, no calls to the vendor.
  • Supply chain: no npm or Composer dependencies. Releases are built only from annotated Git tags, scanned for secrets and reproducible byte for byte.

What your application must do

  1. Sanitize on save. Call HtmlSanitizer::sanitize() (or sanitize() of the integration) on every save, also for API endpoints and imports. Never trust content because it came from the editor.
  2. Allow the same styles in the sanitizer as in the editor (allowStyles($styles)).
  3. Protect the AI endpoint: only logged-in users who may edit content, a CSRF token, and limits with aiBeforeRequest if needed.
  4. Secure uploads: the upload endpoint receives files from users. Check type and size, re-encode images, store them outside directories where PHP runs. A file manager such as VFileManager does this for you.
  5. Send a CSP. A policy like the one below blocks injected scripts even if something slips through:
default-src 'self';
script-src 'self' 'nonce-…';
style-src 'self';
style-src-attr 'unsafe-inline';
img-src 'self' https: data: blob:;
frame-src 'self' https://www.youtube-nocookie.com https://player.vimeo.com;
connect-src 'self';
object-src 'none';
base-uri 'none';
form-action 'self'

style-src-attr 'unsafe-inline' is needed because the content may contain whitelisted style attributes (alignment, widths, list style).

  1. Show content in a known context. Output stored HTML inside <div class="veditor-content"> with veditor-content.css, and never inside attributes, scripts or <textarea> without escaping.
  2. Use separate autosave keys (autosave.key with user and record ids) when several users share a browser.

Reporting a vulnerability

Report it confidentially through the form (type "Vulnerability"); we do not accept reports by e-mail. Please do not use public channels. The full policy (response times, coordinated disclosure, supported versions) is in SECURITY.md in the package and on the Security page.

Something unclear? Send feedback on the documentation.