Skip to content

Pin transitive esbuild to 0.28.1 via pnpm override#158

Merged
jcstein merged 3 commits into
mainfrom
copilot/fix-dependabot-vulnerability-alert
Jun 17, 2026
Merged

Pin transitive esbuild to 0.28.1 via pnpm override#158
jcstein merged 3 commits into
mainfrom
copilot/fix-dependabot-vulnerability-alert

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Dependabot flagged esbuild@0.28.0 (GHSA-gv7w-rqvm-qjhr) via pnpm-lock.yaml; the minimum non-vulnerable target is 0.28.1. This change updates resolution to the patched version without upgrading higher-level toolchain packages.

  • Dependency remediation

    • Added a workspace override to force esbuild resolution to the patched release.
    • Kept the change scoped to dependency resolution (no app/runtime code changes).
  • Lockfile resolution update

    • Regenerated pnpm-lock.yaml so vite/vocs/waku paths that previously referenced esbuild@0.28.0 now resolve to esbuild@0.28.1.
    • Vulnerable esbuild@0.28.0 resolution is replaced by override mapping.
  • Reachability assessment

    • Advisory details describe a Deno-specific esbuild download/execution path (NPM_CONFIG_REGISTRY, Deno module installer).
    • Repository search found no usage of NPM_CONFIG_REGISTRY or ESBUILD_BINARY_PATH in project code.
    • Exposure in this repo is through transitive build tooling (vocs/viteesbuild), not a direct Deno runtime integration.
    • Conclusion: direct vulnerable code path is not clearly reachable from repository code paths; update is primarily to satisfy scanner requirements and reduce supply-chain risk.
      Confidence: High.
# pnpm-workspace.yaml
overrides:
  esbuild: 0.28.1
Original prompt

This section details the Dependabot vulnerability alert you should resolve

<alert_title>Withdrawn Advisory: esbuild: Missing binary integrity verification in Deno module enables remote code execution via NPM_CONFIG_REGISTRY</alert_title>
<alert_description>## Withdrawn Advisory

This advisory has been withdrawn because the affected package was incorrectly identified and the actual affected package is not in a supported ecosystem. This link is maintained to preserve external references.

Original Description

Summary

The esbuild Deno module (lib/deno/mod.ts) downloads native binary executables from an npm registry and writes them to disk with executable permissions (0o755) without performing any integrity verification (e.g., SHA-256 hash check). The Node.js equivalent (lib/npm/node-install.ts) includes a robust binaryIntegrityCheck() function that verifies SHA-256 hashes against hardcoded expected values from package.json, but this protection was never implemented for the Deno distribution.

When the NPM_CONFIG_REGISTRY environment variable is set, the Deno module constructs a download URL using this attacker-influenced value and fetches a native binary from it. Because no integrity check is performed, an attacker who can control this environment variable (common in CI/CD pipelines, shared development environments, or corporate networks with custom npm registries) can supply a malicious binary that will be downloaded, written to disk, and executed with the privileges of the Deno process, achieving full remote code execution.

Details

Vulnerable code pathlib/deno/mod.ts lines 62–82:

async function installFromNPM(name: string, subpath: string): Promise<string> {
  const { finalPath, finalDir } = getCachePath(name)
  try { await Deno.stat(finalPath); return finalPath } catch (e) {}

  const npmRegistry = Deno.env.get("NPM_CONFIG_REGISTRY") || "https://registry.npmjs.org"  // line 70: attacker-controlled
  const url = `${npmRegistry}/${name}/-/${name.replace("@esbuild/", "")}-${version}.tgz`     // line 71: URL uses attacker base
  const buffer = await fetch(url).then(r => r.arrayBuffer())                                  // line 72: download
  const executable = extractFileFromTarGzip(new Uint8Array(buffer), subpath)                   // line 73: extract

  await Deno.mkdir(finalDir, { recursive: true, mode: 0o700 })
  await Deno.writeFile(finalPath, executable, { mode: 0o755 })                                 // line 80: write + chmod
  return finalPath                                                                              // line 81: no hash check
}

Missing protection — The Node.js equivalent at lib/npm/node-install.ts lines 228–234:

function binaryIntegrityCheck(pkg: string, subpath: string, bytes: Uint8Array): void {
  const hash = crypto.createHash('sha256').update(bytes).digest('hex')
  const key = `${pkg}/${subpath}`
  const expected = packageJSON['esbuild.binaryHashes'][key]
  if (!expected) throw new Error(`Missing hash for "${key}"`)
  if (hash !== expected) throw new Error(...)
}

This function is called in both the installUsingNPM() path (line 131) and the downloadDirectlyFromNPM() path (line 243), but no equivalent exists in the Deno module. Searching the entire git history confirms binaryIntegrityCheck, binaryHashes, sha256, and hash have never appeared in lib/deno/mod.ts.

Execution flow after download: The binary returned by installFromNPM() is passed to spawn() at line 291 of the same file:

const child = spawn(binPath, { args: [`--service=${version}`], ... })

Attack vector: The NPM_CONFIG_REGISTRY environment variable is a standard npm configuration variable widely used in enterprise CI/CD pipelines to point to internal artifact repositories (Artifactory, Nexus, Verdaccio, etc.). An attacker who can inject or modify this variable in a build environment (e.g., via CI config injection, shared environment, or compromised registry) can redirect the download to a server they control and serve a trojaned native binary.

PoC

Prerequisites: Deno runtime, Node.js (for fake registry)

Step 1: Create a fake npm registry that serves a malicious binary:

// fake-registry.js
const http = require('http');
const zlib = require('zlib');
http.createServer((req, res) => {
  const fakeBin = '#!/bin/sh\necho PWNED > /tmp/deno-esbuild-rce-proof.txt\necho fake-esbuild-0.28.0\n';
  // ... build tar.gz with fake binary as package/bin/esbuild ...
  res.writeHead(200, {'Content-Length': gz.length});
  res.end(gz);
}).listen(19876, () => console.log('READY'));

Step 2: Run the PoC with NPM_CONFIG_REGISTRY pointing to the fake server:

// poc.ts — mimics lib/deno/mod.ts installFromNPM code path
const npmRegistry = Deno.env.get("NPM_CONFIG_REGISTRY") || "https://registry.npmjs.org"...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Resolves celestiaorg/eden-docs alert #154

Copilot AI changed the title [WIP] Fix Dependabot vulnerability alert for esbuild Pin transitive esbuild from 0.28.0 to 0.28.1 via pnpm override Jun 17, 2026
Copilot AI requested a review from jcstein June 17, 2026 20:50
@jcstein

jcstein commented Jun 17, 2026

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts by merging main into this branch and committing the conflict resolution in df88765.

Copilot AI changed the title Pin transitive esbuild from 0.28.0 to 0.28.1 via pnpm override Pin transitive esbuild to 0.28.1 via pnpm override Jun 17, 2026
Copilot AI requested a review from jcstein June 17, 2026 21:04
@jcstein jcstein marked this pull request as ready for review June 17, 2026 21:10
@jcstein jcstein merged commit 845b4c9 into main Jun 17, 2026
1 check passed
@jcstein jcstein deleted the copilot/fix-dependabot-vulnerability-alert branch June 17, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants