Designed to defend, not just observe
governance-sdk enforces before execution — not after. Every design decision prioritizes security: zero dependencies, no network calls, append-only audits, and 64+ injection patterns blocking the attacks that are happening right now in production AI deployments.
Security principles
Enforcement is entirely in-process. No calls to external services, no telemetry, no phone-home. Your agent's decisions never leave your runtime.
The entire SDK is statically analyzable. No eval(), no new Function(), no dynamic imports that could be hijacked. Works safely in edge runtimes.
Audit events are written and never modified. The HMAC chain means deletion is detected — you can't silently erase a decision from the audit trail.
The HMAC signing key is provided by you at startup. It never leaves your environment. Rotate it without breaking historical chain verification.
No supply chain attack surface. The entire governance enforcement path is first-party code. Nothing from npm can compromise your governance layer.
Shipped as TypeScript source with full type safety. You can audit exactly what runs. No minified bundles with hidden behavior.
64+-pattern injection detection
Run on every user-provided string before it reaches the agent. Categories allow targeted response — block all vs log only vs require approval.
Attempts to replace or nullify the agent's original system prompt or instructions.
ignore_previous_instructionsdisregard_system_promptoverride_withforget_everythingnew_instructionsForces the agent to adopt a different persona, often one without safety constraints.
you_are_nowpretend_you_areact_as_ifswitch_to_modeInstructs the agent to send internal data, credentials, or prompts to attacker-controlled endpoints.
send_to_externalexport_data_toforward_contentsleak_promptEmbeds OS or interpreter commands inside user input, hoping they execute in the agent's context.
execute_commandrun_shellsystem_callexec_Overrides the agent's stated objectives with attacker-defined goals.
your_real_goal_isprimary_objectivesecret_missionAttempts to extract the agent's system prompt, revealing business logic or credentials.
repeat_your_instructionsshow_your_system_promptThreat model
Six threat categories with mitigations in governance-sdk v0.5.0.
detectInjection() on all user-sourced strings64+ patterns across 7 categoriesCategory-aware blocking (override vs exfil vs role-switch)blockTools() — exact or glob matchrequireLevel() — governance score gaterequireSequence() — must complete prerequisite tools firstkill() / killAll() at priority 999rateLimit() per hour/daytokenBudget() hard capHMAC-SHA256 hash chainchain.verify() detects any modificationbrokenAt reports exact tamper locationrequireApproval() — human-in-the-loop gatetimeWindow() — restrict to business hoursrequireLevel(4+) for sensitive namespacesZero runtime dependenciesFirst-party enforcement code onlyStatically analyzable — no eval()Responsible Disclosure
Found a security issue in governance-sdk? Please report it privately via GitHub Security Advisories before public disclosure. We target a 72-hour initial response for all reports.