fix: security hardening and package cleanup#10
Conversation
- Pin awal to v2.0.3 (was @latest — supply chain risk) - Add URL validation (HTTPS-only) before passing to awal CLI - Add header sanitization (no newlines, alphanumeric names only) - Add --max-amount safety cap on awal payments ($10 default, configurable via NULLPATH_MAX_PAYMENT) - Add HTTP method sanitization (strip non-alpha chars) - Trim published package via files field (50→23 files, 263KB→112KB) - Remove src/, .github/, docs/, dist/__tests__/ from npm tarball - Wire semantic-release/git + changelog for auto version bump in repo - Sync package.json version to 1.4.1 (matches npm) - Update tests for pinned version
There was a problem hiding this comment.
Pull request overview
This pull request implements comprehensive security hardening measures for the nullpath-mcp package, focusing on supply chain security, input validation, and package size optimization. The changes pin the awal CLI dependency to a specific version (v2.0.3) instead of using @latest, add multiple input validation layers to prevent injection attacks, and reduce the published package size by ~50% through selective file inclusion.
Changes:
- Pinned awal to v2.0.3 and added URL/header/method validation with max payment safety cap
- Reduced package size from 263 KB to 112 KB unpacked by adding files field to package.json
- Enhanced semantic-release automation to auto-generate CHANGELOG.md and version bump package.json
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/lib/awal.ts | Added security hardening: pinned awal version constant, URL validation (HTTPS-only), header sanitization, HTTP method sanitization, max payment cap with env override, and version getter function |
| src/tests/awal.test.ts | Updated tests to reference pinned awal version (2.0.3) instead of @latest |
| package.json | Bumped version to 1.4.1, added files field to exclude source/test/config files from npm package |
| .releaserc.json | Added @semantic-release/changelog and @semantic-release/git plugins for automated changelog and version management |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Allow underscores in header names (RFC 7230 permits them) - Replace HTTP method char-stripping with whitelist validation - Allow http://localhost and http://127.0.0.1 when NULLPATH_ALLOW_HTTP=true - Add 18 new tests for validation functions, getAwalVersion, max-amount cap - Total: 65 tests passing (was 47)
- Filter NULLPATH_WALLET_KEY and other sensitive vars from child process env - Add 1MB body size limit to prevent OOM via large payloads - Log warning when NULLPATH_ALLOW_HTTP is active - 3 new tests (body limit, env sanitization, normal body) - Total: 68 tests passing
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot correctly identified that src/index.ts had a hardcoded '1.2.0' while package.json is 1.4.1. Synced the constant. Going forward, semantic-release/git will bump package.json automatically.
- Fix AwalStatus.version docstring to clarify it's pinned, not detected - Fix validateUrl comment to match actual behavior (env var, not NODE_ENV) - Broaden env sanitization to regex patterns (catches AWS_SECRET_ACCESS_KEY, GH_TOKEN, etc.) - Move env var cleanup to afterEach for test reliability - Add test for broader secret pattern matching - Total: 69 tests passing
|
🎉 This PR is included in version 1.4.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Changes
Security
@latest, which is a supply chain risk. Compromised@latestwould affect all users silently.file://,javascript:, etc.--max-amountenforced on all awal calls ($10 default, configurable viaNULLPATH_MAX_PAYMENTenv var)Package Size
filesfield to package.json — only ships dist + README + LICENSEsrc/,.github/,docs/,dist/__tests__/,SWARM_SPEC.md,AWESOME_MCP_ENTRY.md,tsconfig.jsonRelease Automation
@semantic-release/changelog+@semantic-release/gitinto.releaserc.jsonpackage.jsonversion and generateCHANGELOG.mdTests
Socket.dev Impact
These changes should improve the supply chain score (currently 77). The
shell accessandnetwork accessflags will persist since they're functional requirements (awal CLI + API calls), but pinning the version and reducing the package surface area addresses the actionable concerns.