agentsclimarketplace

Threat modeling

Skill spec2ship/spec2ship/skills/threat-modeling

This skill should be used when the user asks to 'identify security threats', 'perform threat modeling', 'analyze attack surface', 'apply STRIDE', 'design secure architecture', 'identify trust boundaries'. Provides threat modeling frameworks for security-by-design.From its SKILL.md

Install
npx -y skills add spec2ship/spec2ship --skill threat-modeling

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

8.3 KB, as published. Nobody here has run it

Threat Modeling for Secure Design

Purpose

Threat modeling is a structured approach to identifying security threats, vulnerabilities, and countermeasures during the design phase. This skill helps security champions and architects analyze systems before implementation.

When to Use This Skill

  • During design workflow roundtables
  • When evaluating architecture proposals
  • Identifying security NFRs in specs workflow
  • Reviewing API and data flow designs
  • Assessing third-party integrations

Core Concepts

  • Threat: A potential adverse action that could harm the system
  • Vulnerability: A weakness that can be exploited
  • Attack Surface: All points where an attacker can try to enter or extract data
  • Trust Boundary: Where data or control passes between entities with different trust levels
  • Countermeasure: A control that mitigates a threat

STRIDE Framework

Microsoft's STRIDE categorizes threats by what they violate:

ThreatViolatesDescriptionExample
SpoofingAuthenticationPretending to be someone elseStolen credentials, session hijacking
TamperingIntegrityModifying data or codeSQL injection, man-in-the-middle
RepudiationNon-repudiationDenying an action occurredMissing audit logs
Information DisclosureConfidentialityExposing data to unauthorized partiesData breach, error message leaks
Denial of ServiceAvailabilityMaking system unavailableDDoS, resource exhaustion
Elevation of PrivilegeAuthorizationGaining unauthorized accessPrivilege escalation, IDOR

STRIDE per Element

Apply STRIDE based on DFD element type:

ElementSTRIDE
External Entity✓
Process✓✓✓✓✓✓
Data Store✓✓✓✓
Data Flow✓✓✓

Trust Boundaries

A trust boundary exists wherever:

  • Data crosses between different trust levels
  • Control passes between systems
  • User input enters the system
  • Data leaves for external systems

Common Trust Boundaries

[Internet] ──┬── [DMZ/WAF] ──┬── [App Server] ──┬── [Database]
             │               │                  │
         Boundary 1      Boundary 2         Boundary 3
         (Untrusted)     (Semi-trusted)     (Trusted)

Key Questions at Each Boundary:

  • Who/what is on each side?
  • What data crosses?
  • How is it validated?
  • How is it authenticated?

Data Flow Diagrams (DFD) for Threat Modeling

DFD Elements

SymbolElementDescription
○ProcessTransforms data
═══Data FlowData movement
▭Data StorePersistent storage
□External EntityOutside system boundary
╌╌╌Trust BoundarySecurity perimeter

Example DFD Pattern

[User] ─── Login Request ───> (Auth Service) ─── Query ───> [User DB]
   │                              │
   └─── Session Token <───────────┘

Trust Boundary: ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
                Between User and Auth Service

PASTA Framework (7 Stages)

Process for Attack Simulation and Threat Analysis:

StageActivityRoundtable Focus
1. Define ObjectivesBusiness impact analysisWhat are we protecting? Why?
2. Define Technical ScopeArchitecture decompositionWhat components exist?
3. Application DecompositionDFD creationHow does data flow?
4. Threat AnalysisSTRIDE applicationWhat can go wrong?
5. Vulnerability AnalysisWeakness identificationWhere are we weak?
6. Attack ModelingAttack tree creationHow would attackers proceed?
7. Risk & ImpactPrioritizationWhat matters most?

Attack Trees

Hierarchical decomposition of attack goals:

[Goal: Steal User Data]
    │
    ├── [Subgoal: Access Database]
    │       ├── SQL Injection (OR)
    │       ├── Credential Theft (OR)
    │       └── Insider Access (OR)
    │
    └── [Subgoal: Intercept Traffic]
            ├── Man-in-the-Middle (AND)
            │       ├── ARP Spoofing
            │       └── SSL Stripping
            └── Compromised Endpoint (OR)

Operators:

  • OR: Any child achieves parent goal
  • AND: All children required

Zero Trust Principles

Modern security architecture assumes breach:

PrincipleDescriptionDesign Implication
Never Trust, Always VerifyNo implicit trust based on locationAuthenticate every request
Least PrivilegeMinimum access requiredRole-based, time-limited access
Assume BreachDesign for containmentMicro-segmentation, blast radius
Verify ExplicitlyAll signals consideredDevice, location, behavior
Secure by DefaultFail closed, not openDefault deny policies

OWASP ASVS Levels

Application Security Verification Standard defines 3 levels:

LevelForVerification Depth
L1All applicationsOpportunistic threats
L2Sensitive data appsMost threats
L3Critical/High-valueAdvanced persistent threats

Key ASVS Categories

CategoryFocus Areas
V1: ArchitectureSecurity architecture, threat modeling
V2: AuthenticationIdentity verification, credential handling
V3: SessionSession management, tokens
V4: Access ControlAuthorization, RBAC/ABAC
V5: ValidationInput validation, output encoding
V7: CryptographyKey management, algorithms
V8: Data ProtectionData classification, privacy
V9: CommunicationsTLS, certificate validation
V10: Malicious CodeIntegrity verification
V13: APIREST/GraphQL security

Threat Modeling in Roundtables

Questions to Ask in specs Workflow

  • What data are we handling? (Classification: PII, PHI, Financial?)
  • Who are the users? (Trusted employees vs. anonymous internet?)
  • What compliance applies? (GDPR, HIPAA, PCI-DSS, SOC2?)
  • What's the blast radius of a breach?

Questions to Ask in design Workflow

  • Where are the trust boundaries?
  • What crosses each boundary?
  • How is each crossing authenticated and authorized?
  • What happens if Component X is compromised?
  • How do we detect an attack?
  • How do we recover?

Security NFR Patterns

# Template for security requirements
NFR-SEC-{NNN}:
  category: "Authentication|Authorization|DataProtection|Audit|Cryptography"
  requirement: "{specific measurable requirement}"
  rationale: "{threat being mitigated}"
  verification: "{how to test this}"
  asvs_reference: "V{N}.{N}.{N}"

Quick Reference: Common Threats by Component

ComponentTop ThreatsKey Controls
API EndpointInjection, Broken Auth, BOLAInput validation, AuthN/AuthZ, Rate limiting
DatabaseSQLi, Data exposure, Privilege escalationParameterized queries, Encryption, Least privilege
File UploadMalware, Path traversal, Storage DoSType validation, Sandboxing, Quotas
SessionHijacking, Fixation, CSRFSecure cookies, Rotation, CSRF tokens
AuthenticationCredential stuffing, Brute force, PhishingMFA, Rate limiting, Breach detection
Third-party APISupply chain, Data leakage, AvailabilityVendor assessment, Data minimization, Fallbacks

References

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.