nodejs / nodejs/node

Package map subpath resolves outside the target package directory

未关闭
#65,501 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
JavaScript
星标
122k
派生
37.3k
平均合并
4 天 2 小时
30 天内合并 PR
283

描述

Version

v26.5.0

Platform

Subsystem

module

What steps will reproduce the bug?
  // package-map.json
  {
    "packages": {
      "app": { "url": "./app", "dependencies": { "dep": "dep" } },
      "dep": { "url": "./dep", "dependencies": {} }
    }
  }
  // app/index.js
  require('dep/../../secret.js');

node --experimental-package-map ./package-map.json app/index.js

How often does it reproduce? Is there a required condition?

always

What is the expected behavior? Why is that the expected behavior?

Resolution should fail with ERR_INVALID_MODULE_SPECIFIER, because the subpath escapes the target package's own directory (dep) as declared in the package map.

What do you see instead?

The specifier resolves successfully to a file outside the target package directory.

Additional information

No response

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用 app/index.js 和 node --experimental-package-map 运行 package-map.json 重现。跟踪包含 ../../secret.js 时 dep 子路径的解析方式,并验证解析会使用 ERR_INVALID_MODULE_SPECIFIER 拒绝 dep 之外的任何路径。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, node.js
领域
backend, security
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
活跃
描述清晰度
描述清楚
新手友好度
70/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。