GithubHelp home page GithubHelp logo

XSS in Previews about textpattern HOT 9 CLOSED

grozdniyandy avatar grozdniyandy commented on June 15, 2024
XSS in Previews

from textpattern.

Comments (9)

bloatware avatar bloatware commented on June 15, 2024

Thank you for your interest in Textpattern. While we explicitly delegate to admins all content validation, it's difficult to argue here. The preview step might look safer than it is for newcomers.

So, what could we do?

  • Implement a strict CSP on the admin side. Actually, some (commented) directives are already in dev config-dist.php file and core works fine, but they could break many old plugins.
  • Do the preview on the public side, somehow protecting it from hammering.
  • Restrict Textile in previews, or even reserve 'text' mode to the article author.
  • Clean up the previewed code, removing html event attributes.
  • Something else?

from textpattern.

grozdniyandy avatar grozdniyandy commented on June 15, 2024

I think you named everything necessary for the issue to be fixed.

from textpattern.

Bloke avatar Bloke commented on June 15, 2024
  • Restrict Textile in previews, or even reserve 'text' mode to the article author.
  • Clean up the previewed code, removing html event attributes.

How much fallout/blowback would there be if we started here? The point of a preview is to show what the article will look like on the site so if there's additional functionality that is part of the site, it would fail if we stripped off event handling. But the preview itself is limited by nature, so is that a reasonable restriction? It already doesn't render some things (article images?) so maybe this loss isn't so bad.

Although "correct", the strict CSP makes me a little nervous to include by default at this stage - especially without much warning to plugin authors.

from textpattern.

bloatware avatar bloatware commented on June 15, 2024

The body/excerpt preview does not parse txp tags anyway, so the rendition can be very different from the public side. IMO, its main interest is to show how the content will look for those not fluent in Textile/HTML. Anyway, we should sandbox the preview window from the rest of the page (risk of id/style/js/etc collisions).

Few things I have tested:

  • a sandboxed <iframe sandbox />. Would be ideal, but it's difficult to style properly and is poor UX-wise: on each preview refresh the viewport jumps to the top of the frame. This could be solved if we had access to the frame content via js, but sandbox attribute forbids it. If anyone knows how to autoresize an iframe in pure css, I'm all ears.
  • loading the preview content in a <template /> and attaching it as shadow to the preview window. This isolates the preview styles/ids from the rest of the page, but js is still executed.
  • purifying the preview content either admin or client-side. Needs some third-party libraries, adding ~200kb to txp. As a bonus admins could be warned if an article includes potentially unsafe content.

Ideas welcome

from textpattern.

grozdniyandy avatar grozdniyandy commented on June 15, 2024

Hello Guys, is issue fixed now?

from textpattern.

bloatware avatar bloatware commented on June 15, 2024

Hi @grozdniyandy, mostly yes, up to some cosmetic changes. Please test if you can, and thank you for the report. We will mention it in our HISTORY.txt file.

from textpattern.

grozdniyandy avatar grozdniyandy commented on June 15, 2024

Thanks for the reply, I tested and it seems to be fixed.

from textpattern.

Bloke avatar Bloke commented on June 15, 2024

@bloatware This is mint. The preview window kicks ass now there's the ability to clean up and report the number of infractions. Top stuff, thank you.

from textpattern.

bloatware avatar bloatware commented on June 15, 2024

Thanks! Handy, uh? TO DO: new (unsaved) article preview.

from textpattern.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.