LogoSquare

Denim Group Website

My Photo
Powered by TypePad


Programming Blogs - Blog Catalog Blog Directory

Denim Group

« Command Injection in .NET: 82% Proven that is 98% Impossible | Main | Web Application Security Panel at Austin ISSA Next Week »

May 07, 2009

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83455143b69e2011570762ece970b

Listed below are links to weblogs that reference Command Injection In Java on Windows: 100% Proven that it is 100% Possible (in Certain Cases):

Comments

Jeff Williams

Dan, there are many other programs that allow injection besides cmd.exe. We see sendmail used pretty frequently like this. Anything with an interpreter is potentially injectable and may or may not have an escape syntax.

Also, don't forget injection into the executable path! Even without using cmd.exe there are a number of dangers here. Many applications allow the file to be executed to be specified by the attacker (crazy I know). Validation is difficult because Java passes a lot of strange characters through to Windows. For example, on Windows, adding trailing \0, space, period, slash, and backslash characters still allow the file to be accessed. Of these, the null byte is the worst, as it allows you to specify a completely different name, like ?file=malicious.exe%00innocent.txt. Then when the developer checks file.endsWith(".txt") it passes, but Windows returns the .exe file.

ESAPI has a SafeFile class to protect against this and an Executor class that requires you to specify the allowed executables in a whitelist. You can also use the WindowsCodec (Unix codec is there too) to properly escape user input for use on the command like. You can prevent some forms of injection by escaping characters with the caret ^.

sven

hi!
the link to the demo code is dead. may you can fix it please?
thanx sven

The comments to this entry are closed.