How to run wkhtmltopdf securely on user-supplied HTML?

六月ゝ 毕业季﹏ 提交于 2019-12-23 17:03:14

问题


Is wkhtmltopdf secure enough to prevent abuse when run server-side on user-supplied HTML, and if so, which arguments would I need?

I found how to disallow local file access, but I'd also like at least to prevent network access to localhost, and generally have it be about as secure as a modern browser. Is it?

I don't actually intend to run wkhtmltopdf on user-supplied HTML, but on server-generated HTML. I'm concerned that the presence of wkhtmltopdf would make any HTML injection vulnerability far more severe than it may have been otherwise. So ideally I'd like to secure wkhtmltopdf as if I were expecting arbitrary user input.


回答1:


The answer appears to be "it is not secure enough to do that".

In this discussion, it was suggested that you should run it in a sandbox and filter/sanitize the supplied HTML.

The authors do not mention what kind of HTML filtering is required. One possible security issue I can think of is that wkhtmltopdf could access content from the server's intranet that is not normally accessible from the outside and expose it in the PDF. If you disable Javascript with --disable-javascript, and disable local file access with --disable-local-file-access, then it's still possible to expose such content using an iframe, or by sourcing an image using inline CSS or img.src.



来源:https://stackoverflow.com/questions/24205769/how-to-run-wkhtmltopdf-securely-on-user-supplied-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!