If you choose to read this article, please note that it will not discuss a vulnerability or a bug, but rather an intended behavior of Windows Command Prompt which, in my opinion, poses a security risk. I decided to publish it because I was not aware of this behavior, and most of the people I asked about it were not aware of it either. I would like to thank Microsoft’s MSRC for their prompt response to my report and the additional information they provided.
If you were already aware of the behavior shown in the following video, you can save yourself the trouble of reading this article
The Windows Command Prompt (cmd.exe) is the primary command-line shell used on Windows operating systems. This program is designed to interpret and execute a series of commands, passed as strings, both internal (e.g., “ping”, “ftp”, “notepad”, “calc”, etc.) and external (e.g., “blahblah”). The interpretation of the entered command follows the logic described at this link https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/start and can be summarized as follows:
Advertising
The user types a command, for example, “blahblah.”
The Windows command prompt checks whether the typed command has an extension.
This means that if a file with the name of the typed command exists in the directory from which the command prompt is executed, Windows will run it.
For example:
The user opens the command prompt from the folder “C:\test.”
The user types the command ftp.
The folder contains the file ftp.exe (e.g., C:\test\ftp.exe).
The command prompt will launch the executable “C:\test\ftp.exe.” instead of the legitimate one.
Is this a problem? In my opinion, yes and this is because of the way file extensions are managed.
If the typed command does not have an extension, the command prompt will use the %PATHEXT% variable to get the list of extensions and check them one by one, according to Windows standard search order. In our example, the command prompt will look for “C:\test\ftp.vbs”, “C:\test\ftp.dll”, “C:\test\ftp.exe”, and so on until it finds a file with an extension to execute in the same path. This significantly increases the chances of executing risky files disguised as legitimate commands. Keep in mind that this behavior will apply to all typed commands, included those saved in the “PATH” environment variable (e.g., “java”, “python”, “php”, “node”, etc.…)
A second risk is the possibility of executing commands from shared network folders:
The attacker places a malicious file “ping.exe” in a network drive, e.g., “Z:\test\ping.exe.”
The attacker convinces the victim to open the command prompt from the network drive “Z:\test” and type the command “ping.”
The command prompt will execute the program “Z:\test\ping.exe.”
Another attack scenario could involve creating a compressed file containing “ping.vbs”, convincing a user to decompress it and run the ping command from the folder where the archive that was decompressed.
An additional “remote” scenario might be:
The attacker creates a project or sample package containing a malicious file “node.vbs”
The attacker creates a repository on GitHub.
The attacker convinces the victim to download the package.
The victim runs the “node” command.
The Windows command prompt executes the malicious “node.vbs” file.
If you want to try it by yourself, just follow these steps:
Last but not lease, I tested some Windows internal commands and most of them can be (ab)used to replicate the behavior and this is the list of the tested commands with their respective status:
Command
Affected
cd
No
cls
No
copy
No
del
No
dir
No
md
No
mkdir
No
move
No
rd
No
ren
No
rename
No
type
No
cls
No
set
No
echo
Yes
rmdir
Yes
attrib
Yes
chkdsk
Yes
fc
Yes
format
Yes
mode
Yes
more
Yes
tree
Yes
ftp
Yes
ipconfig
Yes
net
Yes
ping
Yes
tracert
Yes
pathping
Yes
tasklist
Yes
taskkill
Yes
sc
Yes
sfc
Yes
diskpart
Yes
shutdown
Yes
compact
Yes
expand
Yes
nbtstat
Yes
xcopy
Yes
Follow us on Google News to receive daily updates on cybersecurity. Contact us if you would like to report news, insights or content for publication.
Ritorna lunedì 18 e martedì 19 maggio la Red Hot Cyber Conference 2026, l’evento gratuito creato dalla community di Red Hot Cyber, che si terrà a Roma in Via Bari 18, presso il Teatro Italia. L’iniziativa è pensata per promuovere la cultura della sicurezza informatica, dell’innovazione digitale e della consapevolezza del rischio cyber. Rappresenta un punto di incontro tra professionisti, studenti, aziende e appassionati del settore, offrendo contenuti tecnici, workshop e momenti di confronto ad alto valore formativo.
L’edizione 2026 si svolgerà a Roma nelle giornate del 18 e 19 maggio presso il Teatro Italia e includerà attività formative, sessioni pratiche e la tradizionale Capture The Flag. L’evento è completamente gratuito, ma la partecipazione è subordinata a registrazione obbligatoria tramite i canali ufficiali, al fine di garantire una corretta organizzazione e gestione degli accessi.
Le iscrizioni saranno disponibili a partire dal 16 marzo 2026 attraverso la piattaforma Eventbrite, dove sarà possibile registrarsi ai diversi percorsi dell’evento: workshop, conferenza principale e competizione CTF. I link ufficiali di registrazione saranno pubblicati sui canali di Red Hot Cyber e costituiranno l’unico punto valido per la prenotazione dei posti all’evento.