You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 335441c
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: ruby/ql/src/experimental/cwe-502/PlistUnsafeDeserialization.qhelp
+3-4Lines changed: 3 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -8,18 +8,17 @@
8
8
</overview>
9
9
<recommendation>
10
10
<p>
11
-
This vulnerability can be prevented by using <code>Plist.parse_xml</code>.
11
+
This vulnerability in Plist can be prevented by calling <code>Plist.parse_xml FileOrXmlString, marshal: false</code>.
12
12
</p>
13
13
</recommendation>
14
14
<example>
15
-
<p>In the example below, you can see safe and unsafe call of this dangerous method that can be abused by a remote user input. You can use "marshal: false" as an arugument for <code>Plist.parse_xml</code> to use it safe.
15
+
<p>In the example below, you can see safe and unsafe Plist dangerous method calls that can be abused by a remote user input. You can use "marshal: false" as an arugument for <code>Plist.parse_xml</code> to use it safe.
16
16
</p>
17
17
<samplesrc="PlistUnsafeYamlDeserialization.rb" />
18
18
</example>
19
19
<references>
20
20
<li>
21
-
Security considerations from library documentation
Copy file name to clipboardExpand all lines: ruby/ql/src/queries/security/cwe-502/UnsafeDeserialization.qhelp
+23Lines changed: 23 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,17 @@ libraries that support it, such as the Ruby standard library's <code>JSON</code>
17
17
module, ensure that the parser is configured to disable
18
18
deserialization of arbitrary objects.
19
19
</p>
20
+
21
+
<p>
22
+
YAML/Psych recommendation:
23
+
After Psych(YAML) 4.0.0, the load method is same as safe_load method.
24
+
This vulnerability can be prevented by using YAML.load (same as <code>YAML.safe_load</code>), <code>YAML.load_file</code> (same as <code>YAML.safe_load_file</code>) instead of <code>YAML.unsafe_*</code> methods.
25
+
Be careful that <code>YAML.load_stream</code> don't use safe_load method, Also Be careful the <code>to_ruby</code> method of Psych get called on a trusted parsed (<code>YAML.parse*</code>) yaml document.
26
+
</p>
27
+
28
+
<p>
29
+
This vulnerability in Plist can be prevented by calling <code>Plist.parse_xml FileOrXmlString, marshal: false</code>.
30
+
</p>
20
31
</recommendation>
21
32
22
33
<example>
@@ -27,6 +38,14 @@ on data from an HTTP request. Since these methods are capable of deserializing
<p>In the example below, you can see safe and unsafe methods get called by a remote user input. You can give correct authorization to users, or you can use safe methods for loading yaml documents.</p>
<p>In the example below, you can see safe and unsafe Plist dangerous method calls that can be abused by a remote user input. You can use "marshal: false" as an arugument for <code>Plist.parse_xml</code> to use it safe.
Ruby documentation: <ahref="https://ruby-doc.org/stdlib-3.0.2/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security">security guidance on the YAML library</a>.
57
76
</li>
77
+
<li>
78
+
You can read that how unsafe yaml load methods can lead to code executions:
79
+
<ahref="https://devcraft.io/2021/01/07/universal-deserialisation-gadget-for-ruby-2-x-3-x.html">Universal Deserialisation Gadget for Ruby 2.x-3.x </a>.
0 commit comments