Ethical Hacking

Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package.
Computer Forensics Training at InfoSec Institute

Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors.




Network Security Exploits-HackingTools
[Top] [All Lists]

[NEWS] JavaMail Directory Traversal Vulnerability

Subject: [NEWS] JavaMail Directory Traversal Vulnerability
Date: 17 Apr 2005 17:06:20 +0200
The following security advisory is sent to the securiteam mailing list, and can 
be found at the SecuriTeam web site: http://www.securiteam.com
- - promotion

The SecuriTeam alerts list - Free, Accurate, Independent.

Get your security news from a reliable source.
http://www.securiteam.com/mailinglist.html 

- - - - - - - - -



  JavaMail Directory Traversal Vulnerability
------------------------------------------------------------------------


SUMMARY

The JavaMail API provides a platform-independent and protocol-independent 
framework to build mail and messaging applications. The JavaMail API is 
implemented as a Java platform optional package and is also available as 
part of the Java 2 platform, Enterprise Edition.

The JavaMail API doesn't properly validate filename attribute in 
Content-Disposition header, making it vulnerable to directory traversal 
attacks. Successful exploitation of this vulnerability allows writing 
arbitrary content in any directory accessible to the servlet running 
JavaMail.

DETAILS

Vulnerable Systems:
 * JavaMail version 1.3.2

MimeBodyPart.getFileName () method in the JavaMail API get the filename 
associated with body part, if possible. The body part represents an 
"attachment" that was loaded from a file. While in the documentation of 
the function claims that the file name does not need to include path of 
directory, it doesn't properly filter file name attribute in 
Content-Disposition header, and it is possible to place a directory path 
with the file name.

In order to exploit the problem, send an email with the following filename 
attribute in Content-Disposition header:
./../../file.ext

This will write attachment three directories backward from expected 
location, as long as the servlet processing the email has writable access 
to that directory.

Example:
This method uses getFileName () method to save the first attachment into a 
file:

protected void saveMailAttachment (javax.mail.internet.MimeMultipart mp) {
 try {
   int n = mp.getCount();
   javax.mail.Part p = mp.getBodyPart (0);
   String disposition = p.getDisposition ();
 
   if (disposition != null && (disposition.equalsIgnoreCase 
(javax.mail.Part.ATTACHMENT) || disposition.equalsIgnoreCase 
(javax.mail.Part.INLINE) ) ) {
      String filename = p.getFileName ();
      File f = new File (filename);
      OutputStream os = new BufferedOutputStream (new FileOutputStream (f) 
);
      InputStream is = p.getInputStream ();
      int c;
      while ( (c = is.read () ) != -1) os.write (c);
      os.close ();
   }
 } catch (Exception e) { }
}


ADDITIONAL INFORMATION

The information has been provided by  <mailto:smcsoc@yahoo.es> Rafael San 
Miguel Carrasco .



======================================== 


This bulletin is sent to members of the SecuriTeam mailing list. 
To unsubscribe from the list, send mail with an empty subject line and body to: 
list-unsubscribe@securiteam.com 
In order to subscribe to the mailing list, simply forward this email to: 
list-subscribe@securiteam.com 


==================== 
==================== 

DISCLAIMER: 
The information in this bulletin is provided "AS IS" without warranty of any 
kind. 
In no event shall we be liable for any damages whatsoever including direct, 
indirect, incidental, consequential, loss of business profits or special 
damages. 




<Prev in Thread] Current Thread [Next in Thread>
  • [NEWS] JavaMail Directory Traversal Vulnerability, SecuriTeam <=