If Kernel.open
is given a file name that starts with a |
+character, it will execute the remaining string as a shell command. If a
+malicious user can control the file name, they can execute arbitrary code.
+The same vulnerability applies to IO.read
.
+
Use File.open
instead of Kernel.open
, as the former
+does not have this vulnerability. Similarly, use File.read
instead
+of IO.read
.
+The following example shows code that calls Kernel.open
on a
+user-supplied file path.
+
Instead, File.open
should be used, as in the following example.
If Kernel.open
is given a file name that starts with a |
-character, it will execute the remaining string as a shell command. If a
-malicious user can control the file name, they can execute arbitrary code.
-The same vulnerability applies to IO.read
.
-
Use File.open
instead of Kernel.open
, as the former
-does not have this vulnerability. Similarly, use File.read
instead
-of IO.read
.
-The following example shows code that calls Kernel.open
on a
-user-supplied file path.
-
Instead, File.open
should be used, as in the following example.