Reputation: 9245
Within a C# / ASP.NET MVC web app, I would like to display HTML emails received from untrusted sources. Does anyone know if there are known best practices (or even tools) to do in a "safe" way. As far I understand, most webmails perform extensive preprocessing (disabling image links, removing scripts etc).
Is there anything simple to be done better than just displaying the email as text only?
Upvotes: 5
Views: 771
Reputation: 8404
Joannes,
The easiest thing to do would be to use the Web Protection Library's whitelisting service to filter out potentially malicious HTML: http://wpl.codeplex.com/
As for implementing more sophisticated client behavior, such as blocking images from unknown sources unless the user authorizes it, you might want to try implementing something along these lines:
<img src="{URI}" />
tags back to the client - instead push an image with a unique ID attribute and have it src to a default "cannot display image" icon instead.Hope this helps!
Upvotes: 3