systemprompt-security 0.0.11

Security module for systemprompt.io - authentication, authorization, JWT, and token extraction
Documentation
# systemprompt-security Compliance

**Layer:** Infrastructure
**Reviewed:** 2026-01-21
**Verdict:** COMPLIANT

---

## Checklist

| Category | Status |
|----------|--------|
| Boundary Rules ||
| Required Structure ||
| Code Quality ||

---

## Violations Found and Fixed

| File | Line | Violation | Category | Status |
|------|------|-----------|----------|--------|
| `session/generator.rs` | 42-46 | Hardcoded Admin permissions for all sessions | Security | Fixed |
| `extraction/token.rs` | 109 | Token not trimmed (whitespace vulnerability) | Security | Fixed |
| `extraction/token.rs` | 103-105 | Silent error skipping non-UTF8 headers | Silent Error | Fixed |
| `auth/validation.rs` | 64 | `.ok()` silently swallows `to_str()` errors | Silent Error | Fixed |
| `auth/validation.rs` | 53 | `map_or_else(\|_\|)` silently ignores validation errors | Silent Error | Fixed |
| `extraction/header.rs` | 32 | `.ok()` silently swallows `to_str()` errors | Silent Error | Fixed |
| `extraction/header.rs` | 48+ | `Result<(), ()>` uninformative error type | Code Quality | Fixed |
| `services/scanner.rs` | 78 | Duplicate "masscan" check | Code Quality | Fixed |
| Multiple files | Various | Magic numbers/strings not constants | Code Quality | Fixed |

---

## Remediation Summary

1. **SessionGenerator** - Now accepts `user_type`, `permissions`, `roles`, and `rate_limit_tier` as parameters instead of hardcoding Admin
2. **Token extraction** - Tokens are now properly trimmed before use
3. **Silent errors** - Added `tracing::debug!` logging before all error-to-option conversions
4. **HeaderInjector** - Created proper `HeaderInjectionError` type with Display and Error implementations
5. **Constants** - All magic numbers and strings moved to named constants

---

## Commands Run

```
cargo clippy -p systemprompt-security -- -D warnings  # PASS
cargo fmt -p systemprompt-security -- --check          # PASS
cargo build -p systemprompt-security                   # PASS
```

---

## Actions Required

None - fully compliant and production ready.