CWE-259: Use of Hard-coded Password

Variant Draft Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

The product contains a hard-coded password, which it uses for its own inbound authentication or for outbound communication to external components.

常见后果

影响范围: Access Control

技术影响: Gain Privileges or Assume Identity

说明: If hard-coded passwords are used, it is almost certain that malicious users can gain access through the account in question.

影响范围: Access Control

技术影响: Gain Privileges or Assume Identity Hide Activities Reduce Maintainability

说明: A hard-coded password typically leads to a significant authentication failure that can be difficult for the system administrator to detect. Once detected, it can be difficult to fix, so the administrator may be forced into disabling the product entirely.

潜在缓解措施

阶段: Architecture and Design

描述: For outbound authentication: store passwords outside of the code in a strongly-protected, encrypted configuration file or database that is protected from access by all outsiders, including other local users on the same system. Properly protect the key (CWE-320). If you cannot use encryption to protect the file, then make sure that the permissions are as restrictive as possible.

阶段: Architecture and Design

描述: For inbound authentication: Rather than hard-code a default username and password for first time logins, utilize a "first login" mode that requires the user to enter a unique strong password.

阶段: Architecture and Design

描述: Perform access control checks and limit which entities can access the feature that requires the hard-coded password. For example, a feature might only be enabled through the system console instead of through a network connection.

阶段: Architecture and Design

阶段: Architecture and Design

检测方法

方法: Manual Analysis

This weakness can be detected using tools and techniques that require manual (human) analysis, such as penetration testing, threat modeling, and interactive tools that allow the tester to record and modify an active session.

方法: Black Box

方法: Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

有效性: High

观察示例

参考: CVE-2022-29964

Distributed Control System (DCS) has hard-coded passwords for local shell access

参考: CVE-2021-37555

Telnet service for IoT feeder for dogs and cats has hard-coded password [REF-1288]

参考: CVE-2021-35033

Firmware for a WiFi router uses a hard-coded password for a BusyBox shell, allowing bypass of authentication through the UART port

引入模式

阶段 说明
Implementation REALIZATION: This weakness is caused during implementation of an architectural security tactic.
Architecture and Design -

适用平台

编程语言
Not Language-Specific (Undetermined)
技术
ICS/OT (Undetermined)

分类映射

分类名称 条目ID 条目名称 映射适配度
7 Pernicious Kingdoms - Password Management: Hard-Coded Password -
CLASP - Use of hard-coded password -
OWASP Top Ten 2004 A3 Broken Authentication and Session Management CWE More Specific
The CERT Oracle Secure Coding Standard for Java (2011) MSC03-J Never hard code sensitive information -
Software Fault Patterns SFP33 Hardcoded sensitive data -
关键信息

CWE ID: CWE-259

抽象级别: Variant

结构: Simple

状态: Draft

利用可能性: High

相关弱点