JSON vs. Pickle security

后端 未结 2 1533
别跟我提以往
别跟我提以往 2020-12-16 17:39

I recently came across the security problems of the Python pickle and cPickle modules. Obviously, there are no real security measures implemented in pickle unless you overwr

2条回答
  •  半阙折子戏
    2020-12-16 17:51

    json is more secure because it's fundamentally more limited. The only python types that a json document can encode are unicode, int, float, NoneType, bool, list and dict. these are marshaled/unmarshalled in a basically trivial fashion that isn't vulnerable to code injection attacks.

提交回复
热议问题