CVE-2025-11849
Description
Versions of the package mammoth from 0.3.25 and before 1.11.0; versions of the package mammoth from 0.3.25 and before 1.11.0; versions of the package mammoth before 1.11.0; versions of the package org.zwobble.mammoth:mammoth before 1.11.0 are vulnerable to Directory Traversal due to the lack of path or file type validation when processing a docx file containing an image with an external link (r:link attribute instead of embedded r:embed). The library resolves the URI to a file path and after reading, the content is encoded as base64 and included in the HTML output as a data URI. An attacker can read arbitrary files on the system where the conversion is performed or cause an excessive resources consumption by crafting a docx file that links to special device files such as /dev/random or /dev/zero.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
mammothnpm | >= 0.3.25, < 1.11.0 | 1.11.0 |
org.zwobble.mammoth:mammothMaven | < 1.11.0 | 1.11.0 |
mammothPyPI | >= 0.3.25, < 1.11.0 | 1.11.0 |
MammothNuGet | < 1.11.0 | 1.11.0 |
Affected products
1- Range: 0.1.0, 0.1.1, 0.1.2, …
Patches
2c54aaeb43a79Disable external file access by default
4 files changed · +15 −13
lib/options-reader.js+1 −1 modified@@ -63,7 +63,7 @@ var defaultStyleMap = exports._defaultStyleMap = [ ]; var standardOptions = exports._standardOptions = { - externalFileAccess: true, + externalFileAccess: false, transformDocument: identity, includeDefaultStyleMap: true, includeEmbeddedStyleMap: true
NEWS+2 −1 modified@@ -2,7 +2,8 @@ * Ignore style definitions using a style ID that has already been used. -* Support disabling external file accesses using the externalFileAccess option. +* Disable external file accesses by default. External file access can be enabled + using the externalFileAccess option. * Handle numbering levels defined without an index.
README.md+6 −5 modified@@ -377,9 +377,9 @@ Converts the source document to HTML. set `options.includeDefaultStyleMap` to `false`. * `externalFileAccess`: Source documents may reference files outside of the source document. - To disable access to any such external files during the conversion process, - set `options.externalFileAccess` to `false`. - This is highly recommended when converting untrusted user input. + Access to any such external files is disabled by default. + To enable access when converting trusted source documents, + set `options.externalFileAccess` to `true`. * `convertImage`: by default, images are converted to `<img>` elements with the source included inline in the `src` attribute. Set this option to an [image converter](#image-converters) to override the default behaviour. @@ -541,8 +541,9 @@ For instance: and embed the HTML into your website, this may allow arbitrary files on the server to be read and exfiltrated. - To disable access to any such external files during the conversion process, - set `options.externalFileAccess` to `false`. + To avoid this issue, access to any such external files is disabled by default. + To enable access when converting trusted source documents, + set `options.externalFileAccess` to `true`. ### Document transforms
test/mammoth.tests.js+6 −6 modified@@ -309,27 +309,27 @@ test('src of inline images can be changed using readAsBuffer()', function() { }); }); -test('images stored outside of document are included in output', function() { +test('when external file access is enabled then images stored outside of document are included in output', function() { var docxPath = path.join(__dirname, "test-data/external-picture.docx"); - return mammoth.convertToHtml({path: docxPath}).then(function(result) { + return mammoth.convertToHtml({path: docxPath}, {externalFileAccess: true}).then(function(result) { assert.equal(result.value, '<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII=" /></p>'); assert.deepEqual(result.messages, []); }); }); -test('error if images stored outside of document are specified when passing file without path', function() { +test('when external file access is enabled then error if images stored outside of document are specified when passing file without path', function() { var docxPath = path.join(__dirname, "test-data/external-picture.docx"); var buffer = fs.readFileSync(docxPath); - return mammoth.convertToHtml({buffer: buffer}).then(function(result) { + return mammoth.convertToHtml({buffer: buffer}, {externalFileAccess: true}).then(function(result) { assert.equal(result.value, ''); assert.equal(result.messages[0].message, "could not find external image 'tiny-picture.png', path of input document is unknown"); assert.equal(result.messages[0].type, "error"); }); }); -test('error if images stored outside of document are specified when external file access is disabled', function() { +test('given external file access is disabled by default then error if images stored outside of document are specified', function() { var docxPath = path.join(__dirname, "test-data/external-picture.docx"); - return mammoth.convertToHtml({path: docxPath}, {externalFileAccess: false}).then(function(result) { + return mammoth.convertToHtml({path: docxPath}).then(function(result) { assert.equal(result.value, ''); assert.equal(result.messages[0].message, "could not read external image 'tiny-picture.png', external file access is disabled"); assert.equal(result.messages[0].type, "error");
3261fbb689a2Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
8- github.com/advisories/GHSA-rmjr-87wv-gf87ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2025-11849ghsaADVISORY
- gist.github.com/AudunWA/4d690d9ae5efdafe7cf71d9c2ee90a10nvdWEB
- github.com/mwilliamson/mammoth.js/commit/c54aaeb43a7941317c1f3c119ffa92090f988820nvdWEB
- security.snyk.io/vuln/SNYK-DOTNET-MAMMOTH-13561968nvdWEB
- security.snyk.io/vuln/SNYK-JAVA-ORGZWOBBLEMAMMOTH-13561969nvdWEB
- security.snyk.io/vuln/SNYK-JS-MAMMOTH-13554470nvdWEB
- security.snyk.io/vuln/SNYK-PYTHON-MAMMOTH-13561967nvdWEB
News mentions
0No linked articles in our index yet.