How dangerous is it to let users specify RazorEngine templates?

前端 未结 3 1671
无人及你
无人及你 2021-01-12 08:06

I have mail-merge like functionality, which takes a template, some business object, and produces html which is then made into PDF.

I\'m using RazorEngine to do the t

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-12 08:38

    A cshtml Razor file is able to execute any. NET code in the context of the site so yes, it is a security risk to permit them to be supplied by users.

    You would be better served by accepting a more general HTML template, with custom tokens to input Model data.

提交回复
热议问题