Skip to content
Access control Write-up Advanced

The Anatomy of a Bug Door: Dissecting Two D-Link Router Authentication Bypasses

Two authentication bypasses existed in the HNAP protocol handling of D-Link routers. An attacker could bypass authentication by sending an empty LoginPassword or by including a PrivateLogin element set to 'Username', which caused the router to use the username as the password.

zerodayinitiative.com

Published on zerodayinitiative.com

Back in February, D-Link released a firmware patch for two authentication bypass vulnerabilities, ZDI-20-267 (CVE-2020-8863) and ZDI-20-268 (CVE-2020-8864), that affected the D-Link DIR-882, DIR-878 and DIR-867 routers. These wonderful bugs resided in the handling of the HNAP protocol.

The author, on zerodayinitiative.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the first bug was caused by calling strncmp() with a length of zero when the supplied password was empty, and the second by a hidden code path that used the username as the password when a PrivateLogin element containing 'Username' was present.

Impact

An attacker could bypass authentication and gain administrative access to the router without knowing the real admin password.

What the attacker needed

Network access to the router's HNAP interface

How it was found

  1. Send an HNAP request message to obtain an authentication challenge from the server.
  2. Receive the Challenge, Cookie and PublicKey values from the server.
  3. For ZDI-20-268, send a login message with an empty LoginPassword value.
  4. For ZDI-20-267, include a PrivateLogin element containing 'Username' in the login request.
  5. The server generates the PrivateKey using the username instead of the real password, allowing the attacker to compute the correct LoginPassword response.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

These routers use a login protocol called HNAP. One bug let an attacker log in by sending a blank password because the password check compared zero characters and treated that as a match. Another bug let an attacker add a special field to the login request that made the router use the username as the password, so the attacker could compute the correct login response without knowing the real password.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.