KeePass Password Safe 1.22 - Encoding Filter Vulnerability

Type vulnerlab
Reporter Vulnerability Laboratory [Research Team] - Benjamin Kunz Mejri (
Modified 2012-06-24T00:00:00


                                            Document Title:
KeePass Password Safe 1.22 - Encoding Filter Vulnerability

References (Source):

Release Date:

Vulnerability Laboratory ID (VL-ID):

Common Vulnerability Scoring System:

Product & Service Introduction:
KeePass is a very famous & free open source password manager, which helps you to manage your passwords in a secure way. 
You can put all your passwords in one database, which is locked with one master key or a key file. So you 
only have to remember one single master password or select the key file to unlock the whole database. 
The databases are encrypted using the best and most secure encryption algorithms currently known (AES and Twofish).

(Copy of the Vendor Homepage: )

Abstract Advisory Information:
The Vulnerability Laboratory Research Team discovered a software filter & validation vulnerability in the KeePass Password Manager v1.22 & older versions.

Vulnerability Disclosure Timeline:
2012-06-13:	Researcher Notification & Coordination (Benjamin Kunz Mejri - Vulnerability Labs)
2012-06-14:	Vendor Notification (Keepass Developer Team)
2012-06-20:	Vendor Response/Feedback  (Keepass Developer Team)
2012-06-26:	Public Disclosure  (Vulnerability Laboratory)
2012-07-01:	Vendor Fix/Patch  (Keepass Developer Team)

Discovery Status:

Affected Product(s):
Domenic Reichl
Product: Keypass Password Safe 1.22 & older versions

Exploitation Technique:

Severity Level:

Technical Details & Description:
A software filter encoding validation vulnerability has been discovered in the KeePass Password Manager v1.22 & older versions.
The bug allows an attacker (local) to implement/inject malicious script code when processing to export a manipulated database file.

The vulnerability is located in the validation of the html/xml export function/module & the connected vulnerable domain/url parameter. 
URLs of entries are embedded in the exported HTML file without secure parse of the XML against special chars. Attackers can inject a 
url by add to the dabase. The execution occurs when the URL (domain) field of an entry contains a malicious script code, this will be 
executed when the exported as HTML file via browser.

Exploitation of the vulnerabilitiy requires a manipulated url with malicious script code, a logging server with chmod 777, a 
listing file (random) & a keypass v1.22 + user. The payload will be injected locally and affects the local validation (html/xml) 
on exports. The injection of the malicious url/domain context can be done via import (victim browser add) or manually (reproduce) 
by including. Successful exploitation of the vulnerability lead to stable (persistent) context manipulation of the database file, 
persistent phishing, execution of malware or stealing plain password lists. Medium user inter action is required to exploit 
the vulnerability.

Vulnerable Section(s):
				[+] Export

Vulnerable Module(s):
				[+] HTML
				[+] XML 

Vulnerable Parameter(s):
				[+] URL (Domain)

Proof of Concept (PoC):
The persistent script code inject & execution can only be exploited by local attackers with medium user interaction. 
For security demonstration or to reproduce the vulnerability follow the provided information and steps below to continue.

Normally KeePass Password Manager exports the html backup with a secure clean template like ...

<th>URL</th><th>Password</th><th>Notes</th><th>UUID</th><th>Icon</th><th>Creation Time</th><th>Last Access</th>
<th>Last Modification</th><th>Expires</th><th>Attachment Description</th><th>Attachment</th></tr>
<tr><td>mypass category</td><td>my keypass test</td><td>asdfas</td><td>asd</td>

The local attacker manipulates the database with malicious payloads (script code) in the category item profile name input fields.
KeePass Password Manager generates the clean html template but the persistent code is executes directly in the exported html 
template file.

<tr class=``MyAccountNameRow``>
 <td align=``right`` width=``150px``>Name des Benutzerkontos: </td>
 <td><b>``><[PERSISTENT SCRIPT CODE]`) <<=`` b=``></td>

Exploitation Scenario:
Attacker sneds the victim a manipulated login page with script code in the url parameters. The script code impacts 
a html or js script which responds to a url with chmod 777 (other server) to exchange of the file when processing 
a local request. The victim with keypass saves the url via browser or imports it via module (backup, xml & co). After 
some time the victim exports the file as html plain file with the keepass template. The script code of the url executes 
and transfers the context of the listed plain file to the attackers listening website script.

<tbody><tr><th>Password Groups</th><th>Group Tree</th><th>Title</th><th>User Name</th><th>URL</th>
<th>Password</th><th>Notes</th><th>UUID</th><th>Icon</th><th>Creation Time</th><th>Last Access</th>
<th>Last Modification</th><th>Expires</th><th>Attachment Description</th><th>Attachment</th></tr>
<tr><td>mypass category</td>
<td>my keypass test</td><td>asdfas</td><td>asd</td><td><a href=""><[PERSISTENT SCRIPT CODE]")' <"="">
"><iframe src= onload=alert("keepass") 
td>bdd4c872495537e65493cd08d1a2489b</td><td>0</td><td>2012-06-13 22:17:28</td
><td>2012-06-13 22:22:12</td><td>2012-06-13 22:17:28</td><td>2999-12-28 
23:59:59</td><td> </td><td> </td></tr>

PoC:  XML for Imports
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
	<group tree="my keypass test">mypass category</group>
	<expiretime expires="false">2999-12-28T23:59:59</expiretime>

Note: Manual export required by the database user itself for successful exploitation!

Solution - Fix & Patch:
Special characters in URLs (domain) parameter of XML & HTML files needs to be parsed when processing to export in the keepass software.

2012-07-01:	Vendor Fix/Patch  - Keepass v1.23

Development Version (fixed!):

Security Risk:
The security risk of the persistent script code injection software vulnerability in the export function is estimated as medium.

Credits & Authors:
Vulnerability Laboratory [Research Team]  -    Benjamin Kunz Mejri (

Disclaimer & Information:
The information provided in this advisory is provided as it is without any warranty. Vulnerability-Lab disclaims all warranties, 
either expressed or implied, including the warranties of merchantability and capability for a particular purpose. Vulnerability-
Lab or its suppliers are not liable in any case of damage, including direct, indirect, incidental, consequential loss of business 
profits or special damages, even if Vulnerability-Lab or its suppliers have been advised of the possibility of such damages. Some 
states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation 
may not apply. We do not approve or encourage anybody to break any vendor licenses, policies, deface websites, hack into databases 
or trade with fraud/stolen material.

Domains:   	-			       -
Contact: 	- 	       -
Section: 	- 		       -
Social:!/vuln_lab 		- 	       -
Feeds:	-   -

Any modified copy or reproduction, including partially usages, of this file requires authorization from Vulnerability Laboratory. 
Permission to electronically redistribute this alert in its unmodified form is granted. All other rights, including the use of other 
media, are reserved by Vulnerability-Lab Research Team or its suppliers. All pictures, texts, advisories, sourcecode, videos and 
other information on this website is trademark of vulnerability-lab team & the specific authors or managers. To record, list (feed), 
modify, use or edit our material contact ( or to get a permission.

    				   	Copyright © 2012 | Vulnerability Laboratory