-
-
Notifications
You must be signed in to change notification settings - Fork 608
Provide a CMARK_UNSAFE environment variable for backwards compatibility. #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'm not sure I like the idea of providing an environment variable backdoor around a security feature. It means that people might inadvertently think they're running in safe mode, because they're not aware of environment variable settings. If you're able to set an environment variable in the calling script, you should also be able to check the cmark version and make the |
Well, if someone you don't trust can change your environment variables, you have a much bigger problem than possible XSS already.
Of course you can. We are working on Turing-complete machines, don't we? We can solve any computable problem. ;)
Let's put it bluntly: cmark, like many programs these days, is essentially abusing semver by staying at 0.x despite being five years old and relied upon by many people. |
One possible alternative is to reintroduce the Besides, abrupt removal of that option might not have been good idea either—it will break people's scripts on upgrade. |
If you want to support both old and new versions, you can simply check whether the
I agree that |
I'd be happy to reintroduce As for the versioning: the decision was made early on to track the version number of the commonmark spec, at least prior to 1.0, which is why we are still 0.x. The breaking change was announced in the changelog. |
I'm on the fence about the environment variable idea, and I'd be happy to get input from more people. In general, with security simpler is better. |
First of all, I don't see how adding an environment variable helps with the original issue. Older binaries will always fail with |
@nwellnhof Old binaries use unsafe mode by default and never needed --unsafe.
and the script will behave the same regardless of cmark version. The explicit
Regarding security implications... I agree that in the library API, safe mode should be the default because people are likely to use it in web application backends for rendering user comments/posts/etc. That's completely unattended and the risk of XSS is high. |
Only if the version is strictly greater than 0.29.0. Version 0.29.0 will never behave like older versions. |
@nwellnhof Of course it won't. But fixing it for future versions is better than nothing, isn't it? |
Since 0.29.0 is out, it's impossible to make sure that all cmark binaries in the wild will have the same default for safe/unsafe. Adding an environment variable could fix this for all versions except 0.29.0, but if you have to support different versions, you can't rule out that someone happens to have 0.29.0 installed. So you need some kind of feature test anyway. It isn't much more complex than setting an environment variable and it should work for all cmark versions. Why add a workaround that doesn't work on all versions and has security implications? |
First five years security wasn't a concern, but now it suddenly is. So much of a concern in fact that disregarding compatibility completely is justifiable and no deprecation period was possible. You have shown complete disregard for compatibility. I'm trying to do at least something to alleviate it. It's your right to refuse. Do whatever you want. |
That's not fair. Personally, I always kept an eye on cmark development to minimize breaking changes. The safe/unsafe change is the first major breaking change that I know of. It was done deliberately in accordance with the stability guarantees stated by the project because it was deemed an important enough issue. I also tried to help by posting a rather simple workaround. |
@jgm I noticed that you are also the maintainer of pandoc. Pandoc is still unsafe by default. |
I can attest that @nwellnhof has definitely been a force to minimize breaking changes. I did consider the backwards compatibility issue before agreeing to this change, and the PR comments show my reluctance on that score. I hadn't thought of something like your environment variable approach at the time -- if I had, I might have done that. But I'm pretty convinced by @nwellnhof's argument: any robust script will have to reckon with the possibility of encountering cmark 0.29.0, so the environment variable approach is a half-measure. |
@jgm Ok, let's forget about it and focus on pandoc. |
This isn't the place to discuss pandoc. If you genuinely care about this issue, come over to the pandoc-discuss mailing list and raise it there. |
Making safe mode the default is a noble idea. However, an incompatible change without a backwards compatibility option, after years of unchanging behaviour, is a serious headache.
cmark 0.28 is still in a lot of still supported OSes/distros. If you use cmark as a part of a build process and your Markdown comes from a trusted/reviewed source, you have to choose between old and new because the old one will complain about an invalid option if you run
cmark --unsafe
, and the new one will auto-escape HTML without it.Environment variables can be an effective backwards compatibility mechanism: for the new versions it will disable safe mode, and for old versions it will have no ill effects.
This patch adds
CMARK_UNSAFE
environment variable in addition to the--unsafe
option, with the same effect.I'm open to discussion regarding the naming and implementation.