Unsanitized user input in deserialization method
- Rule ID: ruby_lang_deserialization_of_user_input
- Languages: ruby
- Source: deserialization_of_user_input.yml
Description
Deserializing data from untrusted sources, like parameters or cookies, without proper validation is a security risk. Attackers can embed malicious code or payloads in serialized data. When your application deserializes this data, it can compromise your system's security.
Remediations
- Do not deserialize data from untrusted sources directly. This prevents attackers from exploiting the deserialization process.
- Do use data formats that are purely data-oriented and not tied to a specific programming language, such as JSON or XML, for serialization and deserialization. This approach minimizes the risk of executing malicious code during deserialization.
user_data = JSON.parse(params[:user])
JSON.load(user)
References
Associated CWE
OWASP Top 10
Configuration
To skip this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --skip-rule=ruby_lang_deserialization_of_user_input
To run only this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --only-rule=ruby_lang_deserialization_of_user_input