---
title: "CWE-543: Use of Singleton Pattern Without Synchronization in a Multithreaded Context"
url: https://radicalnotion.ai/cwe/cwe-543
type: cwe
description: "The product uses the singleton pattern when creating a resource within a multithreaded environment."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-543: Use of Singleton Pattern Without Synchronization in a Multithreaded Context

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

## Description

The product uses the singleton pattern when creating a resource within a multithreaded environment.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Languages:** Java (Undetermined), C++ (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other, Integrity | Varies by Context, Modify Application Data | The use of a singleton pattern may not be thread-safe. |

## Potential mitigations

### Architecture and Design

Use the Thread-Specific Storage Pattern. See References.

### Implementation

Do not use member fields to store information in the Servlet. In multithreading environments, storing user data in Servlet member fields introduces a data access race condition.

### Implementation

Avoid using the double-checked locking pattern in language versions that cannot guarantee thread safety. This pattern may be used to avoid the overhead of a synchronized call, but in certain versions of Java (for example), this has been shown to be unsafe because it still introduces a race condition (CWE-209).

Effectiveness: Limited

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

## Demonstrative examples

### Example 1

This method is part of a singleton pattern, yet the following singleton() pattern is not thread-safe. It is possible that the method will create two objects instead of only one.

Bad code:

```java
private static NumberConverter singleton;
public static NumberConverter get_singleton() {
    if (singleton == null) {
        singleton = new NumberConverter();
    }
    return singleton;
}
```

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-662](https://radicalnotion.ai/cwe/cwe-662) | Improper Synchronization |
| Parent | [CWE-820](https://radicalnotion.ai/cwe/cwe-820) | Missing Synchronization |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| The CERT Oracle Secure Coding Standard for Java (2011) | Prevent multiple instantiations of singleton objects | MSC07-J | - |
| Software Fault Patterns | Missing Lock | SFP19 | - |

## Frequently asked questions

### What is CWE-543?

The product uses the singleton pattern when creating a resource within a multithreaded environment.

### How do you prevent CWE-543?

Use the Thread-Specific Storage Pattern. See References.

### How is CWE-543 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-543?

Exploiting CWE-543 can lead to: Varies by Context, Modify Application Data.

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

---

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