| name | security-review |
| description | 10-category security checklist for agent-core: secrets, input validation, sandbox, and prompt injection. |
Security Review
Comprehensive security checklist for agent-core. Run through all 10
categories before any security-sensitive change or PR.
See .claude/rules/python/security.md for tool-specific guidance (bandit, pip-audit).
See .claude/rules/security.md for credential, sandbox, and shell execution rules.
1. Secrets Management
Rule: Credentials never enter source code.
API_KEY = "sk-1234567890abcdef"
import os
API_KEY = os.getenv("OPENAI_API_KEY")
2. Input Validation
Rule: Validate all external input before use.
For sys_operation:
from openjiuwen.core.common.security import safe_path
def execute_command(user_path: str, working_dir: Path) -> None:
validated = safe_path(user_path, allowed_base=working_dir)
if validated is None:
raise SecurityError(f"Path outside allowed scope: {user_path}")
3. SQL Injection
Rule: Use parameterized queries for all database operations.
cursor.execute(f"SELECT * FROM {table_name} WHERE id = {user_id}")
cursor.execute(
"SELECT * FROM sessions WHERE id = ?",
(session_id,)
)
4. Authentication and RBAC
Rule: Access control must be enforced server-side, not just client-side.
5. Prompt Injection
Rule: openjiuwen/harness/prompts/ must guard against injected user content.
Prompt injection is agent-core's most unique security concern. Attackers may
try to inject instructions into conversation history to manipulate agent behavior:
system_prompt = f"You are a helpful assistant. User said: {user_message}"
system_prompt = SYSTEM_INSTRUCTIONS
context = {
"user_message": sanitize_for_display(user_message),
"conversation_history": conversation,
}
6. CSRF / Request Validation
Rule: All mutating requests include validation.
7. Rate Limiting
Rule: Protect core/runner/ and core/runner/ resources from exhaustion.
8. Sensitive Data in Logs
Rule: Logs must not expose credentials, tokens, or sensitive data.
logger.info(f"Authenticated user {user_id} with token {token}")
logger.info("User authenticated", extra={"user_id": user_id})
9. Dependency Security
Rule: All dependencies scanned before merging PRs.
pip-audit
bandit -r openjiuwen/ -ll
10. Sandbox Isolation
Rule: core/sys_operation/sandbox/ must provide genuine isolation.
For sandbox implementations, verify:
def sandbox_read(path: Path, allowed_base: Path) -> str:
resolved = (allowed_base / path).resolve()
if not resolved.is_relative_to(allowed_base):
raise SecurityError(f"Escape attempt: {path}")
return resolved.read_text()
Pre-Review Checklist
Before marking a security-sensitive PR as ready for review, run through
all 10 categories above. Document the review in the PR description:
Security Review
===============
Secrets: PASS (no hardcoded credentials)
Input Val: PASS (safe_path used for all user paths)
SQL Injection: PASS (parameterized queries only)
Auth/RBAC: PASS (guardrails enforce permissions)
Prompt Inject: PASS (user content isolated from system prompts)
CSRF: PASS (session IDs are non-guessable)
Rate Limiting: PASS (resource_mgr enforces limits)
Log Safety: PASS (no credentials in structured logs)
Dependencies: PASS (bandit + pip-audit clean)
Sandbox: PASS (path scoping verified)
For changes to core/security/, core/sys_operation/, or
openjiuwen/extensions/sys_operation/sandbox/, request a dedicated
security review from a second reviewer.