felladrin / felladrin/MiniSearch

security: review native module supply chain risk (onnxruntime-node, @wllama/wllama)

Open
#2,525 0 comments 0 reactions 0 assignees View on GitHub
security
Dominant language
TypeScript
Stars
587
Forks
70
Avg merge
1h 3m
Merged PRs (30d)
175

Description

## Problem

The project depends on several native/WebAssembly modules with larger supply chain attack surfaces:

| Package | Type | Risk |
|---------|------|------|
| `onnxruntime-node` | Native (postinstall downloads binaries) | High |
| `@wllama/wllama` | WebAssembly | Medium |
| `@huggingface/tokenizers` | Native | Medium |
| `hash-wasm` | WebAssembly | Low |

The `npm ci` output warns:

```
npm warn install-scripts 1 package has install scripts not yet covered by allowScripts:
npm warn install-scripts onnxruntime-node@1.29.0 (postinstall: node ./script/install)
```

## Why It Matters

- **Native modules execute code at install time**: A compromised postinstall script could exfiltrate secrets or install malware
- **WebAssembly modules are opaque**: They're harder to audit than pure JavaScript
- **Supply chain attacks are increasing**: Recent attacks have targeted npm packages with native dependencies
- **Trust boundary**: These modules run with the same privileges as the application

## Proposed Improvements

1. **Pin native module versions**: Avoid caret (`^`) ranges for native modules
2. **Verify checksums**: Add post-install checksum verification for downloaded binaries
3. **Use npm `allowScripts`**: Explicitly approve which packages can run install scripts
4. **Add `npm audit signatures`**: Verify package integrity
5. **Document trust assumptions**: Add a section to SECURITY.md explaining the native module trust model

## Files to Change

- `package.json` (pin native module versions)
- `.npmrc` (add `allowScripts` configuration)
- `.github/SECURITY.md` (document native module trust model)

## Acceptance Criteria

- Native module versions are pinned (no caret ranges)
- `allowScripts` is configured in `.npmrc`
- SECURITY.md documents the native module trust model
- `npm ci` no longer warns about uncovered install scripts

Contributor guide

Open the contributing guide

Research direction

Start by inspecting the native and WebAssembly dependencies in package.json and reproducing the npm ci install-script warning. Then review .npmrc and .github/SECURITY.md against the proposed pinning, allowScripts, and trust-model documentation. Done means the listed acceptance criteria pass, including a warning-free npm ci.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript, wasm
Domain
build-system, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.