Skip to content

Commit bc4e438

Browse files
committed
Release v1.1.0: Complete SchemaPin enhancement implementation
- Key revocation with schema v1.1 and revoked_keys array - Interactive key pinning with user prompts and domain policies - CLI tools: schemapin-keygen, schemapin-sign, schemapin-verify - Integration demo and production .well-known server - Package distribution preparation for PyPI and npm - Updated README with comprehensive security guarantees - Updated mermaid diagrams to reflect new features
1 parent 5869abb commit bc4e438

63 files changed

Lines changed: 11680 additions & 301 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Changelog
2+
3+
All notable changes to the SchemaPin project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.1.0] - 2025-01-07
9+
10+
### Added
11+
12+
#### Phase 1: Key Revocation System
13+
- **Schema Version 1.1**: Enhanced `.well-known/schemapin.json` format with `revoked_keys` array
14+
- **Key Revocation Support**: Automatic checking of revoked keys during verification
15+
- **Backward Compatibility**: Full support for schema v1.0 endpoints
16+
- **Revocation Validation**: Comprehensive validation of revoked key entries
17+
18+
#### Phase 2: Interactive Key Pinning
19+
- **Interactive Pinning**: User prompts for key pinning decisions with detailed information
20+
- **Domain Policies**: Configurable policies for automatic vs. interactive pinning
21+
- **Enhanced UX**: Rich terminal output with colored status indicators and clear prompts
22+
- **Key Management**: Advanced key pinning with metadata and policy enforcement
23+
24+
#### Phase 3: CLI Tools
25+
- **schemapin-keygen**: Complete key generation tool with ECDSA/RSA support
26+
- **schemapin-sign**: Schema signing tool with batch processing and metadata
27+
- **schemapin-verify**: Verification tool with interactive pinning and discovery
28+
- **Comprehensive Options**: Full CLI interface with extensive configuration options
29+
30+
#### Phase 4: Integration Demo and Production Server
31+
- **Integration Demo**: Complete cross-language compatibility demonstration
32+
- **Production Server**: Docker-ready `.well-known` endpoint server
33+
- **Real-world Examples**: Practical usage scenarios and deployment guides
34+
- **Cross-language Testing**: Validation of Python/JavaScript interoperability
35+
36+
#### Phase 5: Package Management and Distribution
37+
- **Python Package**: Complete PyPI-ready package with modern packaging standards
38+
- **JavaScript Package**: npm-ready package with comprehensive metadata
39+
- **Build Scripts**: Automated building and testing infrastructure
40+
- **Distribution Tools**: Publishing workflows and validation scripts
41+
42+
### Enhanced
43+
44+
#### Core Functionality
45+
- **ECDSA P-256 Signatures**: Industry-standard cryptographic verification
46+
- **Schema Canonicalization**: Deterministic JSON serialization for consistent hashing
47+
- **Trust-On-First-Use (TOFU)**: Secure key pinning with user control
48+
- **Public Key Discovery**: RFC 8615 compliant `.well-known` endpoint discovery
49+
50+
#### Security Features
51+
- **Key Revocation**: Comprehensive revocation checking and validation
52+
- **Signature Verification**: Robust cryptographic signature validation
53+
- **Key Pinning Storage**: Secure local storage of pinned keys with metadata
54+
- **Domain Validation**: Proper domain-based key association and verification
55+
56+
#### Developer Experience
57+
- **High-level APIs**: Simple workflows for both developers and clients
58+
- **Comprehensive Testing**: Full test suites with security validation
59+
- **Rich Documentation**: Complete API documentation and usage examples
60+
- **Cross-platform Support**: Works on Linux, macOS, and Windows
61+
62+
#### Package Quality
63+
- **Modern Packaging**: Uses pyproject.toml and latest npm standards
64+
- **Comprehensive Metadata**: Rich package information for discoverability
65+
- **Development Tools**: Integrated linting, testing, and quality checks
66+
- **Security Compliance**: Bandit security scanning and vulnerability checks
67+
68+
### Technical Specifications
69+
70+
#### Cryptographic Standards
71+
- **Signature Algorithm**: ECDSA with P-256 curve (secp256r1)
72+
- **Hash Algorithm**: SHA-256 for schema integrity
73+
- **Key Format**: PEM encoding for interoperability
74+
- **Signature Format**: Base64 encoding for transport
75+
76+
#### Protocol Compliance
77+
- **RFC 8615**: `.well-known` URI specification compliance
78+
- **JSON Schema**: Structured schema validation and canonicalization
79+
- **HTTP Standards**: Proper HTTP headers and status codes
80+
- **Cross-language**: Full Python and JavaScript compatibility
81+
82+
#### Package Standards
83+
- **Python**: PEP 517/518 compliant with pyproject.toml
84+
- **JavaScript**: Modern ES modules with comprehensive exports
85+
- **Semantic Versioning**: Proper version management and compatibility
86+
- **License Compliance**: MIT license with proper attribution
87+
88+
### Dependencies
89+
90+
#### Python Requirements
91+
- `cryptography>=41.0.0` - ECDSA cryptographic operations
92+
- `requests>=2.31.0` - HTTP client for key discovery
93+
- Python 3.8+ support with type hints
94+
95+
#### JavaScript Requirements
96+
- Node.js 18.0.0+ - Modern JavaScript runtime
97+
- Zero external dependencies - Uses built-in crypto module
98+
- ES modules with proper exports configuration
99+
100+
### Breaking Changes
101+
- None - Full backward compatibility maintained
102+
103+
### Security Notes
104+
- All cryptographic operations use industry-standard algorithms
105+
- Key revocation checking prevents use of compromised keys
106+
- Interactive pinning provides user control over trust decisions
107+
- Secure storage of pinned keys with proper metadata
108+
109+
### Migration Guide
110+
- Existing v1.0 implementations continue to work without changes
111+
- New features are opt-in and backward compatible
112+
- CLI tools provide migration assistance for existing workflows
113+
114+
## [1.0.0] - 2024-12-01
115+
116+
### Added
117+
- Initial release of SchemaPin protocol
118+
- Basic ECDSA P-256 signature verification
119+
- Simple key pinning mechanism
120+
- Python and JavaScript reference implementations
121+
- Core cryptographic operations and schema canonicalization
122+
123+
---
124+
125+
For more details on any release, see the [GitHub releases page](https://github.com/thirdkey/schemapin/releases).

README.md

Lines changed: 97 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@
22

33
A cryptographic protocol for ensuring the integrity and authenticity of tool schemas used by AI agents. SchemaPin prevents "MCP Rug Pull" attacks by enabling developers to cryptographically sign their tool schemas and allowing clients to verify that schemas have not been altered since publication.
44

5+
## About
6+
7+
SchemaPin addresses critical security vulnerabilities in AI agent ecosystems by providing cryptographic guarantees for tool schema integrity and authenticity. As AI agents increasingly rely on external tools and services, ensuring these tools haven't been compromised becomes essential for maintaining system security and user trust.
8+
9+
### Core Security Guarantees
10+
11+
**Schema Integrity:** SchemaPin guarantees that tool schemas have not been altered maliciously or accidentally since publication, protecting against data corruption, misconfigured servers, or unauthorized modification. This ensures that the tool behavior your AI agent expects matches exactly what the tool developer intended.
12+
13+
**Authenticity:** Cryptographic signatures prove schema origin, ensuring schemas genuinely come from the claimed developer. This is critical for supply-chain security, preventing attackers from impersonating legitimate tool developers or injecting malicious schemas into trusted repositories.
14+
15+
### Broader Threat Protection
16+
17+
**Man-in-the-Middle (MITM) Attack Mitigation:** SchemaPin provides application-layer security that prevents schema tampering even if network connections are intercepted. This complements HTTPS transport security by ensuring that even if an attacker compromises the transport layer, they cannot forge valid schema signatures without access to the developer's private key.
18+
19+
**Compromised Infrastructure Defense:** Protection against scenarios where servers, CDNs, or repositories hosting schema files are hacked and schema files are replaced with malicious versions. Since attackers cannot forge signatures without the original developer's private keys, compromised infrastructure cannot be used to distribute malicious schemas that would pass verification.
20+
21+
### Real-World Attack Scenario: The "MCP Rug Pull"
22+
23+
Consider this concrete example: An AI agent uses a popular "file_manager" tool that initially provides legitimate file operations. After gaining widespread adoption, the tool's schema is maliciously updated to include a new "backup_to_cloud" function that secretly exfiltrates sensitive files to an attacker-controlled server. Without SchemaPin, AI agents would automatically trust and use this modified schema. With SchemaPin, the signature verification would fail, alerting users to the unauthorized modification and preventing the attack.
24+
25+
### Ecosystem and Trust Benefits
26+
27+
**Standardized Trust Mechanism:** SchemaPin provides a common, interoperable standard for verifying tools across different AI agent frameworks and programming languages. This creates a unified security foundation that benefits the entire AI ecosystem, regardless of the specific implementation or platform being used.
28+
29+
**Enabling Automated Governance:** The protocol allows enterprises and platforms to programmatically enforce security policies requiring valid signatures before tool execution. This enables automated compliance checking and reduces the manual overhead of security reviews while maintaining strong security guarantees.
30+
31+
**Trust on First Use (TOFU) Model:** Key pinning provides long-term security by protecting against future key substitution attacks. Once a developer's key is pinned, any attempt to use a different key for the same tool domain triggers security warnings, preventing attackers from compromising tools even if they gain control of the developer's infrastructure.
32+
533
## Overview
634

735
SchemaPin provides a robust defense against supply-chain attacks where benign schemas are maliciously replaced after being approved. The protocol uses:
@@ -22,25 +50,39 @@ SchemaPin provides a robust defense against supply-chain attacks where benign sc
2250

2351
```mermaid
2452
flowchart TD
25-
A[Tool Developer] -->|Publishes| B["/.well-known/schemapin.json (Public Key)"]
53+
A[Tool Developer] -->|Publishes| B["/.well-known/schemapin.json<br/>(Public Key + Revoked Keys)"]
2654
A -->|Signs| C["Tool Schema + Signature"]
2755
2856
subgraph "AI Agent"
2957
D["Fetch Schema + Signature"]
3058
E["Fetch or Cache Public Key"]
31-
F["Verify Signature"]
32-
G{"Signature Valid?"}
33-
H["Accept & Use Tool Schema"]
34-
I["Reject / Block Tool"]
59+
F["Check Key Revocation"]
60+
G["Verify Signature"]
61+
H{"Key Revoked?"}
62+
I{"Signature Valid?"}
63+
J{"Interactive Mode?"}
64+
K["Prompt User Decision"]
65+
L["Accept & Use Tool Schema"]
66+
M["Reject / Block Tool"]
67+
N["Pin Key (TOFU)"]
3568
end
3669
3770
C --> D
3871
B --> E
39-
D --> F
72+
D --> G
4073
E --> F
41-
F --> G
42-
G -- Yes --> H
43-
G -- No --> I
74+
F --> H
75+
E --> G
76+
H -- Yes --> M
77+
H -- No --> G
78+
G --> I
79+
I -- No --> M
80+
I -- Yes --> J
81+
J -- Yes --> K
82+
J -- No --> N
83+
K --> L
84+
K --> M
85+
N --> L
4486
```
4587

4688
## Quick Start
@@ -101,21 +143,34 @@ else:
101143

102144
## Installation
103145

104-
### Python
146+
### From Package Repositories (Recommended)
147+
148+
#### Python (PyPI)
105149

106150
```bash
107-
cd python
108-
pip install -e .
151+
# Install from PyPI
152+
pip install schemapin
153+
154+
# Or install with development dependencies
155+
pip install schemapin[dev]
109156
```
110157

111-
### JavaScript/Node.js
158+
After installation, CLI tools will be available:
159+
- `schemapin-keygen` - Generate cryptographic key pairs
160+
- `schemapin-sign` - Sign JSON schemas
161+
- `schemapin-verify` - Verify signed schemas
162+
163+
#### JavaScript/Node.js (npm)
112164

113165
```bash
114-
cd javascript
115-
npm install
166+
# Install from npm
167+
npm install schemapin
168+
169+
# Or install globally for CLI usage
170+
npm install -g schemapin
116171
```
117172

118-
### Development Setup
173+
### From Source (Development)
119174

120175
```bash
121176
# Clone repository
@@ -125,18 +180,30 @@ cd schemapin
125180
# Set up Python environment
126181
python3 -m venv .venv
127182
source .venv/bin/activate
128-
pip install -r python/requirements.txt
129183

130184
# Install Python package in development mode
131185
cd python
132-
pip install -e .
133-
134-
# Run Python tests
135-
python -m pytest tests/ -v
186+
pip install -e .[dev]
136187

137-
# Run JavaScript tests
188+
# Install JavaScript dependencies
138189
cd ../javascript
139-
npm test
190+
npm install
191+
192+
# Run tests
193+
cd ../python && python -m pytest tests/ -v
194+
cd ../javascript && npm test
195+
```
196+
197+
### Package Building
198+
199+
```bash
200+
# Build all packages
201+
python scripts/build_packages.py
202+
203+
# Test packages
204+
python scripts/test_packages.py
205+
206+
# Packages will be available in dist/
140207
```
141208

142209
## Examples
@@ -180,10 +247,12 @@ graph LR
180247
181248
F[Client] --> G[Fetch Schema + Signature]
182249
G --> H[Discover Public Key]
183-
H --> I[Verify Signature]
184-
I --> J{Valid?}
185-
J -->|Yes| K[Use Tool]
186-
J -->|No| L[Reject Tool]
250+
H --> I[Check Key Revocation]
251+
I --> J[Verify Signature]
252+
J --> K{Valid & Not Revoked?}
253+
K -->|Yes| L[Interactive Pinning Check]
254+
L --> M[Use Tool]
255+
K -->|No| N[Reject Tool]
187256
```
188257

189258
## Security
@@ -295,7 +364,7 @@ MIT License - see [`LICENSE`](LICENSE) file for details.
295364

296365
## Contact
297366

298-
- **Author**: Jascha Wanger / ThirdKey.ai
367+
- **Author**: Jascha Wanger / [ThirdKey.ai](https://thirdkey.ai)
299368
- **Email**: [email protected]
300369
- **Repository**: https://github.com/thirdkey/schemapin
301370

0 commit comments

Comments
 (0)