Agent Supply Chain Integrity

Agent Supply Chain Integrity

Generates and verifies SHA-256 integrity manifests for AI agent plugins and tools, detecting tampering and checking dependency pinning and provenance.

Skill files1 file
SKILL.md340 lines
1
---
2
name: agent-supply-chain
3
description: |
4
Verify supply chain integrity for AI agent plugins, tools, and dependencies. Use this skill when:
5
- Generating SHA-256 integrity manifests for agent plugins or tool packages
6
- Verifying that installed plugins match their published manifests
7
- Detecting tampered, modified, or untracked files in agent tool directories
8
- Auditing dependency pinning and version policies for agent components
9
- Building provenance chains for agent plugin promotion (dev → staging → production)
10
- Any request like "verify plugin integrity", "generate manifest", "check supply chain", or "sign this plugin"
11
---
12
13
# Agent Supply Chain Integrity
14
15
Generate and verify integrity manifests for AI agent plugins and tools. Detect tampering, enforce version pinning, and establish supply chain provenance.
16
17
## Overview
18
19
Agent plugins and MCP servers have the same supply chain risks as npm packages or container images — except the ecosystem has no equivalent of npm provenance, Sigstore, or SLSA. This skill fills that gap.
20
21
```
22
Plugin Directory → Hash All Files (SHA-256) → Generate INTEGRITY.json
23
↓
24
Later: Plugin Directory → Re-Hash Files → Compare Against INTEGRITY.json
25
↓
26
Match? VERIFIED : TAMPERED
27
```
28
29
## When to Use
30
31
- Before promoting a plugin from development to production
32
- During code review of plugin PRs
33
- As a CI step to verify no files were modified after review
34
- When auditing third-party agent tools or MCP servers
35
- Building a plugin marketplace with integrity requirements
36
37
---
38
39
## Pattern 1: Generate Integrity Manifest
40
41
Create a deterministic `INTEGRITY.json` with SHA-256 hashes of all plugin files.
42
43
```python
44
import hashlib
45
import json
46
from datetime import datetime, timezone
47
from pathlib import Path
48
49
EXCLUDE_DIRS = {".git", "__pycache__", "node_modules", ".venv", ".pytest_cache"}
50
EXCLUDE_FILES = {".DS_Store", "Thumbs.db", "INTEGRITY.json"}
51
52
def hash_file(path: Path) -> str:
53
"""Compute SHA-256 hex digest of a file."""
54
h = hashlib.sha256()
55
with open(path, "rb") as f:
56
for chunk in iter(lambda: f.read(8192), b""):
57
h.update(chunk)
58
return h.hexdigest()
59
60
def generate_manifest(plugin_dir: str) -> dict:
61
"""Generate an integrity manifest for a plugin directory."""
62
root = Path(plugin_dir)
63
files = {}
64
65
for path in sorted(root.rglob("*")):
66
if not path.is_file():
67
continue
68
if path.name in EXCLUDE_FILES:
69
continue
70
if any(part in EXCLUDE_DIRS for part in path.relative_to(root).parts):
71
continue
72
rel = path.relative_to(root).as_posix()
73
files[rel] = hash_file(path)
74
75
# Chain hash: SHA-256 of all file hashes concatenated in sorted order
76
chain = hashlib.sha256()
77
for key in sorted(files.keys()):
78
chain.update(files[key].encode("ascii"))
79
80
manifest = {
81
"plugin_name": root.name,
82
"generated_at": datetime.now(timezone.utc).isoformat(),
83
"algorithm": "sha256",
84
"file_count": len(files),
85
"files": files,
86
"manifest_hash": chain.hexdigest(),
87
}
88
return manifest
89
90
# Generate and save
91
manifest = generate_manifest("my-plugin/")
92
Path("my-plugin/INTEGRITY.json").write_text(
93
json.dumps(manifest, indent=2) + "\n"
94
)
95
print(f"Generated manifest: {manifest['file_count']} files, "
96
f"hash: {manifest['manifest_hash'][:16]}...")
97
```
98
99
**Output (`INTEGRITY.json`):**
100
```json
101
{
102
"plugin_name": "my-plugin",
103
"generated_at": "2026-04-01T03:00:00+00:00",
104
"algorithm": "sha256",
105
"file_count": 12,
106
"files": {
107
".claude-plugin/plugin.json": "a1b2c3d4...",
108
"README.md": "e5f6a7b8...",
109
"skills/search/SKILL.md": "c9d0e1f2...",
110
"agency.json": "3a4b5c6d..."
111
},
112
"manifest_hash": "7e8f9a0b1c2d3e4f..."
113
}
114
```
115
116
---
117
118
## Pattern 2: Verify Integrity
119
120
Check that current files match the manifest.
121
122
```python
123
# Requires: hash_file() and generate_manifest() from Pattern 1 above
124
import json
125
from pathlib import Path
126
127
def verify_manifest(plugin_dir: str) -> tuple[bool, list[str]]:
128
"""Verify plugin files against INTEGRITY.json."""
129
root = Path(plugin_dir)
130
manifest_path = root / "INTEGRITY.json"
131
132
if not manifest_path.exists():
133
return False, ["INTEGRITY.json not found"]
134
135
manifest = json.loads(manifest_path.read_text())
136
recorded = manifest.get("files", {})
137
errors = []
138
139
# Check recorded files
140
for rel_path, expected_hash in recorded.items():
141
full = root / rel_path
142
if not full.exists():
143
errors.append(f"MISSING: {rel_path}")
144
continue
145
actual = hash_file(full)
146
if actual != expected_hash:
147
errors.append(f"MODIFIED: {rel_path}")
148
149
# Check for new untracked files
150
current = generate_manifest(plugin_dir)
151
for rel_path in current["files"]:
152
if rel_path not in recorded:
153
errors.append(f"UNTRACKED: {rel_path}")
154
155
return len(errors) == 0, errors
156
157
# Verify
158
passed, errors = verify_manifest("my-plugin/")
159
if passed:
160
print("VERIFIED: All files match manifest")
161
else:
162
print(f"FAILED: {len(errors)} issue(s)")
163
for e in errors:
164
print(f" {e}")
165
```
166
167
**Output on tampered plugin:**
168
```
169
FAILED: 3 issue(s)
170
MODIFIED: skills/search/SKILL.md
171
MISSING: agency.json
172
UNTRACKED: backdoor.py
173
```
174
175
---
176
177
## Pattern 3: Dependency Version Audit
178
179
Check that agent dependencies use pinned versions.
180
181
```python
182
import re
183
184
def audit_versions(config_path: str) -> list[dict]:
185
"""Audit dependency version pinning in a config file."""
186
findings = []
187
path = Path(config_path)
188
content = path.read_text()
189
190
if path.name == "package.json":
191
data = json.loads(content)
192
for section in ("dependencies", "devDependencies"):
193
for pkg, ver in data.get(section, {}).items():
194
if ver.startswith("^") or ver.startswith("~") or ver == "*" or ver == "latest":
195
findings.append({
196
"package": pkg,
197
"version": ver,
198
"severity": "HIGH" if ver in ("*", "latest") else "MEDIUM",
199
"fix": f'Pin to exact: "{pkg}": "{ver.lstrip("^~")}"'
200
})
201
202
elif path.name in ("requirements.txt", "pyproject.toml"):
203
for line in content.splitlines():
204
line = line.strip()
205
if ">=" in line and "<" not in line:
206
findings.append({
207
"package": line.split(">=")[0].strip(),
208
"version": line,
209
"severity": "MEDIUM",
210
"fix": f"Add upper bound: {line},<next_major"
211
})
212
213
return findings
214
```
215
216
---
217
218
## Pattern 4: Promotion Gate
219
220
Use integrity verification as a gate before promoting plugins.
221
222
```python
223
def promotion_check(plugin_dir: str) -> dict:
224
"""Check if a plugin is ready for production promotion."""
225
checks = {}
226
227
# 1. Integrity manifest exists and verifies
228
passed, errors = verify_manifest(plugin_dir)
229
checks["integrity"] = {
230
"passed": passed,
231
"errors": errors
232
}
233
234
# 2. Required files exist
235
root = Path(plugin_dir)
236
required = ["README.md"]
237
missing = [f for f in required if not (root / f).exists()]
238
239
# Require at least one plugin manifest (supports both layouts)
240
manifest_paths = [
241
root / ".github/plugin/plugin.json",
242
root / ".claude-plugin/plugin.json",
243
]
244
if not any(p.exists() for p in manifest_paths):
245
missing.append(".github/plugin/plugin.json (or .claude-plugin/plugin.json)")
246
247
checks["required_files"] = {
248
"passed": len(missing) == 0,
249
"missing": missing
250
}
251
252
# 3. No unpinned dependencies
253
mcp_path = root / ".mcp.json"
254
if mcp_path.exists():
255
config = json.loads(mcp_path.read_text())
256
unpinned = []
257
for server in config.get("mcpServers", {}).values():
258
if isinstance(server, dict):
259
for arg in server.get("args", []):
260
if isinstance(arg, str) and "@latest" in arg:
261
unpinned.append(arg)
262
checks["pinned_deps"] = {
263
"passed": len(unpinned) == 0,
264
"unpinned": unpinned
265
}
266
267
# Overall
268
all_passed = all(c["passed"] for c in checks.values())
269
return {"ready": all_passed, "checks": checks}
270
271
result = promotion_check("my-plugin/")
272
if result["ready"]:
273
print("Plugin is ready for production promotion")
274
else:
275
print("Plugin NOT ready:")
276
for name, check in result["checks"].items():
277
if not check["passed"]:
278
print(f" FAILED: {name}")
279
```
280
281
---
282
283
## CI Integration
284
285
Add to your GitHub Actions workflow:
286
287
```yaml
288
- name: Verify plugin integrity
289
run: |
290
PLUGIN_DIR="${{ matrix.plugin || '.' }}"
291
cd "$PLUGIN_DIR"
292
python -c "
293
from pathlib import Path
294
import json, hashlib, sys
295
296
def hash_file(p):
297
h = hashlib.sha256()
298
with open(p, 'rb') as f:
299
for c in iter(lambda: f.read(8192), b''):
300
h.update(c)
301
return h.hexdigest()
302
303
manifest = json.loads(Path('INTEGRITY.json').read_text())
304
errors = []
305
for rel, expected in manifest['files'].items():
306
p = Path(rel)
307
if not p.exists():
308
errors.append(f'MISSING: {rel}')
309
elif hash_file(p) != expected:
310
errors.append(f'MODIFIED: {rel}')
311
if errors:
312
for e in errors:
313
print(f'::error::{e}')
314
sys.exit(1)
315
print(f'Verified {len(manifest[\"files\"])} files')
316
"
317
```
318
319
---
320
321
## Best Practices
322
323
| Practice | Rationale |
324
|----------|-----------|
325
| **Generate manifest after code review** | Ensures reviewed code matches production code |
326
| **Include manifest in the PR** | Reviewers can verify what was hashed |
327
| **Verify in CI before deploy** | Catches post-review modifications |
328
| **Chain hash for tamper evidence** | Single hash represents entire plugin state |
329
| **Exclude build artifacts** | Only hash source files — .git, __pycache__, node_modules excluded |
330
| **Pin all dependency versions** | Unpinned deps = different code on every install |
331
332
---
333
334
## Related Resources
335
336
- [OpenSSF SLSA](https://slsa.dev/) — Supply-chain Levels for Software Artifacts
337
- [npm Provenance](https://docs.npmjs.com/generating-provenance-statements) — Sigstore-based package provenance
338
- [Agent Governance Toolkit](https://github.com/microsoft/agent-governance-toolkit) — Includes integrity verification and plugin signing
339
- [OWASP ASI-09: Supply Chain Integrity](https://owasp.org/www-project-agentic-ai-threats/)
340

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…