# Make CommonMark safe by default?

**URL:** <https://talk.commonmark.org/t/make-commonmark-safe-by-default/1265>\
**Category:** Spec\
**Created:** [July 10, 2015, 6:57am UTC](https://talk.commonmark.org/t/make-commonmark-safe-by-default/1265 "2015-07-10T06:57:31Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Jack\_Douglas](https://talk.commonmark.org/user_avatar/talk.commonmark.org/jack_douglas/32/286_2.png) [@Jack\_Douglas](https://talk.commonmark.org/u/Jack_Douglas)\
**Post date:** [July 10, 2015, 7:23pm UTC](https://talk.commonmark.org/t/make-commonmark-safe-by-default/1265/10 "2015-07-10T19:23:48Z")

</div>

> [@jgm](#):
>
> How does doing the sanitization during Markdown processing make it any easier?

Because we don’t have to understand HTML to make markdown safe - apart from inline HTML, there are only a very small number of entry points for injected code.

> [@jgm](#):
>
> Besides, we already have libraries for doing HTML sanitization, and these are well tested and well maintained, by people who focus on this topic.

Yes, and that’s a good thing, don’t get me wrong, but because it is _so_ difficult, even well tested and well maintained libraries are bound to have bugs. That’s fine if you have no option but to use them, but I think we have an easy option not to - at least for sites that aren’t concerned about supporting inline HTML or esoteric links.

> [@jgm](#):
>
> But we still have to deal with links; we can’t just remove all links. As I recall, it’s harder than it might seem to remove all attack vectors here.

This is the crucial issue - if it’s hard then my proposal is pointless and we might as well just advise on post processing sanitization as we do, however my take-away from your earlier comment is that links could be sanitized easily by walking the AST prior to rendering - in which case it should be relatively easy to add a third parse (or additional stage to link/image parsing) which does the same? Please forgive me if I’m misunderstanding how parsing works here.

---

_[View the full topic](https://talk.commonmark.org/t/make-commonmark-safe-by-default/1265)._
