Create: Re-Packager 修复
一款针对 Create 的服务端修复模组,用于修补 Re-Packager(重新打包器)中的物品复制漏洞。当碎片化包裹所携带的库存不足以完成其订单的制作配方时,Re-Packager 仍会生成一个数量为 0 的包裹条目——随后打包机的输出逻辑会将其作为包含完整配方材料副本的真实物理包裹弹出,从而使攻击者能够无限复制配方材料。本模组通过 Mixin 修补了 PackageRepackageHelper.repackBasedOnRecipes 方法,从根源上消除该复制漏洞,且不影响正常的打包行为。
漏洞详情
受影响版本: Create 6.0.8 (1.20.1)、6.0.10 (1.21.1) 以及 Create Fly 移植版 (1.21.11 / 26.2)。
- 在 Factory Gauge(工厂仪表) 上配置的制作排列不受库存验证限制——配方材料无需与请求物品匹配(Create 仅在 Redstone Requester(红石请求器)路径中检查此一致性;Factory Gauge 路径完全缺失此项检查)。
- 当库存不足时,
repackBasedOnRecipes 仍会生成一个 packagesToCreate == 0 的包裹条目。
- (核心问题) 打包机的输出逻辑
PackagerBlockEntity.tick() 在检查数量之前就将包裹复制出来(heldBox = entry.stack.copy() 位于 count-- 之前),因此数量为 0 的包裹会被作为真实包裹发出——空库存凭空产出了包含全套配方材料的包裹,可通过 Factory Gauge 的循环补货请求无限利用。
相关上游问题(均仍未解决): #8082、#8046、#8155。上游提交 3e662789 仅修复了超大配方材料变体(copyWithCount(1));核心缺陷仍未修复。
修复方案
对 PackageRepackageHelper.repackBasedOnRecipes 应用 Mixin 补丁,采用两阶段验证机制:
- 先检查 —— 验证所有配方材料是否可用(NBT 精确匹配);若缺少任何材料,则中止整轮操作且不消耗任何东西。
- 后消耗 —— 仅在确认所有材料均可用后,统一扣除库存;无部分消耗,因此玩家永远不会损失已投入的材料。
- 零数量守卫 —— 当
packagesToCreate == 0(库存甚至无法支持单次制作)时,不生成任何包裹。
所有正常行为(库存充足、多配方订单等)均与原版的 Vanilla 完全一致。
特性
- 仅限服务端——客户端无需安装即可加入服务器
- 不影响正常的打包 / 重新打包操作
- 当材料部分不足时,材料会通过常规重新打包返回,而非被吞没
- 可与其他修复模组共存
验证方法
向 Re-Packager 输入异常包裹(空库存 + 声称需要 64 次制作的制作订单):
- 未安装本模组: 输出 1 个包含全套配方材料的包裹(发生复制)
- 安装本模组: 输出 0 个包裹(已修复)
测试用包裹命令已在仓库中的 TEST_PACKAGES.md 文件中记录。
Create: Re-Packager Fix
A server-side fix mod for Create that patches a duplication exploit in the Re-Packager. When a fragmented package carries insufficient inventory to fulfill the crafting recipes of its order, the Re-Packager still generates a package entry with a quantity of 0 — which the packager's output logic then ejects as a real physical package containing a full copy of the recipe materials, allowing attackers to duplicate recipe materials infinitely. This mod patches PackageRepackageHelper.repackBasedOnRecipes via Mixin, eliminating the duplication at its root without affecting normal packaging behavior.
The Vulnerability
Affected versions: Create 6.0.8 (1.20.1), 6.0.10 (1.21.1), and the Create Fly ports (1.21.11 / 26.2).
- Crafting arrangements configured on the Factory Gauge are not bound by inventory validation — recipe materials are not required to match the requested items (Create only checks this consistency in the Redstone Requester path; the Factory Gauge path misses this check entirely).
- When inventory is insufficient,
repackBasedOnRecipes still generates a package entry with packagesToCreate == 0.
- (The core issue) The packager's output logic
PackagerBlockEntity.tick() copies the package out before checking its count (heldBox = entry.stack.copy() precedes count--), so a count-0 package is emitted as a real one — an empty inventory produces a package containing a full set of recipe materials out of thin air, infinitely exploitable via the Factory Gauge's recurring restock requests.
Related upstream issues (all still open): #8082, #8046, #8155. Upstream commit 3e662789 only fixed the oversized recipe-material variant (copyWithCount(1)); the core defect remains unfixed.
The Fix
Mixin patch on PackageRepackageHelper.repackBasedOnRecipes using a two-phase validation:
- Check first — verify all recipe materials are available (NBT-exact match); if any is missing, abort the whole round without consuming anything.
- Consume second — only after everything is confirmed available, deduct the inventory uniformly; no partial consumption, so players never lose invested materials.
- Zero-count guard — when
packagesToCreate == 0 (inventory cannot support even a single craft), no package is generated.
All normal behavior (sufficient stock, multi-recipe orders, etc.) remains fully identical to vanilla.
Features
- Server-side only — clients can join without installing it
- Does not affect normal packaging / re-packaging
- Materials are returned (via regular repackaging) instead of being swallowed when partially insufficient
- Coexists with other fix mods
Verification
Feed the Re-Packager an anomalous package (empty inventory + a crafting order claiming 64 crafts):
- Without this mod: 1 package containing a full set of recipe materials is output (duplication)
- With this mod: 0 packages are output (fixed)
Test package commands are documented in TEST_PACKAGES.md in the repository.
评论 0
登录后参与评分
还没有评论,来抢沙发吧