A Deep Dive Into Router Hardcoded Key Risks

Discover critical flaws in TP-Link Archer AX10 backups—hardcoded AES keys and weak encryption expose Wi-Fi and DDNS credentials.
Router Hardcoded Key Security Risks

Router configuration backups are essential for disaster recovery but can become a critical vulnerability if encryption is flawed. In this technical deep dive, we dissect a router’s backup/restore mechanism, exposing how hardcoded AES-256-CBC keys and a multi-layered encryption process can be exploited to extract sensitive data like Wi-Fi passwords and DDNS credentials.

Target:

Device: Archer AX10 AX1500

Firmware Version: 1.3.10 Build 20240130

Intro:

I downloaded a TP-Link router config. When inspecting the config file with strings I just got junk data. When inspecting the file with binwalk it reports that the file has high entropy which means the file is most likely compressed or encrypted.

Wanting to decipher this config i went ahead and downloaded the firmware from the TP-Link. The file was “Archer AX10_240130.zip”

When extracting the archive it contained a file named “ax10v2-up-ver1-3-10-P1[20240130-rel77367]_2024-01-31_09.13.04.bin”

I ran then ran binwalk to extract the firmware

Binwalk successfully identified the Squashfs filesystem and extracted it to a folder.

The Backup Process: A Multi-Step Compression & Encryption Journey

I then ran “find . -name *backup*” and “find . -name *restore*”

The following files were found

  • /usr/bin/tr069/mybackup
  • /usr/bin/tr069/myrestore

Upon inspecting the backup file I found the following.

It has multiple step which including decompressing and decryption however there is no encryption key in this file

The script uses cry which comes from local cry = require “luci.model.crypto” for encryption and decryption

Upon inspecting this file ”/usr/lib/lua/luci/model/crypto.lua” I found the AES Key and IV and the encryption method AES-256-CBC

I used a decompiler from https://github.com/CPunch/LuaPytecode to output the screenshot above. The same result can be found using tools such as strings or xxd. I have removed part of the key and iv for legal reasons.

After analysing the backup and restore scripts, I came up with the following steps and developed a script to reveal the plain-text xml file.

Steps:

  1. Decrypt the config
  2. Decompress the config
  3. Save first 16 bytes (MD5 hash) from config this is needed if you want to repackage it
  4. Strip the first 16 bytes from config write to a new config file
  5. Decompress the config
  6. Decrypt the config
  7. Decompress the config

After completing these step’s I was able to obtain the config in a plain-text xml file.

XML File Contents:

Source Code:

#!/bin/bash

zlib-flate -compress < ori-backup-user-config.xml > output/tmp/archive-ori-backup-user-config.bin

echo “Compressed ori-backup-user-config.xml”

# Encrypt the compressed configuration file

openssl enc -aes-256-cbc -in output/tmp/archive-ori-backup-user-config.bin -out output/tmp/ori-backup-user-config.bin -K “PUT YOUR ENCRYPTION KEY HERE” -iv “PUT YOUR IV HERE” -nosalt

echo “Encrypted archive-ori-backup-user-config.bin”

# Create a tar archive of the encrypted configuration file

tar -cf output/read-backup-userconf.bin -C output/tmp ori-backup-user-config.bin

echo “Created read-backup-userconf.bin”

# Add the first 16 bytes (Product MD5) to the beginning of the tar archive

cat output/product_md5 output/read-backup-userconf.bin > output/tmp/backup-userconf.bin

echo “Added product_md5 to tmp/backup-userconf.bin”

# Compress the tar archive

zlib-flate -compress < output/tmp/backup-userconf.bin > output/read-backup-userconf.bin

echo “Compressed read-backup-userconf.bin”

# Encrypt the compressed tar archive

echo “Encrypting read-backup-userconf.bin”

openssl enc -aes-256-cbc -in output/read-backup-userconf.bin -out “$1” -K “PUT YOUR ENCRYPTION KEY HERE” -iv “PUT YOUR IV HERE” -nosalt

echo “Output written to $1” 

Critical Risks

  1. Hardcoded Keys: The same key/IV pair is used across all devices of this model, making every backup vulnerable.
  2. Double Encryption : Inner/outer encryption layers provide no security if the key is known.

Conclusion

By reverse-engineering the backup/restore process, I’ve shown how hardcoded keys can be exposed and used against the backup config. Vendors must adopt modern key management practices, while users should demand transparency about encryption methodologies.

Final Note: Always treat router backups as highly sensitive.

To learn more about how we integrate best practice cyber security measures with business strategies to keep your IT systems secure and your data safe – get in touch with us
 
author avatar
tim.hoekstra

tim.hoekstra

Share this post

Other Insights

Man in a light blue shirt and glasses sits at a desk, thinking with his hand on his chin in front of an open laptop.

What Vanta Doesn’t Do for ISO 27001 (And Who Fills the Gap)

Vanta automates evidence collection and monitors technical controls, but ISO 27001 also requires risk decisions, tailored policies and effective organisational controls. Learn where expert support fills the gaps.
Network infrastructure and server connections representing the systems Australian businesses should review for cyber threats

Cyber Threats Are Combining Automation and Hands-On Attacks: 5 Actions for Australian Businesses

An Australian Cyber Security Centre advisory highlights cyber actors combining automated tools with hands-on techniques. Here are five practical steps Australian businesses can take to improve visibility, access controls and incident readiness.

Stay Informed with Our Security Newsletter

Get the latest threat intelligence, security insights, and industry updates delivered directly to your inbox.

Scroll to Top