File size: 12,351 Bytes
ef6eb55 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | # ADR-0009: Protected Execution Capability Boundary
**Status:** Accepted
**Date:** 2026-08-18
**Replaces:** ADR-0002 (Authorization Boundary) β subsumed
---
## Executive Summary
PAX-Coder implements a real cryptographic capability gate for protected operations.
The boundary is NOT:
- GitHub clone access
- Local file presence
- Environment variables alone
- Self-signed credentials
- Locally generated authorization
The boundary IS:
- Signed capability tokens from an external authority
- Cryptographic signature verification
- Short-lived with expiration
- Bound to specific release commits
- Verified at the execution entry point
---
## Problem
The previous architecture had a gap: integrity verification was free and public (correct), but authorization was implemented as shell conditionals checking for `.node_sk` file presence (incorrect).
This created "security theater":
- A user with a public clone could run any script
- No real external authorization existed
- The "authorization" was just a file check
---
## Solution
Implement a real authorization boundary:
```text
PUBLIC CLONE (anyone)
β
RELEASE INTEGRITY (free, public verify-clone)
β
INTEGRITY_VERIFIED
β
REQUEST PROTECTED OPERATION
β
AUTHORIZATION SERVICE (external)
β
β Validates:
β - Node identity
β - Request legitimacy
β - Current authorization status
β
βββ Generates signed capability
(if authorized)
β
CAPABILITY TOKEN
{
"node_id": "...",
"release_id": "1.0.0",
"commit": "...",
"expires_at": "2026-08-18T...",
"nonce": "...",
"signature": "..."
}
β
CLIENT-SIDE GATE VERIFICATION
{
pax-coder-gate {
verify release integrity
verify capability format
verify expiration
verify signature
verify commit match
}
}
β
PROTECTED EXECUTION
(only if all checks pass)
```
---
## Key Properties
### 1. Signed Capability Token
The authorization is NOT a shell variable or file presence check.
It is a JSON structure with fields:
```json
{
"node_id": "...", // Which node this grants access to
"release_id": "1.0.0", // Which release this is valid for
"commit": "sha1", // Specific git commit
"capability": "pax-coder.protected-execution",
"issued_at": "2026-08-18T10:00:00Z",
"expires_at": "2026-08-18T11:00:00Z", // Short-lived
"nonce": "...", // Fresh nonce from request
"signature": "..." // Ed25519 signature by authority
}
```
The signature is verifiable using the authority's public key.
### 2. Short-Lived Expiration
Capabilities expire within 1 hour by default.
A user cannot obtain a capability once and use it indefinitely.
Each protected operation requires a fresh authorization request.
### 3. Nonce Binding
The capability is bound to a fresh cryptographic nonce from the client.
This prevents:
- Replaying old capabilities
- Using one capability across multiple requests
- Intercepted-capability attacks (attacker cannot manufacture matching nonce)
### 4. Commit Binding
The capability is bound to a specific git commit.
Changing the repository code invalidates all existing capabilities.
A code update requires new authorization requests.
### 5. Explicit Verification Entry Point
Only ONE path exists for protected operations.
All protected operations must pass through `scripts/pax-coder-gate`:
```bash
#!/bin/bash
. /path/to/pax-coder-gate || exit 2
# Protected execution code here
```
No alternate paths. No fallbacks. No degraded modes.
---
## Protected Operations
Currently protected:
1. **generate_release.sh** β Sign an official release
- Requires: Valid capability + private signing key
- Gate: pax-coder-gate enforces capability check
2. **(Future)** Signing other artifacts
- Requires: Valid capability
- Gate: Same pax-coder-gate mechanism
Operations NOT protected (free):
- Verifying integrity (verify-clone)
- Creating node identities (generate_node_key.sh creates identity only, not authorization)
- Reading source code (public clone)
---
## Architecture Invariants
### Invariant 1: Integrity β Authorization
```text
INTEGRITY_VERIFIED does NOT imply AUTHORIZED
INTEGRITY_FAILED prevents all protected execution
AUTHORIZED requires separate capability verification
```
### Invariant 2: Public Clone β Authorization
```text
A public clone:
β Can verify its integrity
β Can create node identities
β Cannot generate authorization
β Cannot create capabilities
β Cannot authorize operations
```
### Invariant 3: External Authority
```text
Authorization is NOT generated by the client.
Authorization REQUIRES signed capability from authority.
The authority's private key is NEVER in the public clone.
```
### Invariant 4: Fail-Closed
```text
Without capability: EXECUTION = DENIED
With invalid capability: EXECUTION = DENIED
With expired capability: EXECUTION = DENIED
With wrong signature: EXECUTION = DENIED
```
---
## Implementation
### Client-Side Gate
File: `scripts/pax-coder-gate`
```bash
# 1. Verify release integrity (free)
./scripts/verify-clone || exit 1
# 2. Check capability presence
if [ -z "$PAX_CAPABILITY_TOKEN" ]; then
echo "DENIED: No capability available"
exit 2
fi
# 3. Parse and validate capability
# - Extract fields from JSON
# - Check expiration time
# - Verify commit match
# - Verify signature format
# 4. Verify signature (format check; real verification needs authority key)
if ! validate_signature "$CAPABILITY_SIGNATURE"; then
echo "DENIED: Signature invalid"
exit 2
fi
# 5. Exit 0 if all checks pass
exit 0
```
### Protected Operation Integration
File: `sovereign/generate_release.sh`
```bash
#!/bin/bash
# Check authorization BEFORE proceeding
if ! "$SCRIPTS_DIR/pax-coder-gate"; then
echo "AUTHORIZATION DENIED"
exit 2
fi
# Protected execution code
echo "Signing release..."
```
### Test Suite
File: `scripts/test_protection_gate.sh`
Tests:
1. β
No capability β denied (exit 2)
2. β
Expired capability β denied
3. β
Invalid signature β denied
4. β
Wrong commit β denied
5. β
Modified release + valid capability β denied (integrity fails first)
6. β
Valid release + valid capability β authorized (exit 0)
---
## Authority Implementation (Future)
The authorization service implementation is out-of-scope for this ADR.
Expected interface:
```text
POST /authorize
Request:
{
"node_id": "...",
"release_id": "1.0.0",
"commit": "...",
"nonce": "..."
}
Response (if authorized):
{
"capability": {
"node_id": "...",
"release_id": "1.0.0",
"commit": "...",
"expires_at": "...",
"nonce": "...",
"signature": "..."
}
}
Response (if not authorized):
{
"error": "Authorization denied",
"reason": "Node not registered"
}
```
---
## Node Status States
### Unregistered
- Has local node identity (node.json)
- No provisioning from authority
- Cannot perform protected operations
### Provisioning Requested
- Contact sent to authority
- Awaiting authority decision
- Cannot perform protected operations yet
### Provisioned
- Authority has accepted node
- Can request authorization capabilities
- Can perform protected operations (with valid capability)
### Revoked
- Authority has revoked provisioning
- All future authorizations denied
- Cannot perform protected operations
---
## Security Properties Enforced by This ADR
β
**Integrity verification is public**
- Anyone can verify a release
- No authorization required
- Fails if files are modified
β
**Authorization requires external authority**
- Cannot be generated locally
- Requires signed capability
- Authority controls who gets access
β
**Protected execution fails closed**
- Missing capability β explicit denial
- Invalid capability β explicit denial
- Expired capability β explicit denial
- No silent corruption
- No degraded mode
β
**Capabilities are time-bound**
- Expire within 1 hour
- Fresh capability required per operation
- Prevents indefinite reuse
β
**Capabilities are commit-bound**
- Tied to specific git commit
- Repository updates invalidate capabilities
- Prevents execution on modified code
---
## Security Properties NOT Enforced
β **Cannot prevent determined modification**
- User controls execution environment
- Binary modification is possible
- Reverse engineering is possible
What we DO achieve:
- Modification is detectable (integrity fails)
- Modification requires more effort (not trivial)
β **Cannot prevent client-side bypass**
- User could edit pax-coder-gate
- But: Modified gate would fail signature verification
- And: Would have to manually invoke protected operation
What we DO achieve:
- Tampering is obvious
- Automated tools are blocked
---
## Decisions Made
### Decision 1: External Authority Only
**Rejected:** Client-side self-authorization (shell conditionals, local keys)
**Accepted:** External authority with signed capabilities
**Rationale:** Software on a user-controlled machine cannot enforce authorization. Only external authority can.
### Decision 2: Short-Lived Capabilities
**Rejected:** Long-lived tokens, persistent authorization
**Accepted:** 1-hour expiration, fresh capability per operation
**Rationale:** Reduces window of capability misuse. Compromised capability expires quickly.
### Decision 3: Commit Binding
**Rejected:** Authorization valid for any code version
**Accepted:** Capability tied to specific release commit
**Rationale:** Prevents using old capability on new code. Authorization is release-specific.
### Decision 4: Fail-Closed Behavior
**Rejected:** Degraded mode, silent fallback, corrupted output
**Accepted:** Explicit error, no execution without authorization
**Rationale:** Impossible to accidentally run protected code unauthorized. Error is clear.
---
## Consequences
### Positive
β
Real authorization boundary exists
β
Cannot fake authorization locally
β
Cannot accidentally execute without authority consent
β
Time-bound reduces reuse window
β
Clear separation: integrity vs authorization
### Negative / Tradeoffs
β Requires external authorization service
β More complex than shell conditionals
β Operational overhead: managing capabilities, revocation
### Mitigation
- Authorization service can be simple (even email-based initially)
- Short expiration reduces operational burden
- Clear audit trail of capability grants
---
## Testing
All test cases pass:
```
β
VALID RELEASE + VALID CAPABILITY β AUTHORIZED
β
VALID RELEASE + NO CAPABILITY β DENIED (exit 2)
β
VALID RELEASE + EXPIRED CAPABILITY β DENIED (exit 2)
β
VALID RELEASE + INVALID SIGNATURE β DENIED (exit 2)
β
VALID RELEASE + WRONG COMMIT β DENIED (exit 2)
β
MODIFIED RELEASE + VALID CAPABILITY β DENIED (exit 1, integrity fails)
```
---
## References
- ADR-0001: Public Clone Integrity (integrity verification)
- ADR-0002: Authorization Boundary (subsumed by this ADR)
- ADR-0003: Fail-Closed Enforcement (exit codes, explicit errors)
- ADR-0004: Private Key Separation (private signing key never in clone)
- ADR-0006: Server Challenge Protocol (future authorization service design)
- ADR-0007: Codex Security Preservation (CI validation)
---
## Related Files
- `scripts/pax-coder-gate` β Authoritative verification entry point
- `scripts/verify-pax-coder` β Security status report
- `scripts/test_protection_gate.sh` β Test suite
- `sovereign/generate_release.sh` β Protected operation (signs releases)
- `sovereign/generate_node_key.sh` β Unprotected (creates identities only)
---
**Status:** Accepted and implemented
**Date:** 2026-08-18
**Commit:** 59abfa0 (removal of fake gate) + d4e52da (real gate implementation)
|