This rule advises against the use of unsafe deserialization in Ruby, particularly with the Marshal.load method. Deserialization is the process of converting data from a binary or string format back into an object. However, if the data was tampered with, it could lead to arbitrary code execution when the data is deserialized.
This is important because it can lead to serious security vulnerabilities. An attacker could exploit the deserialization process to execute malicious code, alter program flow, or perform other harmful actions. This is particularly dangerous if your application runs with high privileges.
To avoid this, use safe deserialization methods. Instead of using Marshal.load, consider using JSON or YAML for serialization and deserialization, as they are safer. For example, you could use JSON.parse(data) or YAML.load(data) instead. Additionally, always ensure that the data you are deserializing comes from a trusted source.
Non-Compliant Code Examples
obj=Marshal.load(data)
원활한 통합. Datadog Code Security를 경험해 보세요
Datadog Code Security
이 규칙을 사용해 Datadog Code Security로 코드를 분석하세요
규칙 사용 방법
1
2
rulesets:- ruby-security # Rules to enforce Ruby security.
리포지토리 루트에 위의 내용을 포함하는 static-analysis.datadog.yml을 만듭니다
무료 IDE 플러그인을 사용하거나 CI 파이프라인에 Code Security 검사를 추가합니다