# CVE-2023-26154: pubnub Insufficient Entropy vulnerability

> Insufficient entropy in PubNub SDK encryption allows attackers to brute-force keys and decrypt messages.

- **Severity:** Medium 5.9 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 6 Dec 2023
- **Updated:** 2 Aug 2024
- **Also known as:** GHSA-5844-q3fc-56rh, GO-2023-2385, PYSEC-2026-1807

## What is CVE-2023-26154?

CVE-2023-26154 is a medium-severity vulnerability in PubNub, published on 6 Dec 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Versions of the package pubnub before 7.4.0; all versions of the package com.pubnub:pubnub; versions of the package pubnub before 6.19.0; all versions of the package github.com/pubnub/go; versions of the package github.com/pubnub/go/v7 before 7.2.0; versions of the package pubnub before 7.3.0; versions of the package pubnub/pubnub before 6.1.0; versions of the package pubnub before 5.3.0; versions of the package pubnub before 0.4.0; versions of the package pubnub/c-core before 4.5.0; versions of the package com.pubnub:pubnub-kotlin before 7.7.0; versions of the package pubnub/swift before 6.2.0; versions of the package pubnub before 5.2.0; versions of the package pubnub before 4.3.0 are vulnerable to Insufficient Entropy via the getKey function, due to inefficient implementation of the AES-256-CBC cryptographic algorithm. The provided encrypt function is less secure when hex encoding and trimming are applied, leaving half of the bits in the key always the same for every encoded message or file.**Note:**In order to exploit this vulnerability, the attacker needs to invest resources in preparing the attack and brute-force the encryption.

Weakness: CWE-331 (Insufficient Entropy)

## Which versions are affected by CVE-2023-26154?

33 open source packages ship an affected version, including pubnub, github.com/pubnub/go and github.com/pubnub/go/v5. It affects 4 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `pubnub` | Pub | All versions | 4.3.0 |
| `pubnub` | Pub | All versions | 4.3.0 |
| `pubnub` | PyPI | All versions | 7.3.0 |
| `pubnub` | PyPI | All versions | 7.3.0 |
| `pubnub` | PyPI | All versions | 7.3.0 |
| `pubnub` | RubyGems | All versions | 5.3.0 |
| `pubnub` | RubyGems | All versions | 5.3.0 |
| `pubnub` | crates.io | All versions | 0.4.0 |
| `pubnub` | crates.io | All versions | 0.4.0 |
| `pubnub` | npm | All versions | 7.4.0 |
| `pubnub` | npm | All versions | 7.4.0 |
| `github.com/pubnub/go` | Go | All versions | None |
| `github.com/pubnub/go` | Go | All versions | 0.0.0-20231016150651-428517fef5b9 |
| `github.com/pubnub/go` | Go | All versions | 0.0.0-20231016150651-428517fef5b9 |
| `github.com/pubnub/go/v5` | Go | All versions | None |
| `github.com/pubnub/go/v5` | Go | All versions | 5.0.4-0.20231016150651-428517fef5b9 |
| `github.com/pubnub/go/v5` | Go | All versions | 5.0.4-0.20231016150651-428517fef5b9 |
| `github.com/pubnub/go/v6` | Go | All versions | None |
| `github.com/pubnub/go/v6` | Go | All versions | 6.1.1-0.20231016150651-428517fef5b9 |
| `github.com/pubnub/go/v6` | Go | All versions | 6.1.1-0.20231016150651-428517fef5b9 |
| `github.com/pubnub/go/v7` | Go | All versions | 7.2.0 |
| `github.com/pubnub/go/v7` | Go | All versions | 7.2.0 |
| `github.com/pubnub/go/v7` | Go | All versions | 7.2.0 |
| `com.pubnub:pubnub` | Maven | All versions to 4.6.5 | None |
| `com.pubnub:pubnub` | Maven | All versions to 4.6.5 | None |
| `com.pubnub:pubnub-kotlin` | Maven | All versions | 7.7.0 |
| `com.pubnub:pubnub-kotlin` | Maven | All versions | 7.7.0 |
| `Pubnub` | NuGet | All versions | 6.19.0 |
| `Pubnub` | NuGet | All versions | 6.19.0 |
| `pubnub/pubnub` | Packagist | All versions | 6.1.0 |
| `pubnub/pubnub` | Packagist | All versions | 6.1.0 |
| `github.com/pubnub/swift` | SwiftURL | All versions | 6.2.0 |
| `github.com/pubnub/swift` | SwiftURL | All versions | 6.2.0 |

Products: Pubnub C-Core, Pubnub Kotlin, Pubnub Pubnub, Pubnub Swift.

## How do I fix CVE-2023-26154?

Upgrade pubnub to a fixed version for your release line: 4.3.0, 7.3.0, 5.3.0 or 0.4.0.

## Is CVE-2023-26154 being exploited?

There is no known exploitation of CVE-2023-26154 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-26154 and fix it if it is affected.

What it is: CVE-2023-26154 is a medium-severity vulnerability in PubNub, published on 6 Dec 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2023-26154 in the wild and no public exploit code.

Affected packages and fixed versions:
- pubnub (Pub): affected all versions; fixed in 4.3.0
- pubnub (Pub): affected all versions; fixed in 4.3.0
- pubnub (PyPI): affected all versions; fixed in 7.3.0
- pubnub (PyPI): affected all versions; fixed in 7.3.0
- pubnub (PyPI): affected all versions; fixed in 7.3.0
- pubnub (RubyGems): affected all versions; fixed in 5.3.0
- pubnub (RubyGems): affected all versions; fixed in 5.3.0
- pubnub (crates.io): affected all versions; fixed in 0.4.0
- pubnub (crates.io): affected all versions; fixed in 0.4.0
- pubnub (npm): affected all versions; fixed in 7.4.0
- pubnub (npm): affected all versions; fixed in 7.4.0
- github.com/pubnub/go (Go): affected all versions; no fix listed

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-26154/ (Markdown: https://insights.sbomify.com/CVE-2023-26154/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-26154
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-26154
- OSV: https://osv.dev/vulnerability/CVE-2023-26154

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-26154/
Summaries are generated and may contain mistakes; the official description above is the record.
