Skip to content

fix(skills_hub): verify ClawHub archive and per-file SHA-256 on download - #13583

Closed
Subway2023 wants to merge 1 commit into
NousResearch:mainfrom
Subway2023:fix-skill
Closed

Subway2023 wants to merge 1 commit into
NousResearch:mainfrom
Subway2023:fix-skill

Conversation

@Subway2023

Copy link
Copy Markdown

What does this PR do?

ClawHubSource downloaded and installed skill archives without verifying them against any server-published hash. A network-level attacker (MITM) could silently replace a downloaded archive with malicious content, and the agent would install it without any indication of tampering.

This PR adds integrity verification to two download paths:

  • Archive download (_download_zip): fetch sha256hash from /skills/{slug}/versions/{version} before extracting, and compare it against the SHA-256 of the downloaded ZIP bytes. A mismatch aborts the install.
  • Per-file fallback (_extract_files): when fetching individual files via rawUrl, verify against the optional sha256 field in the file metadata. Files that fail the check are skipped with a warning.

If the API does not return a hash (degraded mode), a warning is logged and the install proceeds.

Related Issue

GHSA-w4h6-jpv9-2gx5

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • tools/skills_hub.py: add _resolve_version_integrity() to fetch version metadata and extract sha256hash
  • tools/skills_hub.py: update fetch() to call _resolve_version_integrity() and abort on tamper detection
  • tools/skills_hub.py: update _download_zip() to accept expected_sha256 and verify archive hash before extraction
  • tools/skills_hub.py: update _extract_files() to verify per-file sha256 from metadata when available
  • tests/tools/test_skills_hub_integrity.py: add tests covering hash match, tamper rejection, degraded-mode warning, and per-file integrity

How to Test

  1. Run pytest tests/tools/test_skills_hub_integrity.py -v — all 10 integrity tests should pass
  2. Run pytest tests/ -q — full suite should pass with no regressions

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

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

Labels

tool/skills Skills system (list, view, manage) type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants