The default configuration of the Unanet web application has a backdoor that can allow unauthenticated users to login and manipulate the user accounts and the roles they maintain. This vulnerability is due to a code branch that exists within the product that maintains a hardcoded user that is unlisted in the users table of the database. The user was originally identified via a user enumeration vulnerability (see below).
Although the user is unable to login directly, the vulnerable nature of how session cookies function within Unanet (zero entropy and no session timeouts) allows anyone to bypass the need to authenticate with this user.
The construction of a Unanet session cookie is as follows, UserID, username in uppercase, roles concatenated together with '^', static cookie value, and digest. The digest is created similar to the following psuedo code:
username = "csanders".upper()
id="718"
roles = ["unaSourceUser","timesheetUser","expenseUser"]
cookval = "q4Z26w&3@1xya"
m = hashlib.md5(id+"|"+username+"|"+('^'.join(roles))+"|"+cookval)
digest = m.hexdigest()
Another issue is that usernames and ID's were available via a user enumeration. By iterating the 'personkey' value, each username and id would echo into an error page that could be parsed to obtain a list of existing usernames within the system.
Role values were also known as they exist within the 'Roles' tab on 'https://x.host.com/unanet/action/preferences'. The actual value that is used within the cookie is available as the value of each checkbox. We identified 19 roles within our environment. Without any knowledge of the normal roles associated with users (for instance customer and administrator are not typically used together) there are 19! permutations, with intelligence we brought this number down ~5! permutations, well within the range of a simple brute force.
Having obtained the userID, usernames, roles, the last remaining piece of data is the special cookie value. This value is referred to as a nonce. However, a nonce by definition is only used once (http://en.wikipedia.org/wiki/Cryptographic_nonce). This is set to a default value that is outlined in http://www.unanet.com/unadocs/unanet92/getting_started/installing_unanet/advanced/cookies_and_md5.htm. The default nonce value can be changed from 'q4Z26w&3@1xya' but this is only a recommendation, not a requirement.
As long as that default value has not been changed, the hidden cookie value can be brute forced offline using the knowledge of all other values. This is true because the algorithm for generating the digest is known and when userid, username, roles, and digest are known it becomes a simple problem of solving for the single missing variable.
However, it became clear that user unanet (id 0) was not handled in the same way. Since this user was identified by the user enumeration but not within our user list, we investigated the code. We found the following within the personfactory.class:
public static Person make(Long personKey, Connection con)
throws SQLException
{
if (personKey == null) {
return null;
}
if (personKey.longValue() == 0L) {
return makeAdmin();
}
public static Person makeAdmin()
{
Person unanet = new Person(Long.valueOf(0L), "UNANET", UNANET");
unanet.setName(new Name("Unanet", (Character)null, "Unanet", ull, unanet.getUsername()));
unanet.setPassword("UNANET");
unanet.setUnanetAdministrator(true);
unanet.setActive(true);
unanet.setPasswordDate(new java.util.Date());
return unanet;
This identified that if the personkey was zero, it would go to the makeadmin section. When this method was called, it generated a new person 'unanet' and assigned that password, 'UNANET'. More interestingly though it then called 'setUnanetAdministrator(true)'. Tracing that method we get:
public void setUnanetAdministrator(boolean unanetAdministrator)
{
if (unanetAdministrator) {
addGroup("__unanetAdministrator__");
} else {
removeGroup("__unanetAdministrator__");
}
}
After uncovering the UserID, Username, and seeing the secret group __unanetAdministrator__, we could now generate our digest. Our cookie then becomes:
'unanetAccess=0%7CUNANET%7C__unanetAdministrator__%7C477c49a990eeabde873313578ce1daeb'
We were able to successfully log in with this user.
This is not some deep, arcane issue. Anyone having access to a Unanet system is capable of generating the same conclusion via a simple code review. Additionally, even if the cookie 'nonce' was changed, any user of the system (or attacker who intercepts a request) is capable of brute forcing the new nonce offline. Currently any system that has not changed their cookie 'nonce' is vulnerable to an unauthenticated attacker being able to login with unanetAdministrator privileges. This includes public facing instances of Unanet. A simple Google search (http://www.google.com/#q=intitle%3Aunanet+Login) returns ~1600 results of such instances.
Exploitation of this vulnerability allows an unauthenticated attacker access to remove users, change roles, and create a new administrator. An attacker can use these privileges to deny availability, comprise integrity, and remove confidentiality.
Steps to Reproduce
Mitigation
Fixes for this issue were released in Unanet versions 10.0.51, 10.1.43, and 10.2.5.
For more information see the Trustwave advisory: TWSL2017-004