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

No validating backend XSS #192

Open
BaHeK1994 opened this issue Jul 3, 2019 · 5 comments
Open

No validating backend XSS #192

BaHeK1994 opened this issue Jul 3, 2019 · 5 comments

Comments

@BaHeK1994
Copy link

  1. Open form
    изображение
  2. Open browser console
  3. CKEDITOR.instances[textareaId].destroy(true);
  4. Paste XSS
    изображение
  5. Submit
    изображение
@TomaszGasior
Copy link
Contributor

TomaszGasior commented Jul 17, 2019

I don't see any issue related to this bundle here. Regardless of used WYSIWYG editor you MUST do validation/sanitization on your own, using good tools like: https://github.com/tgalopin/html-sanitizer-bundle

@BaHeK1994
Copy link
Author

Without an editor, the default is to escape HTML characters and there are no problems. It turns out this bandl adds only a few javascript lines and no backend check? You can, by default, add the same html-sanitizer-bundle to yourself and add backend processing to the html so that developers can safely install the bundle from the composer without unnecessary actions.

@TomaszGasior
Copy link
Contributor

TomaszGasior commented Jul 17, 2019

Without an editor, the default is to escape HTML characters

No, it isn't. Symfony framework itself does not escape HTMl characters while saving. Escaping/sanitizing should be done using sanitizer while saving or reading or on template side, using twig filter. IMHO this bundle is not responsive for handling data the way you want.

You may want provide your application repository to see how is done "submit" action shown on screenshot.

@BaHeK1994
Copy link
Author

When displaying, twig shields HTML by default.

{% set var = '<p>test</p>' %}
{{ var }}

output:
&lt;p&gt;test&lt;/p&gt;

Unfortunately, I can not provide access, because the private repository. To generate the form used https://github.com/sonata-project/SonataAdminBundle
image

@lukepass
Copy link

lukepass commented Feb 7, 2022

Using FOSCKEditorBundle is as simple as this:

  1. Install the bundle suggested by @TomaszGasior
  2. Edit the desired forms adding the following attribute:
->add('content', CKEditorType::class, [
    'config_name' => 'advanced',
    'required' => false,
    'sanitize_html' => true, // this is the important line
])
  1. Done!

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

No branches or pull requests

3 participants