nodejs / nodejs/node

Package map subpath resolves outside the target package directory

オープン
#65,501 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、app/index.js と node --experimental-package-map を使って package-map.json の再現手順を実行します。../../secret.js を含む場合に dep サブパスがどのように解決されるかを追跡し、解決によって dep 外のパスが ERR_INVALID_MODULE_SPECIFIER で拒否されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
backend, security
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
70/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。