<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/index.php?action=history&amp;feed=atom&amp;title=Inyecci%C3%B3n_De_Comandos_En_Java</id>
		<title>Inyección De Comandos En Java - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/index.php?action=history&amp;feed=atom&amp;title=Inyecci%C3%B3n_De_Comandos_En_Java"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Inyecci%C3%B3n_De_Comandos_En_Java&amp;action=history"/>
		<updated>2026-05-01T20:57:08Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Inyecci%C3%B3n_De_Comandos_En_Java&amp;diff=208878&amp;oldid=prev</id>
		<title>Imifos at 11:51, 14 February 2016</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Inyecci%C3%B3n_De_Comandos_En_Java&amp;diff=208878&amp;oldid=prev"/>
				<updated>2016-02-14T11:51:08Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 11:51, 14 February 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l74&quot; &gt;Line 74:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 74:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;OWASP &lt;/del&gt;Java &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Project&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Java]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Imifos</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Inyecci%C3%B3n_De_Comandos_En_Java&amp;diff=140663&amp;oldid=prev</id>
		<title>José Luis Escobar: Created page with &quot;==Estado== Review  ==Introducción== Las vulnerabilidades de  este tipo permiten a un atacante inyectar arbitrariamente comandos del sistema en una aplicación. Estos comandos...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Inyecci%C3%B3n_De_Comandos_En_Java&amp;diff=140663&amp;oldid=prev"/>
				<updated>2012-12-04T14:27:10Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Estado== Review  ==Introducción== Las vulnerabilidades de  este tipo permiten a un atacante inyectar arbitrariamente comandos del sistema en una aplicación. Estos comandos...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Estado==&lt;br /&gt;
Review&lt;br /&gt;
&lt;br /&gt;
==Introducción==&lt;br /&gt;
Las vulnerabilidades de  este tipo permiten a un atacante inyectar arbitrariamente comandos del sistema en una aplicación. Estos comandos se ejecutan al mismo nivel de privilegios que la aplicación Java y proveen al atacante una funcionalidad similar a la de una Shell de Sistema Operativo. En Java, Runtime.exec es comúnmente usado para invocar a un nuevo proceso, pero esto no invoca una nueva Shell de comandos, lo que significa que usualmente encadenando o entubando múltiples comandos juntos no funciona. La inyección de comandos sin embargo es posible si el proceso engendrado con Runtime.exec es una Shell como command.com, cmd.exe o /bin/sh..&lt;br /&gt;
&lt;br /&gt;
==Ejemplos ==&lt;br /&gt;
&lt;br /&gt;
===Ejemplo 1===&lt;br /&gt;
&lt;br /&gt;
El código detallado a continuación permite a un usuario el control de los argumentos del comando de Windows find. Mientras el usuario no posea control absoluto sobre los argumentos, no es posible inyectar comandos adicionales. Por ejemplo, ingresando “test &amp;amp; del file” no causará que el comando del se ejecute. Dado que Runtime.exec tokeniza la cadena de comando y luego invoca el comando find usando los parámetros “test”, “&amp;amp;”, “del” y “file”.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
&lt;br /&gt;
public class Example1 {&lt;br /&gt;
	public static void main(String[] args)&lt;br /&gt;
	throws IOException {&lt;br /&gt;
		if(args.length != 1) {&lt;br /&gt;
			System.out.println(&amp;quot;No arguments&amp;quot;);&lt;br /&gt;
			System.exit(1);&lt;br /&gt;
		}&lt;br /&gt;
		Runtime runtime = Runtime.getRuntime();&lt;br /&gt;
		Process proc = runtime.exec(&amp;quot;find&amp;quot; + &amp;quot; &amp;quot; + args[0]);&lt;br /&gt;
		&lt;br /&gt;
		InputStream is = proc.getInputStream();&lt;br /&gt;
		InputStreamReader isr = new InputStreamReader(is);&lt;br /&gt;
		BufferedReader br = new BufferedReader(isr);&lt;br /&gt;
		&lt;br /&gt;
		String line;&lt;br /&gt;
		while ((line = br.readLine()) != null) {&lt;br /&gt;
			System.out.println(line);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Ejemplo 2===&lt;br /&gt;
&lt;br /&gt;
El código a continuación invoca una shell del sistema para ejecutar un commando no ejecutable usando lo ingresado por el usuario como parámetros. Comandos de Windows no ejecutables tales como dir y copy son parte del intérprete de comandos y por ende no pueden ser directamente invoados por Runtime.exec. En este caso, la inyección de comandos es posible y un atacante puede encadenar múltiples comandos juntos. Por ejemplo ingresando, “.&amp;amp; echo hello” causará que el comando dir liste los contenidos del directorio actual y el comando echo imprima un mensaje de saludo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
&lt;br /&gt;
public class Example2 {&lt;br /&gt;
	public static void main(String[] args)&lt;br /&gt;
	throws IOException {&lt;br /&gt;
		if(args.length != 1) {&lt;br /&gt;
			System.out.println(&amp;quot;No arguments&amp;quot;);&lt;br /&gt;
			System.exit(1);&lt;br /&gt;
		}&lt;br /&gt;
		Runtime runtime = Runtime.getRuntime();&lt;br /&gt;
		String[] cmd = new String[3];&lt;br /&gt;
		cmd[0] = &amp;quot;cmd.exe&amp;quot; ;&lt;br /&gt;
                cmd[1] = &amp;quot;/C&amp;quot;;&lt;br /&gt;
                cmd[2] = &amp;quot;dir &amp;quot; + args[0];&lt;br /&gt;
		Process proc = runtime.exec(cmd);&lt;br /&gt;
		&lt;br /&gt;
		InputStream is = proc.getInputStream();&lt;br /&gt;
		InputStreamReader isr = new InputStreamReader(is);&lt;br /&gt;
		BufferedReader br = new BufferedReader(isr);&lt;br /&gt;
		&lt;br /&gt;
		String line;&lt;br /&gt;
		while ((line = br.readLine()) != null) {&lt;br /&gt;
			System.out.println(line);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mejores Prácticas ==&lt;br /&gt;
&lt;br /&gt;
Los desarrolladores deben evitar invocar la shell usando Runtime.exec para llamar a comandos del sistema operativo y en su defecto deben usar la API de Java. Por ejemplo, en vez de llamar lsor dir desde la sell se debe usar la clase Java File para la función de listado. Si es necesario que el usuario deba ingresar datos y pasarlos hacía Runtime.exec, y luego usar expresiones regulares para validar el ingreso.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>José Luis Escobar</name></author>	</entry>

	</feed>