avoid unsafe function to (de)serialize data

이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.

Metadata

ID: python-security/deserialize-untrusted-data

Language: Python

Severity: Notice

Category: Security

Description

Do not deserialize untrusted data. Make sure you use alternatives to check that the data can be deserialized safely. There is no workaround around this: unless you really trust the data source, it’s better to use another way to exchange data, such as an API or other protocols such as protobuf or thrift.

Read More

Non-Compliant Code Examples

import marshal
person = {"name":"xyz", "age":22, "marks":[45,56,78]}
data = marshal.dumps(person)
obj = marshal.loads(data)
import pickle

data = pickle.loads(data)

Compliant Code Examples

import pickle

data = pickle.loads(data)
data = pickle.loads(data)
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis