Engineer working on a laptop connected to a device test rig, surrounded by wiring harnesses and test hardware

Firmware vulnerabilities & fixes

How to fix hard-coded credentials in embedded firmware

Last updated:

Hard-coded credentials (MITRE CWE-798, and the password-specific CWE-259, both read 2026-10-29) are passwords, API keys or cryptographic keys embedded directly in firmware code, configuration or a binary — either a default admin login every unit of a product shares (the inbound case), or a secret the firmware itself uses to authenticate to a backend, update server or companion app (the outbound case). MITRE is direct about the blast radius: because the value is identical across every shipped unit, "it is almost certain that malicious users will gain access," and a value shared by all installations "enables massive attacks such as worms" — the exact pattern behind most default-credential IoT botnets.

Key takeaways

  • A shared secret turns one teardown into access to every unit.
  • Check source code and build scripts for credentials embedded in constants, environment defaults baked into the image, or test/debug accounts left enabled in release builds.
  • Most findings come from a small set of places.
  • For consumer IoT products, two texts turn this weakness into a market-access rule, and they do not cover the same things.

Why are shared credentials a fleet-wide problem?

A shared secret turns one teardown into access to every unit. MITRE's CWE-798 entry notes that an inbound hard-coded password "is the same for each installation of the product, and it usually cannot be changed or disabled by system administrators without manually modifying the program." That is why the fix is a firmware and manufacturing change, not a configuration tip for customers.

MITRE's own observed examples read like an embedded product inventory: Wi-Fi router firmware with a hard-coded password for a BusyBox shell reachable through the UART port (CVE-2021-35033), a remote terminal unit that ships a hard-coded SSH private key (CVE-2022-30271), and a PLC maintenance service with undocumented hard-coded credentials (CVE-2022-30997).

The class also shows up in active exploitation. In CISA's KEV JSON feed (catalog version 2026.11.10, 1,779 entries), 8 entries are tagged CWE-798 and 2 are tagged CWE-259. They include CVE-2024-3272, a hard-coded credential in four legacy D-Link NAS models that leads to remote code execution, and CVE-2019-6693, a hard-coded key protecting FortiOS configuration backups, which KEV marks as known to be used in ransomware campaigns. The count is small next to memory-safety bugs, but each entry exposes every unit of the affected product at once.

1. Detect

  • Extract firmware images (filesystem, bootloader, any OTA package) and search binaries and configuration files for plaintext passwords, API tokens, private keys, and common vendor-default strings (admin, password, root, device-model-based defaults).
  • Check source code and build scripts for credentials embedded in constants, environment defaults baked into the image, or test/debug accounts left enabled in release builds.
  • Audit every outbound connection the firmware makes (update servers, cloud APIs, companion-app pairing) for a fixed, shared API key or client secret rather than a per-device provisioned one.
  • Review the first-boot/provisioning flow: does every unit ship reachable over the network with the same default login active, or is a unique credential required before the device accepts remote connections?
  • Do not rely on string search alone. MITRE's detection notes say credentials in configuration files are findable from outside, but a hard-coded check in an inbound login routine "typically involves an account that is not visible outside of the code." Read the login and diagnostic handlers, or their disassembly, for comparisons against fixed strings.
  • Compare two images built for different units of the same model. Any secret that is byte-identical across both is shared by the whole fleet.

Where do hard-coded credentials hide in a firmware image?

Most findings come from a small set of places. Check each one in every image, including bootloader and recovery partitions.

Location in the image What to look for Variant
/etc/passwd, /etc/shadow, BusyBox login settings root or admin entries with a hash that is identical across builds, or an empty password field Inbound
Web server, CGI and diagnostic binaries comparisons against a literal "support" or "debug" user, hidden maintenance pages Inbound
Bootloader environment and serial console a fixed password to interrupt autoboot, a root shell on UART without a login Inbound, local
*.pem, *.key, SSH host keys the same TLS or SSH private key in every image, generated at build time instead of on the device Key, impersonation
Cloud, MQTT and update-client configuration a username/password, API key or client secret shared by the whole product line Outbound
Backup, export and licence routines a symmetric key compiled into the binary to encrypt exported data (the CVE-2019-6693 pattern) Key
Factory and test scripts a manufacturing test account or a script that enables telnet, left in the release build Inbound

Debug interfaces deserve their own pass: a UART console that drops to a root shell is a hard-coded credential with a physical attack vector. See JTAG and SWD debug port security. Test keys are another frequent case; the PKfail Secure Boot test key incident is the platform-firmware version of the same weakness.

What do ETSI EN 303 645 and UK PSTI require?

For consumer IoT products, two texts turn this weakness into a market-access rule, and they do not cover the same things.

Rule Requirement Covers keys and API tokens?
ETSI EN 303 645 V3.1.3, provision 5.1-1 In any state other than the factory default, all device passwords "shall be unique per device or defined by the user" Passwords only
ETSI EN 303 645, provision 5.1-2 Pre-installed unique passwords must be generated so they resist automated attacks; incremental counters and values tied to the MAC address or Wi-Fi SSID are given as counter-examples Passwords only
ETSI EN 303 645, provisions 5.1-4 and 5.1-5 A simple way for the user to change the authentication value, and brute-force protection on network interfaces Authentication values
ETSI EN 303 645, provision 5.4-3 "Hard-coded critical security parameters in consumer IoT device software source code shall not be used" Yes
ETSI EN 303 645, provision 5.4-4 Secrets used for update integrity and for communication with associated services must be unique per device Yes
UK PSTI Regulations 2023, Schedule 1, paragraph 1 Passwords must be unique per product or defined by the user, and not based on counters, public information or product identifiers such as serial numbers unless derived with an accepted keyed method No: the paragraph excludes cryptographic keys, non-IP pairing PINs and API keys

The UK rules came into force on 29 April 2024. The practical point for an engineering team: passing the PSTI password rule does not clear an outbound API key or a shared private key. ETSI provisions 5.4-3 and 5.4-4 do catch those. See ETSI EN 303 645 explained and PSTI and the Cyber Trust Mark.

2. How do you fix it?

  1. Move outbound credentials out of the code entirelyMITRE's mitigation for the outbound case: store the credential "outside of the code in a strongly-protected, encrypted configuration file or database that is protected from access by all outsiders," provisioned uniquely per device during manufacturing or first boot — not baked identically into every firmware image.
  2. Replace default inbound accounts with mandatory first-login provisioningRequire each unit to set a unique, strong password or key before any network-facing admin function becomes reachable, instead of shipping with a fixed default that works out of the box.
  3. If you pre-install a password, make it random per unitGenerate it from a cryptographic random source on the production line, print it on the label, and store it in the device's protected storage. ETSI's examples rule out counters and values derived from public data such as the MAC address.
  4. Prefer keys over passwords between machinesETSI provision 5.1-2A recommends against passwords for machine-to-machine authentication. A per-device key pair or client certificate, created on the device or injected at manufacturing, replaces a shared cloud password.
  5. Scope access to the credential-gated featureWhere a hard-coded value cannot be removed immediately (for example, a manufacturing-test backdoor), restrict it to a local, physically-present interface — a serial console or JTAG header — rather than leaving it reachable over the network, and schedule its removal.
  6. Hash stored passwords with a per-installation saltIf a password must be stored at all (rather than a key), use a strong one-way hash with a randomly assigned salt per device, so that extracting the configuration store does not directly yield a usable credential. The OWASP Password Storage Cheat Sheet recommends Argon2id with at least 19 MiB of memory, an iteration count of 2 and 1 degree of parallelism, scrypt as the fallback, and PBKDF2 with at least 600,000 iterations where FIPS-140 compliance is required. On a device with little RAM, PBKDF2 or scrypt with tuned parameters is often the realistic choice.
  7. Treat this as a class, not a one-offIf one product line has a default-credential issue, check every other product line and firmware branch built from the same SDK or reference design for the same pattern before declaring the fix complete.

