We have an application that uses XSLT to format XML data for display as XHTML.
The system is able to handle arbitrary XML schemas, so users and users need to download Schemas and XSLT. It is clear that this is a task that is allowed only to users of the administrator level, however it is also a rather large bullish look, so I tried to make it more secure.
I must mention that we use Saxon 9.0 B
Is there any standard way to sanitize a user-provided XSLT? So far I have identified three possible questions, although I understand that there may be more that I simply did not think about:
xsl: the import and document () functions can get into the server file system. It's pretty easy to block with a custom URI resolver, so I'm sure I have this
output may contain javascript. I am thinking of using something like OWASP Anti-Samy to whitelist valid output tags.
XSLT can call java functions. This is the one that is currently causing me a headache. I donβt want to completely disable this ability (although at the moment I donβt even see how to do it), because we use it. My preferred solution would be to block valid Java namespaces so that only known safe functions can be executed. However, I am open to other suggestions.
The Gold Standard will be a standard library that will handle all known XSLT-based vulnerabilities, but will not accept any suggestions to solve the above problems (especially 3).
Thank you in advance
source share