# CVE-2016-4658: Nokogiri does not forbid namespace nodes in XPointer ranges

> Remote attackers can execute arbitrary code or cause denial of service via crafted XML due to a use-after-free in libxml2.

- **Severity:** Critical 9.8 (`CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 25 Sep 2016
- **Updated:** 14 Oct 2026
- **Also known as:** CLSA-2023-1699381307, CLSA-2023-1699393971, DEBIAN-CVE-2016-4658, ECHO-f7fb-e3bf-0154, GHSA-fr52-4hqw-p27f, RHSA-2021:3810, SUSE-SU-2016:2650-1, SUSE-SU-2016:2652-1, UBUNTU-CVE-2016-4658

## What is CVE-2016-4658?

CVE-2016-4658 is a critical use after free vulnerability in Apple Iphone Os, published on 25 Sep 2016. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

xpointer.c in libxml2 before 2.9.5 (as used in Apple iOS before 10, OS X before 10.12, tvOS before 10, and watchOS before 3, and other products) does not forbid namespace nodes in XPointer ranges, which allows remote attackers to execute arbitrary code or cause a denial of service (use-after-free and memory corruption) via a crafted XML document.

Weakness: CWE-119 (Improper Restriction of Operations within the Bounds of a Memory Buffer)

## Which versions are affected by CVE-2016-4658?

2 open source packages ship an affected version, including nokogiri. It affects 5 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `nokogiri` | RubyGems | All versions | 1.7.1 |
| `nokogiri` | RubyGems | All versions | 1.7.1 |
| `libxml2` | Red Hat:enterprise_linux:7::client | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-debuginfo` | Red Hat:enterprise_linux:7::client | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-devel` | Red Hat:enterprise_linux:7::client | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-python` | Red Hat:enterprise_linux:7::client | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-static` | Red Hat:enterprise_linux:7::client | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-debuginfo` | Red Hat:enterprise_linux:7::computenode | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-devel` | Red Hat:enterprise_linux:7::computenode | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-static` | Red Hat:enterprise_linux:7::computenode | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2` | Red Hat:enterprise_linux:7::server | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-debuginfo` | Red Hat:enterprise_linux:7::server | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-devel` | Red Hat:enterprise_linux:7::server | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-python` | Red Hat:enterprise_linux:7::server | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-static` | Red Hat:enterprise_linux:7::server | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2` | Red Hat:enterprise_linux:7::workstation | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-debuginfo` | Red Hat:enterprise_linux:7::workstation | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-devel` | Red Hat:enterprise_linux:7::workstation | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-python` | Red Hat:enterprise_linux:7::workstation | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2-static` | Red Hat:enterprise_linux:7::workstation | All versions | 0:2.9.1-6.el7_9.6 |
| `libxml2` | SUSE:Linux Enterprise Desktop 12 SP1 | All versions | 2.9.1-26.3.1 |
| `python-libxml2` | SUSE:Linux Enterprise Desktop 12 SP1 | All versions | 2.9.1-26.3.1 |
| `libxml2` | SUSE:Linux Enterprise Server 11 SP4 | All versions | 2.7.6-0.50.1 |
| `libxml2-python` | SUSE:Linux Enterprise Server 11 SP4 | All versions | 2.7.6-0.50.4 |
| `libxml2` | SUSE:Linux Enterprise Server 12 SP1 | All versions | 2.9.1-26.3.1 |
| `python-libxml2` | SUSE:Linux Enterprise Server 12 SP1 | All versions | 2.9.1-26.3.1 |
| `libxml2` | SUSE:Linux Enterprise Server for SAP Applications 11 SP4 | All versions | 2.7.6-0.50.1 |
| `libxml2-python` | SUSE:Linux Enterprise Server for SAP Applications 11 SP4 | All versions | 2.7.6-0.50.4 |
| `libxml2` | SUSE:Linux Enterprise Server for SAP Applications 12 SP1 | All versions | 2.9.1-26.3.1 |
| `python-libxml2` | SUSE:Linux Enterprise Server for SAP Applications 12 SP1 | All versions | 2.9.1-26.3.1 |
| `libxml2` | SUSE:Linux Enterprise Software Development Kit 11 SP4 | All versions | 2.7.6-0.50.1 |
| `libxml2` | SUSE:Linux Enterprise Software Development Kit 12 SP1 | All versions | 2.9.1-26.3.1 |

Products: Apple Iphone Os, Apple Mac Os X, Apple Tvos, Apple Watchos, Xmlsoft Libxml2.

## How do I fix CVE-2016-4658?

Upgrade nokogiri to 1.7.1 or later.

## Is CVE-2016-4658 being exploited?

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

## Other vulnerabilities in Apple Iphone Os

- [CVE-2021-30666](https://insights.sbomify.com/CVE-2021-30666/): Apple iOS WebKit Buffer Overflow (high 8.8, exploited in the wild)
- [CVE-2021-30761](https://insights.sbomify.com/CVE-2021-30761/): Apple iOS WebKit Memory Corruption (high 8.8, exploited in the wild)
- [CVE-2021-30762](https://insights.sbomify.com/CVE-2021-30762/): Apple iOS WebKit Use-After-Free (high 8.8, exploited in the wild)
- [CVE-2016-4657](https://insights.sbomify.com/CVE-2016-4657/): Apple iOS Webkit Memory Corruption (high 8.8, exploited in the wild)
- [CVE-2019-7286](https://insights.sbomify.com/CVE-2019-7286/): Apple Multiple Products Memory Corruption (high 7.8, exploited in the wild)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2016-4658 and fix it if it is affected.

What it is: CVE-2016-4658 is a critical use after free vulnerability in Apple Iphone Os, published on 25 Sep 2016. 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-2016-4658 in the wild and no public exploit code.

Affected packages and fixed versions:
- nokogiri (RubyGems): affected all versions; fixed in 1.7.1
- nokogiri (RubyGems): affected all versions; fixed in 1.7.1

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

## Sources

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

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