Worked example: how do you replace a shared default on a camera?

Synthetic example. The product, accounts and values are invented for illustration.

A hypothetical Wi-Fi camera ships with a web admin account admin / admin on every unit, and its cloud client authenticates to the vendor's MQTT broker with one username and password compiled into the binary. The fix, in order:

  1. InventoryExtraction finds the admin hash in /etc/shadow, the broker password as a string in the cloud client, and one TLS client key shared by all units.
  2. InboundDelete the default admin password from the image. On first boot the camera only serves a local setup page. The user sets a password in the companion app, or enters a random per-unit setup code printed on the label. Remote admin opens only after that step.
  3. OutboundThe production line generates a key pair inside each camera, the vendor's factory CA signs a client certificate, and the broker authenticates cameras by certificate. The shared broker password is revoked once the fleet has migrated.
  4. StorageThe setup code and the user's password are kept only as a salted hash; the private key sits in the SoC's protected storage, where available.
  5. Fleet in the fieldA signed update forces existing units into the same first-login flow at next restart and swaps them to per-device certificates. Until the update reaches every unit, the broker keeps a short allowlist of old units and logs every login on the shared account.
  6. Release gateA build check fails if any image contains a private key or a non-empty password hash in /etc/shadow.

3. Verify

  • Re-flash the patched firmware to a test unit, confirm the device refuses to operate (or operates in a restricted provisioning-only mode) until a unique credential is set, and confirm the old default no longer authenticates.
  • Re-extract the new firmware image and confirm no plaintext credential remains in the filesystem, configuration or binary.
  • Confirm outbound connections now use a per-device credential by provisioning two test units and checking they use different values against the backend.

What are the common pitfalls?

  • Obfuscating instead of removing. The text under ETSI provision 5.4-3 warns that "simple obfuscation methods also used to obscure or encrypt this hard-coded information can be trivially broken." A key that decrypts the secret is itself a hard-coded secret.
  • "Unique" passwords derived from the serial number or MAC address. PSTI forbids this unless an accepted encryption or keyed-hash method is used, and ETSI lists MAC- and SSID-derived passwords as counter-examples.
  • Fixing the web login but leaving UART, telnet or a diagnostic daemon with the old account.
  • Forgetting the outbound side. A per-device admin password with a shared cloud API key still lets one teardown reach every customer's data. OWASP's Secrets Management Cheat Sheet calls out keys "hardcoded within the source code in plaintext" for this reason and covers rotation and revocation.
  • Keeping the shared secret valid after the fix. If the backend still accepts the old credential, the update has not closed anything.
  • End-of-life models. For CVE-2024-3272, KEV's required action is to retire and replace the affected D-Link products, because they are no longer supported. Decide how long each model gets credential fixes before it ships.

4. Ship an update

Hard-coded-credential fixes usually require a provisioning-flow change, not just a firmware flash, so coordinate the update with manufacturing and any existing fleet: units already in the field need a forced password-rotation path (and, if remotely reachable, a remediation notice), not just a silent binary swap. Confirm affected models and versions with your firmware SBOM before scoping the rollout. Rotate every outbound secret that was ever shipped in an image: once it has been in a public firmware download, treat it as published.

5. Disclose via PSIRT

Hard-coded credentials do appear in CISA's Known Exploited Vulnerabilities catalog, as the KEV entries above show, so treat disclosure as time-sensitive; see KEV + EPSS prioritization. Publish the advisory and remediation guidance through your coordinated disclosure process (CVD process explained; PSIRT setup for a hardware company if you have no PSIRT today), and check the Cyber Resilience Act's reporting duty for EU-market products if the credential was being actively exploited (CRA 24h/72h reporting). Name the weakness as CWE-798 or CWE-259 in the advisory; see the CWE Top 25 guide for how MITRE ranks weakness classes.

