Shield V2
Rusakov Shield posture, response sanitization, sealed env, and CleverCase shield.yaml
Shield V2 (Rusakov Shield)
CleverCase runs under Rusakov Shield V2 — a tenant posture engine that seals secrets in memory, sanitizes API responses, detects prompt attacks, and enforces legal compliance (SOC 2, HIPAA, ABA 1.6/5.4). The canonical tenant posture lives in packages/rak-plugin-clevercase/shield.yaml and extends the platform legal vertical preset.
sanitizeApiResponse
Customer-facing routes must pass payloads through sanitizeApiResponse() from @rakontevr/shield (vendor: vendor/rakontevr/shield/src/sanitizer.ts). The sanitizer strips:
- Internal orchestration metadata (
_executionPath,_provider,_modelId) - Stack traces and
internalTracefields - Sealed key values (connection strings, bearer tokens, API keys)
CleverCase shield.yaml enables sanitizeResponses: true and defines an inline sanitizer policy with key deny-lists and regex patterns for Postgres URLs, Bearer tokens, OpenAI/Anthropic keys, and CC_MSO_* keys.
import { sanitizeApiResponse } from "@rakontevr/shield";
export async function GET() {
const raw = await fetchUpstream();
return NextResponse.json(sanitizeApiResponse(await raw.json()));
}responseSanitization toggles in shield.yaml:
| Toggle | Effect |
|---|---|
stripExecutionPaths | Remove inference routing paths |
stripProviderMetadata | Hide provider names |
stripModelIds | Hide internal model identifiers |
stripInternalTraces | Remove debug trace blobs |
allowPublicErrors | false — generic errors only |
Sealed environment
bootstrapSealedEnv encrypts sensitive env vars in worker memory at boot. CleverCase sealed keys:
| Key | Purpose |
|---|---|
DATABASE_URL | Cluster Postgres connection |
REDIS_AI_URL | Job queues / worker heartbeats |
RAK_GATEWAY_SERVICE_KEY | Gateway M2M auth |
RAKONTEVR_SERVICE_KEY | BuilderHub proxy auth |
JWT_SECRET | Session signing |
OPENAI_API_KEY / ANTHROPIC_API_KEY | Cloud inference |
CC_MSO_MASTER_KEY | MSO admin operations |
Agents and logs must never echo sealed values. Use sealedEnvGet() server-side only; never serialize sealed keys into API responses or MCP tool output.
Posture engine
bootstrapShieldFromYaml loads tenant posture and merges with platform defaults via mergeShieldPosture. Surfaces enabled for CleverCase:
worker— background jobs and inference workersgateway— RSP gateway completionsmcp— Cursor MCP tool catalogsdk—@rakontevr/sdkclient calls
getShieldSurfaceConfig(surface) returns per-surface sanitizer, attack detection, and agent shield policies. CleverCase shield posture name: clevercase.
Attack detection
detectPromptAttack scores inbound prompts against a corpus of injection/jailbreak templates. CleverCase thresholds:
| Level | Score |
|---|---|
| critical | 8.0 |
| high | 6.0 |
| medium | 4.0 |
Settings: attackDetection.enabled: true, logOnly: false, learnFromBlocks: true. Blocked attacks are logged to audit tables without exposing attack text in client responses.
Agent shield
guardAgentAction enforces per-tool rate limits and a blocked-tool list. CleverCase blocks destructive agent tools:
drop_table,delete_case,purge_trust_account,export_all_clients
Rate limits: 10 calls per tool per minute, 100 global per minute.
CleverCase shield.yaml highlights
extends:
- legal
compliance:
standards: [soc2, hipaa, aba-1.6, aba-5.4]
dataClassification: legal-privileged
requireNimPiiScan: true
cloudOffloadRequiresMasking: true
piiEntities:
- case_number
- attorney_bar_number
- client_matter_id
- trust_account_number
ragDefense:
enabled: true
stripInstructionPatterns: true
requireUntrustedEnvelope: trueMSO content-blind (ABA 5.4)
MSO admin views return aggregates only — counts and billing rollups, never cross-firm matter narratives. RLS and tenant_sharing_grants scope conflicts-index for blind conflict matching.
Cloud offload masking
When legal text routes to external inference (allowCloudOffload: true), cloudOffloadRequiresMasking: true requires NIM PII scan/mask before offload.
Verification
| Check | Command |
|---|---|
| Shield status | clevercase shield status |
| Shield audit | clevercase shield audit |
| BDD compliance | packages/rak-plugin-clevercase/src/__tests__/shield-compliance.bdd.test.ts |
Related
docs/RUSAKOV-SHIELD-TENANT.mdpackages/rak-plugin-clevercase/rak-plugin.json→shieldblock- Rakontevr SDK