News for hackers. Stuff that matters.
Re:XML is better than YAML by frant-hartm on Thursday September 21, 2023 @01:12AM (#37593449)
You know that JSON is subset of yaml, right?
Re:XML is better than YAML by dragonwriter on Thursday September 21, 2023 @01:42AM (#37593618)
Since most people’s (especially critics) understanding of YAML is stuck on YAML 1.1 where that wasn't quite true, probably not.
Re:XML is better than YAML by arwineap on Thursday September 21, 2023 @01:44AM (#37593641)
The commenter said they preferred json over yaml because yaml is whitespace sensitive; Json is not

yaml's feature set is also too broad, forcing safe loaders

Re:XML is better than YAML by bshacklett on Thursday September 21, 2023 @08:14AM (#37596492)
I think the point is that if something accepts YAML, you can feed it JSON without issue.

> yaml's feature set is also too broad, forcing safe loaders

Could you elaborate?

Re:XML is better than YAML by arwineap on Friday September 22, 2023 @02:10AM (#37608467)
Yaml tags allow for serialization of native types, and has been abused to run malicious code.

I think you can also make circular references in yaml effectively making a zip bomb

This is why you have yaml.safe_load in Python and SafeConstructor in Java's snakeyaml package

The end result is that you should not use yaml to handle untrusted data unless you are also explicitly handling it safely

Re:XML is better than YAML by bshacklett on Friday September 22, 2023 @04:54PM (#37617639)
Any de-serialization should be done via safe loaders. Using `require()` or `eval()` isn't something I'd do outside of a very narrow set of scenarios.
Re:XML is better than YAML by arwineap on Saturday September 23, 2023 @04:19AM (#37621541)
The json modules in the same languages doesn't support the madness and doesn't necessitate a safe loader

It's possible someone could come along and write a json library that would support this, but somehow we have made it this far without it and that's a good thing

The point is that yaml and xml both have side effects in the form of require and eval that json won't, and frequently people are unaware of this

Re:XML is better than YAML by bshacklett on Wednesday September 27, 2023 @09:10AM (#37674143)
I feel I must still be misunderstanding something. OWASP has pages of resources which talk about the lack of safety of JSON:

https://owasp.org/search/?searchString=json

Perhaps yaml and xml have _more_ ways to inject behavior into an application, but I would still not consider JSON safe in any way. Why would JSON.parse() even exist if `require()` and `eval()` were safe to use?