# CVE-2018-1000159: tlslite-ng off-by-one error on mac checking

> An attacker can manipulate TLS ciphertext without detection due to improper integrity check validation in tlslite-ng.

- **Severity:** Medium 5.9 (`CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/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:** 18 Apr 2018
- **Updated:** 5 Aug 2024
- **Also known as:** GHSA-cwh5-3cw7-4286, PYSEC-2018-31, UBUNTU-CVE-2018-1000159

## What is CVE-2018-1000159?

CVE-2018-1000159 is a medium-severity vulnerability in n/a, published on 18 Apr 2018. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

tlslite-ng version 0.7.3 and earlier, since commit d7b288316bca7bcdd082e6ccff5491e241305233 contains a CWE-354: Improper Validation of Integrity Check Value vulnerability in TLS implementation, tlslite/utils/constanttime.py: ct_check_cbc_mac_and_pad(); line "end_pos = data_len - 1 - mac.digest_size" that can result in an attacker manipulating the TLS ciphertext which will not be detected by receiving tlslite-ng. This attack appears to be exploitable via man in the middle on a network connection. This vulnerability appears to have been fixed after commit 3674815d1b0f7484454995e2737a352e0a6a93d8.

Weakness: CWE-354 (Improper Validation of Integrity Check Value)

## Which versions are affected by CVE-2018-1000159?

3 open source packages ship an affected version, including tlslite-ng. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `tlslite-ng` | PyPI | All versions | 0.7.4 |
| `tlslite-ng` | PyPI | All versions | 0.7.4 |
| `tlslite-ng` | PyPI | All versions | 0.7.4 |

Products: Tlslite-Ng Project Tlslite-Ng.

## How do I fix CVE-2018-1000159?

Upgrade tlslite-ng to 0.7.4 or later.

## Is CVE-2018-1000159 being exploited?

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

## Other vulnerabilities in n/a

- [CVE-2020-26263](https://insights.sbomify.com/CVE-2020-26263/): RSA vulnerability in tslite-ng (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2018-1000159 and fix it if it is affected.

What it is: CVE-2018-1000159 is a medium-severity vulnerability in n/a, published on 18 Apr 2018. 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-2018-1000159 in the wild and no public exploit code.

Affected packages and fixed versions:
- tlslite-ng (PyPI): affected all versions; fixed in 0.7.4
- tlslite-ng (PyPI): affected all versions; fixed in 0.7.4
- tlslite-ng (PyPI): affected all versions; fixed in 0.7.4

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-2018-1000159/ (Markdown: https://insights.sbomify.com/CVE-2018-1000159/index.md)
```

## Sources

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

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