PWNISMS — On-the-Go Threat Modelling
For EVERY security-relevant task (feature, bug fix, refactor, infra change, architecture design), run a lightweight 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.
Inputs to Gather First
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?
If the user provided specific code, diffs, or architecture artifacts, prioritize those as primary evidence.
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.
- Walk all 7 PWNISMS categories
- Identify plausible threats for each category.
- Keep findings concrete and contextual.
- Prioritize
- Select the top 3-7 risks by impact and likelihood.
- Mitigate
- Propose concrete, implementable controls for each prioritized risk.
- Summarize residual risk
- Call out remaining risk, trade-offs, and follow-up actions.
- Call out unknowns instead of silently guessing.
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.
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.
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).
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.
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.
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.
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.
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.
Security-First Code Generation Rules
When implementing code, enforce these baseline controls:
- 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.
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-modelling-23description: Lightweight, security-first threat modelling workflow for code and architecture tasks. Use it to walk all 7 PWNISMS categories, identify plausible threats, prioritize top risks, and propose concrete mitigations before and during implementation.4---56# PWNISMS — On-the-Go Threat Modelling78For EVERY security-relevant task (feature, bug fix, refactor, infra change, architecture design), run a lightweight 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## Inputs to Gather First1819Collect these quickly before deep analysis:2021- **Scope**: What is changing (feature, component, service, migration, PR)?22- **Assets**: What must be protected (PII, credentials, tokens, configs, accounts, workflows)?23- **Entry points**: How data enters/leaves (HTTP, queues, schedulers, CLI, webhooks, integrations)?24- **Trust boundaries**: Where data crosses users/services/networks/privilege levels?2526If the user provided specific code, diffs, or architecture artifacts, prioritize those as primary evidence.2728---2930## Lightweight Workflow (PWNISMS)31321. **Clarify scope and assumptions**33 - Define the exact unit of analysis.34 - State assumptions explicitly (auth model, deployment boundary, tenant model, etc.).352. **Map assets and flows**36 - List high-value assets and critical data paths.37 - List entry points and exits across trust boundaries.383. **Walk all 7 PWNISMS categories**39 - Identify plausible threats for each category.40 - Keep findings concrete and contextual.414. **Prioritize**42 - Select the top 3-7 risks by impact and likelihood.435. **Mitigate**44 - Propose concrete, implementable controls for each prioritized risk.456. **Summarize residual risk**46 - Call out remaining risk, trade-offs, and follow-up actions.47 - Call out unknowns instead of silently guessing.4849---5051## The 7 Categories (What to Check)5253### P — Product5455Application and business-logic threats:5657- Input validation, injection, insecure deserialization.58- Authorization gaps, privilege escalation, IDOR/BOLA.59- Business logic abuse, replay/race conditions, unsafe redirects.60- Error handling that leaks internals.6162### W — Workload6364Compute and infrastructure threats:6566- Insecure container/runtime posture, over-privileged workload identity.67- Weak host/orchestrator controls and segmentation.68- Insecure data storage/backups and DB configuration.69- Queue/broker abuse and poison-message handling gaps.7071### N — Network7273Network and transport threats:7475- Missing/weak TLS, insecure service-to-service communication.76- Exposed ports/endpoints and permissive ingress/egress.77- Weak segmentation or lateral movement paths.78- API-layer abuse controls missing (rate limits, request limits, CORS hardening).7980### I — IAM (Identity & Access Management)8182Identity and authorization threats:8384- Broken authentication controls and token validation.85- Missing least-privilege RBAC/ABAC.86- Service-to-service auth gaps.87- Escalation paths across users, roles, or services.8889### S — Secrets9091Credential and key management threats:9293- Secrets in code, images, logs, CI output, or defaults.94- Weak rotation, revocation, or token lifetime policies.95- Over-shared secrets across components.96- Missing secret manager/KMS controls.9798### M — Monitoring (Logging & Observability)99100Detection and auditability threats:101102- Missing logs for auth, authorization, admin/data access events.103- Sensitive data leakage in logs.104- Missing alerts for abuse indicators.105- Incomplete audit trails or weak log integrity.106107### S — Supply Chain108109Dependency and delivery threats:110111- Unpinned/unverified dependencies and vulnerable packages.112- Third-party integration trust and scope overreach.113- CI/CD pipeline leakage or unreviewed build scripts.114- Unsigned/unprovenanced artifacts, missing SBOM.115- Treat AI-generated code as untrusted until validated.116117---118119## Tailor for Architecture / Design Tasks120121When discussing designs before code exists:122123- Sketch a mental data flow: actors, data sent/received, storage, processing points.124- Mark trust boundaries explicitly (client-backend, backend-DB, service-service, cloud-third party).125- Identify where strong authentication/authorization is mandatory.126- Identify where encryption in transit and at rest is mandatory.127- Recommend concrete security patterns:128 - Parameterized queries / ORM for DB access.129 - Centralized authn/authz and role checks.130 - Secrets manager / KMS for credentials and keys.131 - mTLS or signed requests for service-to-service calls.132133---134135## Security-First Code Generation Rules136137When implementing code, enforce these baseline controls:1381391. Validate and constrain all untrusted input.1402. Parameterize all queries and command-like invocations.1413. Enforce least privilege for users, services, and workloads.1424. Never hardcode secrets; use managed secret stores.1435. Encrypt sensitive data in transit and at rest.1446. Log security-relevant actions without leaking secrets/PII.1457. Pin and verify dependencies and build artifacts.1468. Return safe user errors; keep sensitive diagnostics internal.1479. Add abuse protections (rate limits, lockouts, throttling) on exposed interfaces.148149---150151## Post-Generation Checklist152153Before finalizing output, confirm:154155- [ ] Scope, assumptions, and trust boundaries were explicit.156- [ ] All 7 PWNISMS categories were checked (or marked N/A explicitly).157- [ ] Top risks were prioritized by impact and likelihood.158- [ ] Mitigations are concrete and actionable.159- [ ] Residual risk and follow-up actions are stated.160161If ANY box cannot be checked, you MUST flag the gap to the user with a specific remediation recommendation before finalizing the code.