Skip to content

fix: security hardening and package cleanup#10

Merged
tgaeta merged 6 commits intomainfrom
fix/security-hardening
Feb 21, 2026
Merged

fix: security hardening and package cleanup#10
tgaeta merged 6 commits intomainfrom
fix/security-hardening

Conversation

@tgaeta
Copy link
Contributor

@tgaeta tgaeta commented Feb 21, 2026

Changes

Security

  • Pin awal to v2.0.3 — was @latest, which is a supply chain risk. Compromised @latest would affect all users silently.
  • URL validation — only HTTPS URLs allowed before passing to awal CLI. Prevents file://, javascript:, etc.
  • Header sanitization — header names must be alphanumeric+hyphens, values cannot contain newlines (prevents header injection)
  • HTTP method sanitization — strips non-alpha characters from method strings
  • Max payment safety cap--max-amount enforced on all awal calls ($10 default, configurable via NULLPATH_MAX_PAYMENT env var)

Package Size

  • Added files field to package.json — only ships dist + README + LICENSE
  • Before: 50 files, 263 KB unpacked, 58 KB tarball
  • After: 23 files, 112 KB unpacked, 28 KB tarball
  • Removed from tarball: src/, .github/, docs/, dist/__tests__/, SWARM_SPEC.md, AWESOME_MCP_ENTRY.md, tsconfig.json

Release Automation

  • Wired @semantic-release/changelog + @semantic-release/git into .releaserc.json
  • Next release will auto-bump package.json version and generate CHANGELOG.md
  • Synced package.json to 1.4.1 to match current npm

Tests

  • Updated awal tests for pinned version (47/47 passing)

Socket.dev Impact

These changes should improve the supply chain score (currently 77). The shell access and network access flags 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.

- 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
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@tgaeta tgaeta merged commit b40a57b into main Feb 21, 2026
1 check passed
tgaeta pushed a commit that referenced this pull request Feb 21, 2026
## [1.4.2](v1.4.1...v1.4.2) (2026-02-21)

### Bug Fixes

* security hardening and package cleanup ([#10](#10)) ([b40a57b](b40a57b))
* use GH_PAT for checkout so semantic-release/git can push to main ([#11](#11)) ([4417bba](4417bba))
@tgaeta
Copy link
Contributor Author

tgaeta commented Feb 21, 2026

🎉 This PR is included in version 1.4.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants