[PR #2823] [MERGED] port-pack: keep pack-index file names and jar entries inside the output #4640

Closed
opened 2026-11-03 05:06:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2823
Author: @sirrayi
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @ludovic111

Base: main ← Head: fix/port-pack-unsafe-names


📝 Commits (2)

  • 690033b port-pack: keep pack-index file names and jar entries inside the output
  • 5ff61e1 Merge remote-tracking branch 'origin/main' into upd/2823

📊 Changes

2 files changed (+59 additions, -1 deletions)

View changed files

📝 crates/horizon-port-pack/src/carry.rs (+38 -1)
📝 crates/horizon-port-pack/src/fetch.rs (+21 -0)

📄 Description

🤖 Opened by sirrayi's AI agent (Devin), not by sirrayi themselves.

What and why

Two places where horizon-port-pack wrote files under names taken from a modpack without checking them:

  1. fetch.rs joined each jar's name onto jars/. The name is PackFile::file_name(): the last /-part of an .mrpack index path, a CurseForge manifest entry, or a modlist jarName. On Windows a name like ..\..\..\evil.dll or C:\x escapes jars/, so a malicious modpack could write files anywhere. Names that aren't one plain part are now refused with a Failed outcome, recorded and logged like any other failure: empty, ., .., or containing /, \, : or NUL.
  2. carry.rs skipped jar entries with .. or empty /-parts, but not backslashes or drive colons. On Windows, data/mymod/..\..\..\evil.json escaped carry/ and outside/. Entries containing \ or : are now skipped too.

Possible follow-up, not changed here: carry.rs also builds output paths from identifiers read from a jar's JSON (structure and pool paths, model names, tag names), e.g. around inside.join(to) and data/{ns}/worldgen/structure/{path}.json. Checking those against ResourceLocation.isValidPath would close the same class of escape.

Vanilla reference

none (Horizon's modpack porting tool).

Self-check

  • cargo fmt --all -- --check ✅
  • cargo clippy -p horizon-port-pack --lib --tests -- -D warnings ✅
  • cargo test -p horizon-port-pack --lib (70) ✅
  • New tests: fetch::tests::a_pack_index_name_must_stay_inside_jars, and carry::tests::entry_names_cannot_escape_the_output, a jar with a ..\..\..\evil.json entry.

Generated with Devin


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2823 **Author:** [@sirrayi](https://github.com/sirrayi) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/port-pack-unsafe-names` --- ### 📝 Commits (2) - [`690033b`](https://github.com/horizon-rust/horizon/commit/690033b71b65a704eb95a34bfa8479b6c0ba952b) port-pack: keep pack-index file names and jar entries inside the output - [`5ff61e1`](https://github.com/horizon-rust/horizon/commit/5ff61e1c429b5df4f0f6328b8f2ea70cd85761e7) Merge remote-tracking branch 'origin/main' into upd/2823 ### 📊 Changes **2 files changed** (+59 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-port-pack/src/carry.rs` (+38 -1) 📝 `crates/horizon-port-pack/src/fetch.rs` (+21 -0) </details> ### 📄 Description > 🤖 Opened by sirrayi's AI agent (Devin), not by sirrayi themselves. ## What and why Two places where horizon-port-pack wrote files under names taken from a modpack without checking them: 1. **`fetch.rs`** joined each jar's name onto `jars/`. The name is `PackFile::file_name()`: the last `/`-part of an `.mrpack` index path, a CurseForge manifest entry, or a modlist `jarName`. On Windows a name like `..\..\..\evil.dll` or `C:\x` escapes `jars/`, so a malicious modpack could write files anywhere. Names that aren't one plain part are now refused with a `Failed` outcome, recorded and logged like any other failure: empty, `.`, `..`, or containing `/`, `\`, `:` or NUL. 2. **`carry.rs`** skipped jar entries with `..` or empty `/`-parts, but not backslashes or drive colons. On Windows, `data/mymod/..\..\..\evil.json` escaped `carry/` and `outside/`. Entries containing `\` or `:` are now skipped too. Possible follow-up, not changed here: `carry.rs` also builds output paths from identifiers read from a jar's JSON (structure and pool paths, model names, tag names), e.g. around `inside.join(to)` and `data/{ns}/worldgen/structure/{path}.json`. Checking those against `ResourceLocation.isValidPath` would close the same class of escape. ## Vanilla reference none (Horizon's modpack porting tool). ## Self-check - `cargo fmt --all -- --check` ✅ - `cargo clippy -p horizon-port-pack --lib --tests -- -D warnings` ✅ - `cargo test -p horizon-port-pack --lib` (70) ✅ - New tests: `fetch::tests::a_pack_index_name_must_stay_inside_jars`, and `carry::tests::entry_names_cannot_escape_the_output`, a jar with a `..\..\..\evil.json` entry. Generated with [Devin](https://devin.ai) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:06:52 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4640
No description provided.