Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6826185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:07:02+00:00 2026-05-26T22:07:02+00:00

I currently have a simple <div contenteditable=true> working, but, here’s my problem. Currently, the

  • 0

I currently have a simple <div contenteditable="true"> working, but, here’s my problem.

Currently, the user can create a persistent XSS by inserting a <script> into the div, which I definitely do not want.

However, my current ideas to fix this are:

  • Allow only a and img tags
  • Use a textarea (not a good idea, because then have users copy and paste images)

What do you guys suggest?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:07:02+00:00Added an answer on May 26, 2026 at 10:07 pm

    You have to keep in mind that to prevent xss, you’ve GOT TO DO IT ON THE SERVER SIDE. If your rich text editor (ex YUI or tinyMCE) has some javascript to prevent a script tag from being inputted, that doesn’t stop me from inspecting your http post requests, looking at the variable names you’re using, and then using firefox poster to send whatever string I like to your server to bypass all client side validation. If you aren’t validating user input SERVER SIDE then you’re doing almost nothing productive to protect from XSS.

    Any client side xss protection would have to do with how you render user input; not how you receive it. So, for example, if you encoded all input so it does not render as html. This goes away from what you want to accomplish though (just anchor and img tags). Just keep in mind the more you allow to be rendered the more possible vulnerabilities you expose.

    That being said the bulk of your protection should come from the server side and there are a lot of XSS filters out there depending on what you’re writing with (ex, asp.net or tomcat/derby/jboss) that you can look into.

    I think you’re on the right path by allowing ONLY a and img tags. The one thing you have to keep in mind is that you can put javascript commands into the src attributes of a tags, so take care to validate the href attributes. But the basic idea of “allow nothing and then change the filters to only allow certain things” (AKA whitelist filtering) is better than “allow everything and then filter out what I don’t want” (AKA blacklist filtering).

    In the comments below, Brian Nickel also said this which illustrates the point:

    Everything but the elements and attributes you want to keep. I
    know you mentioned it in your answer but that bears repeating since it
    is so scary. <img onerror="stealMoney()">

    The other thing you’re going to want to do is define a XSSFilterRequest object (or something along those lines) and in a filter, override your requests so that any call to whatever your “getUrlParameter” and “getRequestParameter” objects run the request values through your xss filter. This provides a clean way to filter everything without rewriting existing code.

    EDIT: A python example of xss filtering:

    Python HTML sanitizer / scrubber / filter

    Python library for XSS filtering?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is probably is simple fix for this but I currently have code similar
I'm working on a relatively simple website with (currently) a single resource. I have
Currently I have a very simple tab system set up, the problem is when
I currently have a simple app that includes user authentication through devise and a
I have a contenteditable div, but I want to add a few characters of
I currently have a simple form that when you click the save button will
I have a simple ticket logging application build on LAMP. I am currently playing
I am currently learning F# and have tried (an extremely) simple example of FizzBuzz.
Currently, I have some basic code to play a simple tone whenever a button
I have been trying to get more in to TDD. Currently keeping it simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.