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,teland relative addresses, after removing control characters; everysrcsetentry is checked. - Ids must start with
ve-, which prevents DOM clobbering of your page’s scripts and stolen anchors. - Links with any
targetalways getrel="noopener noreferrer". - Embeds: an
iframeis limited to YouTube (no-cookie) and Vimeo inside afigure, withsandboxandreferrerpolicyforced on output. Nativevideoandaudio(also only inside afigure) accept any safehttp(s)or relative address and always getcontrols; files from other domains needmedia-srcin your CSP. - Size:
LengthExceptionabove 1 MB by default, invalid UTF-8 scrubbed, linear processing time for large and deeply nested input. - CSP: the editor needs no
evaland 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.
AiApirequires 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 asrc,poster,dataorsrcsetattribute of the HTML sent to the AI (addresses typed as text do not count; asrcsetstays 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
- Sanitize on save. Call
HtmlSanitizer::sanitize()(orsanitize()of the integration) on every save, also for API endpoints and imports. Never trust content because it came from the editor. - Allow the same styles in the sanitizer as in the editor (
allowStyles($styles)). - Protect the AI endpoint: only logged-in users who may edit content, a CSRF token, and limits with
aiBeforeRequestif needed. - 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.
- 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).
- Show content in a known context. Output stored HTML inside
<div class="veditor-content">withveditor-content.css, and never inside attributes, scripts or<textarea>without escaping. - Use separate autosave keys (
autosave.keywith 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.