PWNISMS — Security-First Threat Modelling
For EVERY security-relevant task (feature, bug fix, refactor, infra change, architecture design), run a threat model with PWNISMS.
- Walk through all 7 categories explicitly.
- If a category is not applicable, state it briefly and move on.
- Anchor analysis to linked files, diffs, PRs, API specs, and diagrams whenever available.
- Focus on realistic threats for the current context, not exhaustive attack catalogs.
Phase 0 — Guardrail Context
Before deep analysis, ensure the project-specific guardrail shortlist exists:
- Use
{{GUARDRAILS_SELECTION_SKILL_DIR}}/SKILL.md.
- Resolve the project with
find_project_by_name using name="<SRAI_PROJECT_NAME>".
- Call
get_guardrails, shortlist intentionally for this task, then hydrate the exact shortlist with get_guardrail_by_id.
- Keep the shortlisted existing guardrails in context for implementation and the final VibeReview markdown sync.
Do not perform project-profile exploration as part of PWNISMS. The old profile tools are not part of this workflow. Ground the threat model in the user request, repository code, diffs, architecture docs the user provides, and the shortlisted guardrails.
If SRAI is not available, proceed with the user-provided context and repository evidence, then clearly note that project guardrails could not be fetched.
Phase 1 — Inputs to Gather
Collect these quickly before deep analysis:
- Scope: What is changing (feature, component, service, migration, PR)?
- Assets: What must be protected (PII, credentials, tokens, configs, accounts, workflows)?
- Entry points: How data enters/leaves (HTTP, queues, schedulers, CLI, webhooks, integrations)?
- Trust boundaries: Where data crosses users/services/networks/privilege levels?
- Existing guardrails: What shortlisted project-specific dos and don'ts apply (from Phase 0)?
If the user provided specific code, diffs, or architecture artifacts, prioritize those as primary evidence.
Phase 2 — Lightweight Workflow (PWNISMS)
Clarify scope and assumptions
- Define the exact unit of analysis.
- State assumptions explicitly (auth model, deployment boundary, tenant model, etc.).
Map assets and flows
- List high-value assets and critical data paths.
- List entry points and exits across trust boundaries.
- Note which assets are covered by existing guardrails and which are not.
Walk all 7 PWNISMS categories
- Identify plausible threats for each category.
- Keep findings concrete and contextual.
- For each threat, check if an existing guardrail already addresses it.
Prioritize
- Select the top 3-7 risks by impact and likelihood.
- Factor in existing mitigations from the codebase, user-provided context, and guardrails.
Mitigate
- Propose concrete, implementable controls for each prioritized risk.
- Map mitigations to specific guardrails where applicable.
- If a mitigation represents a recurring pattern, propose it as a new guardrail candidate.
Summarize residual risk
- Call out remaining risk, trade-offs, and follow-up actions.
- Call out unknowns instead of silently guessing.
- Note guardrail gaps — security patterns not yet captured by any guardrail.
The 7 Categories (What to Check)
P — Product
Application and business-logic threats:
- Input validation, injection, insecure deserialization.
- Authorization gaps, privilege escalation, IDOR/BOLA.
- Business logic abuse, replay/race conditions, unsafe redirects.
- Error handling that leaks internals.
- Guardrail check: Are there
must / must_not rules for input validation, authorization patterns, error handling?
W — Workload
Compute and infrastructure threats:
- Insecure container/runtime posture, over-privileged workload identity.
- Weak host/orchestrator controls and segmentation.
- Insecure data storage/backups and DB configuration.
- Queue/broker abuse and poison-message handling gaps.
- Guardrail check: Are there rules for container security, data-at-rest encryption, workload identity?
N — Network
Network and transport threats:
- Missing/weak TLS, insecure service-to-service communication.
- Exposed ports/endpoints and permissive ingress/egress.
- Weak segmentation or lateral movement paths.
- API-layer abuse controls missing (rate limits, request limits, CORS hardening).
- Guardrail check: Are there rules for TLS enforcement, CORS policy, rate limiting?
I — IAM (Identity & Access Management)
Identity and authorization threats:
- Broken authentication controls and token validation.
- Missing least-privilege RBAC/ABAC.
- Service-to-service auth gaps.
- Escalation paths across users, roles, or services.
- Guardrail check: Are there rules for auth mechanisms, session management, privilege boundaries?
S — Secrets
Credential and key management threats:
- Secrets in code, images, logs, CI output, or defaults.
- Weak rotation, revocation, or token lifetime policies.
- Over-shared secrets across components.
- Missing secret manager/KMS controls.
- Guardrail check: Are there
must_not rules against hardcoded secrets, must rules for secret manager usage?
M — Monitoring (Logging & Observability)
Detection and auditability threats:
- Missing logs for auth, authorization, admin/data access events.
- Sensitive data leakage in logs.
- Missing alerts for abuse indicators.
- Incomplete audit trails or weak log integrity.
- Guardrail check: Are there rules for what must be logged and what must not appear in logs?
S — Supply Chain
Dependency and delivery threats:
- Unpinned/unverified dependencies and vulnerable packages.
- Third-party integration trust and scope overreach.
- CI/CD pipeline leakage or unreviewed build scripts.
- Unsigned/unprovenanced artifacts, missing SBOM.
- Treat AI-generated code as untrusted until validated.
- Guardrail check: Are there rules for dependency pinning, SBOM generation, artifact signing?
Phase 3 — Guardrail Enforcement (Secure by Code)
After completing the PWNISMS analysis and before writing code:
- Review the shortlisted hydrated guardrails produced by
{{GUARDRAILS_SELECTION_SKILL_DIR}}/SKILL.md.
- Classify applicability — For each shortlisted guardrail, determine if it applies to the current task.
- Apply during code generation:
must rules → mandatory implementation requirements. Every applicable must guardrail must be satisfied.
must_not rules → hard prohibitions. Code must never violate an applicable must_not guardrail.
- Flag conflicts — If a guardrail conflicts with the user's explicit instruction, flag it and ask for confirmation.
- Create new guardrails on the fly — When PWNISMS analysis or code review reveals a recurring security pattern not captured by existing guardrails, create and apply it as a new guardrail (marked
source: "ide_generated" in the VibeReview markdown). Include title, rule_type (must/must_not), category, instruction, and rationale in the notes.
Phase 4 — Security-First Code Generation Rules
When implementing code, enforce these baseline controls alongside project guardrails:
- Validate and constrain all untrusted input.
- Parameterize all queries and command-like invocations.
- Enforce least privilege for users, services, and workloads.
- Never hardcode secrets; use managed secret stores.
- Encrypt sensitive data in transit and at rest.
- Log security-relevant actions without leaking secrets/PII.
- Pin and verify dependencies and build artifacts.
- Return safe user errors; keep sensitive diagnostics internal.
- Add abuse protections (rate limits, lockouts, throttling) on exposed interfaces.
Tailor for Architecture / Design Tasks
When discussing designs before code exists:
- Sketch a mental data flow: actors, data sent/received, storage, processing points.
- Mark trust boundaries explicitly (client-backend, backend-DB, service-service, cloud-third party).
- Identify where strong authentication/authorization is mandatory.
- Identify where encryption in transit and at rest is mandatory.
- Recommend concrete security patterns:
- Parameterized queries / ORM for DB access.
- Centralized authn/authz and role checks.
- Secrets manager / KMS for credentials and keys.
- mTLS or signed requests for service-to-service calls.
- Review existing guardrails for design-level constraints.
Phase 5 — VibeReview Sync (Post Threat Modelling)
MANDATORY: After every threat modeling step that produces or modifies threat content, the main agent must update the vibereview/*.md artifact and call sync_ai_ide_markdown directly.
What triggers the VibeReview sync
- New threat model generated (any form: scenarios, data flows, attack trees, PWNISMS analysis)
- Existing threat model updated or extended (new threats, refined mitigations, additional components)
- Guardrails applied during a code-generation task (existing or IDE-generated)
What the VibeReview markdown must contain
The main agent writes a structured .md artifact under vibereview/ and uploads it through sync_ai_ide_markdown. That markdown should contain:
- Threat model findings: threats mitigated, PWNISMS categories, severities, mitigations applied
- Best practices achieved: structured practice entries with
practice_name, description, and category
- Secure code snippets: security-relevant code with explanations
- Guardrails applied: all guardrails enforced during this session — both existing ones shortlisted earlier via
get_guardrails + get_guardrail_by_id (source: "existing") and new ones the IDE agent created on the fly (source: "ide_generated"), each with satisfaction status
- Workflow metadata:
chat_session_id, event_name or title, required summary, and optional workflow_name / workflow_description
How to sync
- Read and follow
{{VIBEREVIEW_SYNC_SKILL_DIR}}/SKILL.md.
- Write or update a file under
vibereview/, ideally vibereview/<chat_session_id>-<slugified-title-or-event-name>.md.
- Put
chat_session_id, summary, and either title or event_name in frontmatter.
- Include the required sections:
Best Practices Achieved
Threats Mitigated
Secure Code Snippets
Guardrails Applied
OWASP Top 10 2025 Mappings
- Validate that:
- every threat entry includes
threat_name, pwnisms_category, severity, and mitigation_applied
- every best-practice entry includes
practice_name, description, and category
- every guardrail includes
title, rule_type, source, and satisfied
- OWASP mappings use exact IDs and names
- snippets are grounded in actual code, not invented text
- no sibling
.md files in vibereview/ were read just to infer format or content
- Call
sync_ai_ide_markdown directly with the finished markdown artifact.
- If sync fails, leave the artifact in
vibereview/ and report the failure clearly.
Post-Generation Checklist
Before finalizing output, confirm:
If ANY box cannot be checked, you MUST flag the gap to the user with a specific remediation recommendation before finalizing the code.
1---2name: pwnisms-threat-modelling3description: Security-first threat modelling workflow for code and architecture tasks. Walks all 7 PWNISMS categories, enforces vibe guardrails (secure by code), and synchronizes findings via a direct VibeReview markdown sync. Use before, during, and after implementation.4---56# PWNISMS — Security-First Threat Modelling78For EVERY security-relevant task (feature, bug fix, refactor, infra change, architecture design), run a threat model with PWNISMS.910- Walk through all 7 categories explicitly.11- If a category is not applicable, state it briefly and move on.12- Anchor analysis to linked files, diffs, PRs, API specs, and diagrams whenever available.13- Focus on realistic threats for the current context, not exhaustive attack catalogs.1415---1617## Phase 0 — Guardrail Context1819Before deep analysis, ensure the project-specific guardrail shortlist exists:20211. Use `{{GUARDRAILS_SELECTION_SKILL_DIR}}/SKILL.md`.222. Resolve the project with `find_project_by_name` using `name="<SRAI_PROJECT_NAME>"`.233. Call `get_guardrails`, shortlist intentionally for this task, then hydrate the exact shortlist with `get_guardrail_by_id`.244. Keep the shortlisted existing guardrails in context for implementation and the final VibeReview markdown sync.2526Do not perform project-profile exploration as part of PWNISMS. The old profile tools are not part of this workflow. Ground the threat model in the user request, repository code, diffs, architecture docs the user provides, and the shortlisted guardrails.2728If SRAI is not available, proceed with the user-provided context and repository evidence, then clearly note that project guardrails could not be fetched.2930---3132## Phase 1 — Inputs to Gather3334Collect these quickly before deep analysis:3536- **Scope**: What is changing (feature, component, service, migration, PR)?37- **Assets**: What must be protected (PII, credentials, tokens, configs, accounts, workflows)?38- **Entry points**: How data enters/leaves (HTTP, queues, schedulers, CLI, webhooks, integrations)?39- **Trust boundaries**: Where data crosses users/services/networks/privilege levels?40- **Existing guardrails**: What shortlisted project-specific dos and don'ts apply (from Phase 0)?4142If the user provided specific code, diffs, or architecture artifacts, prioritize those as primary evidence.4344---4546## Phase 2 — Lightweight Workflow (PWNISMS)47481. **Clarify scope and assumptions**49 - Define the exact unit of analysis.50 - State assumptions explicitly (auth model, deployment boundary, tenant model, etc.).51522. **Map assets and flows**53 - List high-value assets and critical data paths.54 - List entry points and exits across trust boundaries.55 - Note which assets are covered by existing guardrails and which are not.56573. **Walk all 7 PWNISMS categories**58 - Identify plausible threats for each category.59 - Keep findings concrete and contextual.60 - For each threat, check if an existing guardrail already addresses it.61624. **Prioritize**63 - Select the top 3-7 risks by impact and likelihood.64 - Factor in existing mitigations from the codebase, user-provided context, and guardrails.65665. **Mitigate**67 - Propose concrete, implementable controls for each prioritized risk.68 - Map mitigations to specific guardrails where applicable.69 - If a mitigation represents a recurring pattern, propose it as a new guardrail candidate.70716. **Summarize residual risk**72 - Call out remaining risk, trade-offs, and follow-up actions.73 - Call out unknowns instead of silently guessing.74 - Note guardrail gaps — security patterns not yet captured by any guardrail.7576---7778## The 7 Categories (What to Check)7980### P — Product8182Application and business-logic threats:8384- Input validation, injection, insecure deserialization.85- Authorization gaps, privilege escalation, IDOR/BOLA.86- Business logic abuse, replay/race conditions, unsafe redirects.87- Error handling that leaks internals.88- **Guardrail check:** Are there `must` / `must_not` rules for input validation, authorization patterns, error handling?8990### W — Workload9192Compute and infrastructure threats:9394- Insecure container/runtime posture, over-privileged workload identity.95- Weak host/orchestrator controls and segmentation.96- Insecure data storage/backups and DB configuration.97- Queue/broker abuse and poison-message handling gaps.98- **Guardrail check:** Are there rules for container security, data-at-rest encryption, workload identity?99100### N — Network101102Network and transport threats:103104- Missing/weak TLS, insecure service-to-service communication.105- Exposed ports/endpoints and permissive ingress/egress.106- Weak segmentation or lateral movement paths.107- API-layer abuse controls missing (rate limits, request limits, CORS hardening).108- **Guardrail check:** Are there rules for TLS enforcement, CORS policy, rate limiting?109110### I — IAM (Identity & Access Management)111112Identity and authorization threats:113114- Broken authentication controls and token validation.115- Missing least-privilege RBAC/ABAC.116- Service-to-service auth gaps.117- Escalation paths across users, roles, or services.118- **Guardrail check:** Are there rules for auth mechanisms, session management, privilege boundaries?119120### S — Secrets121122Credential and key management threats:123124- Secrets in code, images, logs, CI output, or defaults.125- Weak rotation, revocation, or token lifetime policies.126- Over-shared secrets across components.127- Missing secret manager/KMS controls.128- **Guardrail check:** Are there `must_not` rules against hardcoded secrets, `must` rules for secret manager usage?129130### M — Monitoring (Logging & Observability)131132Detection and auditability threats:133134- Missing logs for auth, authorization, admin/data access events.135- Sensitive data leakage in logs.136- Missing alerts for abuse indicators.137- Incomplete audit trails or weak log integrity.138- **Guardrail check:** Are there rules for what must be logged and what must not appear in logs?139140### S — Supply Chain141142Dependency and delivery threats:143144- Unpinned/unverified dependencies and vulnerable packages.145- Third-party integration trust and scope overreach.146- CI/CD pipeline leakage or unreviewed build scripts.147- Unsigned/unprovenanced artifacts, missing SBOM.148- Treat AI-generated code as untrusted until validated.149- **Guardrail check:** Are there rules for dependency pinning, SBOM generation, artifact signing?150151---152153## Phase 3 — Guardrail Enforcement (Secure by Code)154155After completing the PWNISMS analysis and before writing code:1561571. **Review the shortlisted hydrated guardrails** produced by `{{GUARDRAILS_SELECTION_SKILL_DIR}}/SKILL.md`.1582. **Classify applicability** — For each shortlisted guardrail, determine if it applies to the current task.1593. **Apply during code generation:**160 - `must` rules → mandatory implementation requirements. Every applicable `must` guardrail must be satisfied.161 - `must_not` rules → hard prohibitions. Code must never violate an applicable `must_not` guardrail.1624. **Flag conflicts** — If a guardrail conflicts with the user's explicit instruction, flag it and ask for confirmation.1635. **Create new guardrails on the fly** — When PWNISMS analysis or code review reveals a recurring security pattern not captured by existing guardrails, create and apply it as a new guardrail (marked `source: "ide_generated"` in the VibeReview markdown). Include `title`, `rule_type` (must/must_not), `category`, `instruction`, and rationale in the notes.164165---166167## Phase 4 — Security-First Code Generation Rules168169When implementing code, enforce these baseline controls alongside project guardrails:1701711. Validate and constrain all untrusted input.1722. Parameterize all queries and command-like invocations.1733. Enforce least privilege for users, services, and workloads.1744. Never hardcode secrets; use managed secret stores.1755. Encrypt sensitive data in transit and at rest.1766. Log security-relevant actions without leaking secrets/PII.1777. Pin and verify dependencies and build artifacts.1788. Return safe user errors; keep sensitive diagnostics internal.1799. Add abuse protections (rate limits, lockouts, throttling) on exposed interfaces.180181---182183## Tailor for Architecture / Design Tasks184185When discussing designs before code exists:186187- Sketch a mental data flow: actors, data sent/received, storage, processing points.188- Mark trust boundaries explicitly (client-backend, backend-DB, service-service, cloud-third party).189- Identify where strong authentication/authorization is mandatory.190- Identify where encryption in transit and at rest is mandatory.191- Recommend concrete security patterns:192 - Parameterized queries / ORM for DB access.193 - Centralized authn/authz and role checks.194 - Secrets manager / KMS for credentials and keys.195 - mTLS or signed requests for service-to-service calls.196- Review existing guardrails for design-level constraints.197198---199200## Phase 5 — VibeReview Sync (Post Threat Modelling)201202**MANDATORY:** After every threat modeling step that produces or modifies threat content, the main agent must update the `vibereview/*.md` artifact and call `sync_ai_ide_markdown` directly.203204### What triggers the VibeReview sync205206- New threat model generated (any form: scenarios, data flows, attack trees, PWNISMS analysis)207- Existing threat model updated or extended (new threats, refined mitigations, additional components)208- Guardrails applied during a code-generation task (existing or IDE-generated)209210### What the VibeReview markdown must contain211212The main agent writes a structured `.md` artifact under `vibereview/` and uploads it through `sync_ai_ide_markdown`. That markdown should contain:213214- **Threat model findings**: threats mitigated, PWNISMS categories, severities, mitigations applied215- **Best practices achieved**: structured practice entries with `practice_name`, `description`, and `category`216- **Secure code snippets**: security-relevant code with explanations217- **Guardrails applied**: all guardrails enforced during this session — both existing ones shortlisted earlier via `get_guardrails` + `get_guardrail_by_id` (`source: "existing"`) and new ones the IDE agent created on the fly (`source: "ide_generated"`), each with satisfaction status218- **Workflow metadata**: `chat_session_id`, `event_name` or `title`, required `summary`, and optional `workflow_name` / `workflow_description`219220### How to sync2212221. Read and follow `{{VIBEREVIEW_SYNC_SKILL_DIR}}/SKILL.md`.2232. Write or update a file under `vibereview/`, ideally `vibereview/<chat_session_id>-<slugified-title-or-event-name>.md`.2243. Put `chat_session_id`, `summary`, and either `title` or `event_name` in frontmatter.2254. Include the required sections:226 - `Best Practices Achieved`227 - `Threats Mitigated`228 - `Secure Code Snippets`229 - `Guardrails Applied`230 - `OWASP Top 10 2025 Mappings`2315. Validate that:232 - every threat entry includes `threat_name`, `pwnisms_category`, `severity`, and `mitigation_applied`233 - every best-practice entry includes `practice_name`, `description`, and `category`234 - every guardrail includes `title`, `rule_type`, `source`, and `satisfied`235 - OWASP mappings use exact IDs and names236 - snippets are grounded in actual code, not invented text237 - no sibling `.md` files in `vibereview/` were read just to infer format or content2386. Call `sync_ai_ide_markdown` directly with the finished markdown artifact.2397. If sync fails, leave the artifact in `vibereview/` and report the failure clearly.240241---242243## Post-Generation Checklist244245Before finalizing output, confirm:246247- [ ] Scope, assumptions, and trust boundaries were explicit.248- [ ] All 7 PWNISMS categories were checked (or marked N/A explicitly).249- [ ] Top risks were prioritized by impact and likelihood.250- [ ] Mitigations are concrete and actionable.251- [ ] Residual risk and follow-up actions are stated.252- [ ] Vibe guardrails were fetched and enforced (all applicable `must`/`must_not` rules satisfied).253- [ ] Guardrail compliance summary is included in the response (existing + IDE-generated).254- [ ] The VibeReview markdown was written under `vibereview/` and `sync_ai_ide_markdown` was called successfully.255256If ANY box cannot be checked, you MUST flag the gap to the user with a specific remediation recommendation before finalizing the code.