For engineers

Default passwords and keys in firmware: find and fix them

By Manish SharmaPublished 6 min read

One default password or shared private key can fail a lab test and put every device at risk. Hard-coded secrets in firmware sit in six places: the account database, the web interface's configuration, init scripts and NVRAM defaults, keys and certificates, cloud and API tokens, and program strings. The fix is the same everywhere: nothing secret is the same on two devices, and secrets are created at first boot or in the factory and stored securely. The release fails if a known secret is found in the image.

In short

  • Hard-coded secrets hide in six places: account databases, web interface files, init scripts and NVRAM defaults, keys and certificates, cloud tokens, and program strings.
  • One extracted image is enough. A shared password or key found in it works on every device you have sold.
  • The fix is a rule and a gate: no secret is the same on two devices, and the build fails if a known one turns up.

Six places, one fix

Hard-coded secrets hide in six places in a firmware image:

  • the account database
  • the web interface's own files
  • init scripts and NVRAM defaults
  • certificates and private keys
  • cloud tokens
  • the strings inside programs

Each one turns a single extracted image into access to every device you have sold. The fix is a rule and a gate. No secret may be the same on two devices, secrets are made on the device or in the factory, and the build fails if a known one turns up.

The rules agree. ETSI EN 303 645 forbids universal passwords outside the factory default state (5.1-1) and hard-coded critical security parameters in source code (5.4-3).

India's CCTV test reviews all code, third-party binaries included, for hard-coded credentials and backdoors (item 2.6). It also asks for keys unique to each device (item 1.2). MITRE files the mistakes as CWE-798, CWE-1392 and CWE-321.

Why one image is enough

An attacker does not need your device, only your update file, because once it is unpacked a shared password or key works on every unit.

CISA's 2016 alert on Mirai described a botnet that found its victims with a list of 62 common default usernames and passwords. In 2015, CERT/CC's VU#566724 documented home routers, IP cameras and VoIP phones shipping the same X.509 certificates and SSH host keys. That allows impersonation and decryption of their traffic.

1. The account database

Start with /etc/passwd and /etc/shadow. Three things matter:

  • Accounts with no password. An empty second field in /etc/shadow lets anyone log in as that user over any service that accepts it.
  • Extra accounts with user id 0. A second root account is the classic backdoor.
  • Weak or known hashes. DES crypt and MD5 crypt ($1$) fall to commodity cracking, and a hash of a published default password is as good as the password itself.

A line to worry about looks like this, with the hash shortened:

root:$1$<salt>$<hash>:19000:0:99999:7:::
support::19000:0:99999:7:::

Some legitimate firmware ships with no root password by design and forces the choice at first use. OpenWrt's documentation says a fresh install has no root password, and tells you to set one in the web interface. That is defensible for a general-purpose router OS, and ETSI 5.1-1 allows a factory default state. The test is whether the device refuses to work normally until the password is set.

2. The web interface's own files

Embedded web servers keep their own credentials, separate from /etc/shadow. Look for password files for lighttpd, Boa or GoAhead, JSON or INI files for the management application, and CGI scripts that compare the submitted password with a constant.

Open camera firmware documents its defaults openly. The OpenIPC web interface's README gives root with password 12345 and asks for a change at first login. Your product needs the same forced change, or a unique password printed on each unit.

Check the streaming side too. RTSP and ONVIF services in cameras can have their own accounts in their own configuration files. A stream that needs no login at all is the same problem in a different shape.

The secrets findings for a firmware release in FDIE, each with its type, the file it was found in and the value masked.

3. Init scripts and NVRAM defaults

Boot scripts set things that never appear in any configuration file. Look in /etc/init.d, /etc/inittab, rc files and any vendor startup script for:

  • chpasswd or passwd fed a constant, which resets a password on every boot;
  • telnetd -l /bin/sh or a shell bound to the serial console, which skips login altogether;
  • nvram set lines and NVRAM default dumps carrying the administrator, Wi-Fi or PPPoE passwords.

NVRAM defaults deserve care. A factory reset restores them, so a secret there survives every attempt to fix it in the field.

4. Certificates and private keys

Every PEM file in the image needs an owner. A private key shipped in the image is known to anyone with the image. So a TLS server key, an SSH host key or, worst of all, the key that signs your updates must not be there.

Generate host keys at first boot, or provision them per unit in the factory into secure storage. Item 1.5 of India's CCTV requirements asks for keys in secure storage, and item 1.2 for keys unique to each device.

Check the certificates as well. RSA keys under 2048 bits, expired certificates and MD5 or SHA-1 signatures are findings even when the key is not secret.