What can SoftWSP check, and what needs a firmware review?

SoftWSP extracts a firmware image into a CycloneDX SBOM, matches its components against NVD, CISA KEV, FIRST EPSS and CISA ICS advisories, and drafts a cited report for an engineer to review. That finds published CVEs in the open-source and third-party components you ship, including vendor advisories for hard-coded credentials in those components. It does not search your own image for passwords, keys or hidden accounts; that takes the extraction, string and login-routine review described above. See device & firmware security.

This guide summarises public MITRE CWE, ETSI, UK legislation, OWASP and CISA guidance; it is not a substitute for a full firmware extraction and review, and does not constitute legal advice.

Put this guide to work

Frequently asked questions

What is a hard-coded credential, exactly?

MITRE's CWE-798 (Use of Hard-coded Credentials) defines it as a product that "contains hard-coded credentials, such as a password or cryptographic key." CWE-259 (Use of Hard-coded Password) is the narrower password-only case. MITRE describes two variations: inbound, where the product's own authentication mechanism checks a login against a fixed value — a default admin account with the same password on every unit — and outbound, where the firmware itself authenticates to another system (a backend API, an update server, a companion device) using a credential embedded in its code or binary, which MITRE notes is "usually very simple" to extract, especially from client-side systems.

Why is this specifically dangerous at device-fleet scale?

MITRE's Common Consequences for CWE-798 are blunt: "it is almost certain that malicious users will gain access to the account in question," and "since all installations of the product will have the same password, even across different organizations, this enables massive attacks such as worms to take place" — a single extracted credential compromises every deployed device at once, which is the exact mechanism behind large IoT botnets built from default-credential devices.

What is MITRE's recommended fix for outbound credentials (firmware calling another system)?

CWE-798's architecture-and-design mitigation for the outbound case: "store passwords, keys, and other credentials outside of the code in a strongly-protected, encrypted configuration file or database that is protected from access by all outsiders," provisioned per-device at manufacturing or first boot rather than baked into every firmware image.

What is the fix for inbound credentials (a device's own login/admin account)?

Rather than shipping a fixed default admin password, MITRE recommends a "first login" mode that forces each unit to be provisioned with a unique, strong password or key before it becomes reachable — the same goal CISA's Secure by Design Pledge sets as one of its seven measurable commitments: "demonstrate measurable progress towards reducing default passwords across the manufacturers' products," with "random, instance-unique initial passwords" among its example approaches. See our [CISA Secure by Design guide](/guides/cisa-secure-by-design-pledge/).

What if we can't fully remove the credential — is there a fallback mitigation?

MITRE lists two partial mitigations: limit which entities can reach the feature that needs the hard-coded credential (for example, restrict it to a local serial console rather than the network), and, where a password must be stored at all, hash it with a strong one-way function and a per-installation random salt rather than keeping it in plaintext — this does not remove the underlying design flaw, but it raises the cost of exploiting it if the storage is later exposed.

Sources

  1. MITRE CWE-798: Use of Hard-coded Credentials
  2. MITRE CWE-259: Use of Hard-coded Password
  3. CISA: Secure by Design Pledge
  4. ETSI EN 303 645 V3.1.3 (2024-09): Cyber Security for Consumer Internet of Things: Baseline Requirements
  5. UK legislation: The Product Security and Telecommunications Infrastructure (Security Requirements for Relevant Connectable Products) Regulations 2023, Schedule 1
  6. OWASP Password Storage Cheat Sheet
  7. OWASP Secrets Management Cheat Sheet
  8. CISA Known Exploited Vulnerabilities catalog, JSON feed (cisagov/kev-data, catalog version 2026.11.10)
Was this guide helpful?

In this cluster