Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Question: DON'T apply any filters inside any scriptable contexts? #63

Closed
chiefjester opened this issue Mar 21, 2017 · 2 comments
Closed

Comments

@chiefjester
Copy link

I'm not sure I follow. Can you elaborate when to use the filter? I assume filter means any method in xssFilters?

  1. Is this warning only applies on Client-side?
  2. Why is the example right before the warning applying filters inside a scritable context / <script>
<script>
var firstname = "..."; //an untrusted input collected from user
document.write('<h1> Hello, ' + xssFilters.inHTMLData(firstname) + '!</h1>')
</script>
@chiefjester chiefjester changed the title Question: DON'T apply any filters inside any scriptable contexts Question: DON'T apply any filters inside any scriptable contexts? Mar 21, 2017
@adon-at-work
Copy link
Contributor

good question. let's take a look at two vuln examples of what we want dev to avoid:

// assume you're using express at server-side
res.send('<a onclick="func(' + xssFilters.inDoubleQuotedAttr(untrusted) + ')">bomb</a>')
// assume on client-side
document.write('<a onclick="func(' + xssFilters.inDoubleQuotedAttr(untrusted) + ')">bomb</a>')

will that help better explain what scriptable context means?

@chiefjester
Copy link
Author

thank you for the quick response!

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

No branches or pull requests

2 participants