What did we test?

We verified the possibility of reading the credentials file user.dat without authentication via the API (8728) or WinBox (8291) ports on various RouterOS v6 versions. Additionally, we analyzed the password field structure to determine if it was possible to derive the plaintext password offline.

How was the lab set up?

The test was performed on an isolated home-lab (network 10.13.0.0/24) with no Internet access. Four virtual routers (CHR) were used with the following versions:

  • chr5: 6.40.5 and subsequently 6.40.8 (fix)
  • chr7: 6.38.4
  • chr8: 6.34.6
  • A base instance with 6.49.2

For offline analysis, Python scripts (deriv.py, decrypt_userdat.py) based solely on the standard library were used, along with local MCP consultants for validating CVE information.

The exam material · CVE-2018-14847Reserved for dojo members: join for free to download it

How to reproduce?

  1. Unauthenticated access: Use an API or WinBox client to connect to the router on port 8728 (API) or 8291 (WinBox).
  2. File read: Execute the command read-file specifying the path /user.dat.
    • On affected versions (e.g., 6.49.2, 6.40.5), the command returns the file content in base64.
    • On fixed versions (e.g., 6.40.8), the command returns Permission denied.
  3. Offline decoding: Decode the base64 content to obtain the raw bytes of user.dat.
  4. Password derivation: Apply the confirmed XOR formula:
    key = MD5((username + "283i4jfkai3389").encode()).digest()[:12]
    password = field12_bytes XOR key

    Where field12_bytes are the first 12 bytes of the credential field associated with the user.

What happened?

  • Successful read: On all pre-fix versions tested (6.49.2, 6.40.5, 6.38.4, 6.34.6), the file user.dat was successfully read without authentication.
  • Password recovery: The XOR formula based on MD5 and a static constant (283i4jfkai3389) allowed recovering the plaintext passwords for users admin (password passtest1234) and probeuser (password zzz_probe999).
  • Fix verification: On versions 6.40.8, 6.42.11, and 6.49.7, the unauthenticated read attempt was blocked with error Permission denied.
  • Note on version 6.30.0: The PoC used does not support this specific API version, so direct verification was not performed, but the fix logic applies from 6.40.8 onwards.

How to protect yourself?

  1. Update the firmware: Immediately update to RouterOS 6.40.8 or higher (7.x recommended) to apply the vulnerability patch.
  2. Limit exposure: Do not expose the API (8728) and WinBox (8291) ports to the Internet; use them only via VPN or trusted internal networks.
  3. Monitoring: Implement log alarms for unauthenticated read attempts of the file user.dat.
  4. Credential management: Use non-default accounts and complex passwords, keeping in mind that on vulnerable versions these can be recovered in plaintext.

Frequently asked questions

Is the password stored as a hash?

No, it is not a resistant hash. It is the result of an XOR between the password and a key derived from the MD5 of the username and a static constant. This makes the transformation invertible offline.

Does the issue also affect RouterOS v7?

The report indicates that the fix has been present since 6.40.8 and that 7.x versions are mitigated. The vulnerability is specific to v6 versions prior to the fix.

Can I recover the password if I only have the user.dat file?

Yes, if the router version was vulnerable (pre-6.40.8), it is possible to recover the plaintext password offline by applying the XOR formula with the known constant 283i4jfkai3389.