UEFI firmware has its own version of the problem. PKfail (CVE-2024-8105, CERT/CC VU#455367, August 2024) was UEFI firmware shipped with test Platform Keys whose private halves were not secret. So anyone could sign boot code that Secure Boot would trust.

5. Cloud and API tokens

Connected devices talk to a cloud, and the credentials for that talk often travel inside the image. They include MQTT broker usernames and passwords, API keys for the vendor's backend, keys for peer-to-peer video SDKs and object storage keys for uploading clips.

ETSI EN 303 645 names API keys and private keys as exactly the kind of credential that reverse engineering finds. The fix is per-device identity: give each unit its own certificate or token at manufacture. Let the cloud issue short-lived credentials after the device proves who it is, and make every key revocable without a firmware update.

6. Inside the programs, and in bare-metal images

Secrets compiled into a program show up as strings: a password compared in a login function, a key in a data section. On Linux images, string search across every program finds most of them.

Microcontroller images are harder. Microchip's dsPIC and PIC24 parts store text two or three bytes to a 24-bit program word, which no plain string scan reads.

A check that searches text has little to go on in an image with little readable text, and a "pass" there means less.

How to fix each one

How to fix each one
WhereFixRule it answers
Account databaseNo empty passwords; one root; strong hashes such as SHA-512 crypt or yescrypt; unique or user-set password before first useETSI 5.1-1 and 5.1-2; CWE-1392
Web interface and servicesCredentials from the same unique source; no constant comparisons in code; authentication on every streamCCTV item 2.6; CWE-798
Init scripts and NVRAMNo passwords set from scripts; NVRAM defaults free of secrets; no shell without login on any consoleCCTV items 1.1 and 2.6
Keys and certificatesGenerated at first boot or provisioned per unit into secure storage; signing keys never in the imageCCTV items 1.2 and 1.5; CWE-321
UEFIProduction platform keys, never test keys; check every firmware variables file you shipVU#455367
Cloud tokensPer-device identity, short-lived tokens, revocation without an updateETSI 5.4-3

Then make it stick: fail the release when a known secret appears, so the next build cannot quietly bring one back.

Finding them before you ship

FDIE by Magdox looks for secrets and default credentials across the whole unpacked image: account databases, configuration, scripts, certificates and programs. It masks every value before results leave the analysis.

Seven of its 64 device checks cover credentials and keys. They range from hard-coded and published default credentials to private keys, tokens, password hashes and accounts without a password. The release gate can fail on any hard-coded credential.

The Credentials and keys group of device checks in FDIE, with results for hard-coded credentials, default credentials, password hashes, tokens, private keys and accounts without a password.

Questions

Why are default passwords in firmware dangerous?

Because every unit shares them and they end up in public lists. CISA's 2016 alert on the Mirai botnet described malware that scanned for devices using a short list of 62 common default usernames and passwords.

Is a default password allowed if the user must change it?

ETSI EN 303 645 provision 5.1-1 requires passwords to be unique per device or defined by the user in any state other than the factory default. Forcing a change before first use meets that; a shared password that keeps working does not.

What is PKfail?

CVE-2024-8105, published by CERT/CC as VU#455367 in August 2024. UEFI firmware shipped with test Platform Keys, so anyone holding the matching private key could sign boot code that Secure Boot would accept.

How do I keep a private key out of my firmware image?

Generate it on the device at first boot, or provision it per unit in the factory into secure storage, and ship only the code that uses it. Item 1.2 of India's CCTV requirements asks for keys and certificates unique to each device.

Sources

  1. CISA alert TA16-288A, Heightened DDoS Threat Posed by Mirai and Other Botnets cisa.gov
  2. CERT/CC VU#566724, Embedded devices use non-unique X.509 certificates and SSH host keys kb.cert.org
  3. CERT/CC VU#455367, Insecure Platform Key (PK) used in UEFI system firmware signature (CVE-2024-8105) kb.cert.org
  4. ETSI EN 303 645 V3.1.3, Cyber Security for Consumer Internet of Things (PDF) etsi.org
  5. STQC, IoTSCS P01 Procedure for CCTV Testing, Evaluation and Certification (PDF) stqc.gov.in
  6. MITRE CWE-798, Use of Hard-coded Credentials cwe.mitre.org
  7. MITRE CWE-1392, Use of Default Credentials cwe.mitre.org
  8. MITRE CWE-321, Use of Hard-coded Cryptographic Key cwe.mitre.org
  9. OpenWrt, The OpenWrt Login openwrt.org
  10. OpenIPC microbe-web, README (default login) github.com
  11. Debian package tracker, edk2 (source of qemu-efi-aarch64) tracker.debian.org
  12. Bus Pirate firmware v8.0-rc2 release github.com

OpenWrt is a registered trademark of Software Freedom Conservancy; see openwrt.org. Product and project names are trademarks of their owners, used only to identify the public firmware, software and standards discussed. MAGDOX is not affiliated with or endorsed by them.

  • For leaders

    Choosing a firmware security platform: questions to ask first

    Firmware security tools are easy to compare on feature names and hard to compare on evidence. Choose a firmware security platform by what it can prove on your own images. Look at the formats and processors it reads, how it reports what it could not read, which SBOM and VEX formats it exports and which markets' rules it maps to. On the vendors' own pages, ONEKEY publishes a longer list of firmware formats, exports more CycloneDX versions and holds ISO/IEC 27001. FDIE by Magdox covers India's ER-01, NCCS ITSAR and TEC 31318, exports VEX in three formats and publishes measured rates. Both import supplier SBOMs.

    · 6 min read

  • For engineers

    Buyers asking for VEX? CycloneDX, OpenVEX and CSAF compared

    When a vulnerability makes the news, buyers ask whether your product is affected. CycloneDX, OpenVEX and CSAF all say the same thing, that a product is affected, not affected, fixed or under investigation for a vulnerability. But they name the product, the vulnerability and the reason differently. Map the four statuses one to one, and carry any justification label the target format lacks as text instead of guessing. Identify the product so the customer's tools can match it, and keep non-CVE identifiers out of fields that accept only CVEs.

    · 7 min read

  • For leaders

    Exporting devices to the EU? What the CRA asks of you

    Indian makers who sell into the EU are covered by the Cyber Resilience Act even without an EU office. The Cyber Resilience Act applies to Indian companies whose connected products are sold in the EU, through their own brand or through an importer. Since 11 September 2026 they must report actively exploited vulnerabilities within 24 hours. From 11 December 2027, every product they place on the EU market must meet the essential requirements, with a technical file kept for at least ten years.

    · 6 min read

Find out what the lab would flag in your firmware

A 45-minute call with our team. Bring one firmware image.

Request access