---
title: "CWE-547: Use of Hard-coded, Security-relevant Constants"
url: https://radicalnotion.ai/cwe/cwe-547
type: cwe
description: "The product uses hard-coded constants instead of symbolic names for security-critical values, which increases the likelihood of mistakes during code maintenance or security policy change."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-547: Use of Hard-coded, Security-relevant Constants

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 10
- **Of those, in CISA KEV:** 0
- **New in 2026:** 1
- **CWE catalog version:** 4.21

## Description

The product uses hard-coded constants instead of symbolic names for security-critical values, which increases the likelihood of mistakes during code maintenance or security policy change.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | If the developer does not find all occurrences of the hard-coded constants, an incorrect policy decision may be made if one of the constants is not changed. Making changes to these values will require code changes that may be difficult or impossible once the system is released to the field. |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other | Varies by Context, Quality Degradation, Reduce Maintainability | The existence of hardcoded constants could cause unexpected behavior and the introduction of weaknesses during code maintenance or when making changes to the code if all occurrences are not modified. The use of hardcoded constants is an indication of poor quality. In addition, these hard-coded values may become available to attackers if the code is ever disclosed. |

## Potential mitigations

### Implementation

Avoid using hard-coded constants. Configuration files offer a more flexible solution.

## Detection methods

### 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.)

Effectiveness: High

## Demonstrative examples

### Example 1

The usage of symbolic names instead of hard-coded constants is preferred.

Bad code:

```c
char buffer[1024];
...
fgets(buffer, 1024, stdin);
```

Good code:

```c
enum { MAX_BUFFER_SIZE = 1024 };
...
char buffer[MAX_BUFFER_SIZE];
...
fgets(buffer, MAX_BUFFER_SIZE, stdin);
```

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2023-1712 | Use of Hard-coded, Security-relevant Constants in deepset-ai/haystack | critical | 9.8 | - | No | 2023-03-30 |
| CVE-2025-49151 | Use of Hard-coded, Security-relevant Constants in MICROSENS NMP Web+ | critical | 9.3 | - | No | 2025-06-25 |
| CVE-2019-14837 | keycloak vulnerable to unauthorized login via mail server setup | critical | 9.1 | - | No | 2020-01-07 |
| CVE-2025-2081 | Use of Hard-Coded, Security-Relevant Constants | high | 8.7 | - | No | 2025-03-13 |
| CVE-2025-2079 | Use of Hard-Coded, Security-Relevant Constants in Optigo Networks Visual BACnet Capture Tool / Optigo Visual Networks Capture Tool | high | 8.7 | - | No | 2025-03-13 |
| CVE-2024-39888 | Hard-coded Default Encryption Key in Mendix Encryption Module V10.0.0 and V10.0.1 | high | 8.7 | - | No | 2024-07-09 |
| CVE-2024-32021 | Local Git clone may hardlink arbitrary user-readable files into the new repository's "objects/" directory | high | 7.1 | - | No | 2024-05-14 |
| CVE-2026-28256 | Use of Hard-coded Credentials vulnerability in Trane Tracer SC, Tracer SC+, and Tracer Concierge | medium | 6.9 | - | No | 2026-03-12 |
| CVE-2024-41885 | Hardcoding sensitive information | medium | 5.6 | - | No | 2024-12-24 |
| CVE-2025-23253 | - | low | 2.5 | - | No | 2025-04-22 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-1078](https://radicalnotion.ai/cwe/cwe-1078) | Inappropriate Source Code Style or Formatting |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CERT C Secure Coding | Use meaningful symbolic constants to represent literal values in program logic | DCL06-C | - |

## Frequently asked questions

### What is CWE-547?

The product uses hard-coded constants instead of symbolic names for security-critical values, which increases the likelihood of mistakes during code maintenance or security policy change.

### What CVEs are caused by CWE-547?

10 recorded CVEs are attributed to CWE-547, including CVE-2023-1712, CVE-2025-49151 and CVE-2019-14837.

### How do you prevent CWE-547?

Avoid using hard-coded constants. Configuration files offer a more flexible solution.

### How is CWE-547 detected?

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.)

### What are the consequences of CWE-547?

Exploiting CWE-547 can lead to: Varies by Context, Quality Degradation, Reduce Maintainability.

### Is CWE-547 actively exploited?

10 recorded CVEs are caused by CWE-547; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/547.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-547). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
