html - Looking for a popular templating language that needs XSS protection -
i'd experiment popular html templating language see if can solve xss problems in it. popular, open-source, templating language try tackle.
by templating language, mean language used generate output language combining static content in output language dynamic data source. e.g. php commonly used templating language html/css/js, , xslt templating language xml.
the ideal template language be
- widely used
- open source
- not have solved xss
- the simpler syntax better
the idea to
- parse each template end tree of chunks of raw html, expressions produce dynamic values need encoded, , conditional (switch/if) , loop constructs.
- walk tree inferring context. possible contexts might include (html_pcdata, in_js_dbl_quoted_str, etc.) if see chunk of raw html,
<a href="
in html pcdata context, move context expecting part of url. when reach branch or loop, follow each branch independently, , join contexts afterwards. - if language has templates, try determine static call graph can clone templates , rewrite calls given template called in multiple contexts.
- wrap expressions produce dynamic values calls library implement includes functions
expecthtml(...)
,expectjsvalue(...)
encode dynamic value appropriately. e.g.expecthtml(...)
converts<
<
. - provide convenience functions code provies data templates can use rtti specify language of dynamic values avoid overescaping.
expecthtml(...)
not escape value of typehtml
since assumed come safe sourceknownsafehtml(...)
orstripbadtags(...)
the upcoming symfony broken down in components. releasing them 1 one. symfony templating 1 of them , candidate test.
Comments
Post a Comment