@wazir-dev/cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (629) hide show
  1. package/AGENTS.md +111 -0
  2. package/CHANGELOG.md +14 -0
  3. package/CONTRIBUTING.md +101 -0
  4. package/LICENSE +21 -0
  5. package/README.md +314 -0
  6. package/assets/composition-engine.mmd +34 -0
  7. package/assets/demo-script.sh +17 -0
  8. package/assets/logo-dark.svg +14 -0
  9. package/assets/logo.svg +14 -0
  10. package/assets/pipeline.mmd +39 -0
  11. package/assets/record-demo.sh +51 -0
  12. package/docs/README.md +51 -0
  13. package/docs/adapters/context-mode.md +60 -0
  14. package/docs/concepts/architecture.md +87 -0
  15. package/docs/concepts/artifact-model.md +60 -0
  16. package/docs/concepts/composition-engine.md +36 -0
  17. package/docs/concepts/indexing-and-recall.md +160 -0
  18. package/docs/concepts/observability.md +41 -0
  19. package/docs/concepts/roles-and-workflows.md +59 -0
  20. package/docs/concepts/terminology-policy.md +27 -0
  21. package/docs/getting-started/01-installation.md +78 -0
  22. package/docs/getting-started/02-first-run.md +102 -0
  23. package/docs/getting-started/03-adding-to-project.md +15 -0
  24. package/docs/getting-started/04-host-setup.md +15 -0
  25. package/docs/guides/ci-integration.md +15 -0
  26. package/docs/guides/creating-skills.md +15 -0
  27. package/docs/guides/expertise-module-authoring.md +15 -0
  28. package/docs/guides/hook-development.md +15 -0
  29. package/docs/guides/memory-and-learnings.md +34 -0
  30. package/docs/guides/multi-host-export.md +15 -0
  31. package/docs/guides/troubleshooting.md +101 -0
  32. package/docs/guides/writing-custom-roles.md +15 -0
  33. package/docs/plans/2026-03-15-cli-pipeline-integration-design.md +592 -0
  34. package/docs/plans/2026-03-15-cli-pipeline-integration-plan.md +598 -0
  35. package/docs/plans/2026-03-15-docs-enforcement-plan.md +238 -0
  36. package/docs/readmes/INDEX.md +99 -0
  37. package/docs/readmes/features/expertise/README.md +171 -0
  38. package/docs/readmes/features/exports/README.md +222 -0
  39. package/docs/readmes/features/hooks/README.md +103 -0
  40. package/docs/readmes/features/hooks/loop-cap-guard.md +133 -0
  41. package/docs/readmes/features/hooks/post-tool-capture.md +121 -0
  42. package/docs/readmes/features/hooks/post-tool-lint.md +130 -0
  43. package/docs/readmes/features/hooks/pre-compact-summary.md +122 -0
  44. package/docs/readmes/features/hooks/pre-tool-capture-route.md +100 -0
  45. package/docs/readmes/features/hooks/protected-path-write-guard.md +128 -0
  46. package/docs/readmes/features/hooks/session-start.md +119 -0
  47. package/docs/readmes/features/hooks/stop-handoff-harvest.md +125 -0
  48. package/docs/readmes/features/roles/README.md +157 -0
  49. package/docs/readmes/features/roles/clarifier.md +152 -0
  50. package/docs/readmes/features/roles/content-author.md +190 -0
  51. package/docs/readmes/features/roles/designer.md +193 -0
  52. package/docs/readmes/features/roles/executor.md +184 -0
  53. package/docs/readmes/features/roles/learner.md +210 -0
  54. package/docs/readmes/features/roles/planner.md +182 -0
  55. package/docs/readmes/features/roles/researcher.md +164 -0
  56. package/docs/readmes/features/roles/reviewer.md +184 -0
  57. package/docs/readmes/features/roles/specifier.md +162 -0
  58. package/docs/readmes/features/roles/verifier.md +215 -0
  59. package/docs/readmes/features/schemas/README.md +178 -0
  60. package/docs/readmes/features/skills/README.md +63 -0
  61. package/docs/readmes/features/skills/brainstorming.md +96 -0
  62. package/docs/readmes/features/skills/debugging.md +148 -0
  63. package/docs/readmes/features/skills/design.md +120 -0
  64. package/docs/readmes/features/skills/prepare-next.md +109 -0
  65. package/docs/readmes/features/skills/run-audit.md +159 -0
  66. package/docs/readmes/features/skills/scan-project.md +109 -0
  67. package/docs/readmes/features/skills/self-audit.md +176 -0
  68. package/docs/readmes/features/skills/tdd.md +137 -0
  69. package/docs/readmes/features/skills/using-skills.md +92 -0
  70. package/docs/readmes/features/skills/verification.md +120 -0
  71. package/docs/readmes/features/skills/writing-plans.md +104 -0
  72. package/docs/readmes/features/tooling/README.md +320 -0
  73. package/docs/readmes/features/workflows/README.md +186 -0
  74. package/docs/readmes/features/workflows/author.md +181 -0
  75. package/docs/readmes/features/workflows/clarify.md +154 -0
  76. package/docs/readmes/features/workflows/design-review.md +171 -0
  77. package/docs/readmes/features/workflows/design.md +169 -0
  78. package/docs/readmes/features/workflows/discover.md +162 -0
  79. package/docs/readmes/features/workflows/execute.md +173 -0
  80. package/docs/readmes/features/workflows/learn.md +167 -0
  81. package/docs/readmes/features/workflows/plan-review.md +165 -0
  82. package/docs/readmes/features/workflows/plan.md +170 -0
  83. package/docs/readmes/features/workflows/prepare-next.md +167 -0
  84. package/docs/readmes/features/workflows/review.md +169 -0
  85. package/docs/readmes/features/workflows/run-audit.md +191 -0
  86. package/docs/readmes/features/workflows/spec-challenge.md +159 -0
  87. package/docs/readmes/features/workflows/specify.md +160 -0
  88. package/docs/readmes/features/workflows/verify.md +177 -0
  89. package/docs/readmes/packages/README.md +50 -0
  90. package/docs/readmes/packages/ajv.md +117 -0
  91. package/docs/readmes/packages/context-mode.md +118 -0
  92. package/docs/readmes/packages/gray-matter.md +116 -0
  93. package/docs/readmes/packages/node-test.md +137 -0
  94. package/docs/readmes/packages/yaml.md +112 -0
  95. package/docs/reference/configuration-reference.md +159 -0
  96. package/docs/reference/expertise-index.md +52 -0
  97. package/docs/reference/git-flow.md +43 -0
  98. package/docs/reference/hooks.md +87 -0
  99. package/docs/reference/host-exports.md +50 -0
  100. package/docs/reference/launch-checklist.md +172 -0
  101. package/docs/reference/marketplace-listings.md +76 -0
  102. package/docs/reference/release-process.md +34 -0
  103. package/docs/reference/roles-reference.md +77 -0
  104. package/docs/reference/skills.md +33 -0
  105. package/docs/reference/templates.md +29 -0
  106. package/docs/reference/tooling-cli.md +94 -0
  107. package/docs/truth-claims.yaml +222 -0
  108. package/expertise/PROGRESS.md +63 -0
  109. package/expertise/README.md +18 -0
  110. package/expertise/antipatterns/PROGRESS.md +56 -0
  111. package/expertise/antipatterns/backend/api-design-antipatterns.md +1271 -0
  112. package/expertise/antipatterns/backend/auth-antipatterns.md +1195 -0
  113. package/expertise/antipatterns/backend/caching-antipatterns.md +622 -0
  114. package/expertise/antipatterns/backend/database-antipatterns.md +1038 -0
  115. package/expertise/antipatterns/backend/index.md +24 -0
  116. package/expertise/antipatterns/backend/microservices-antipatterns.md +850 -0
  117. package/expertise/antipatterns/code/architecture-antipatterns.md +919 -0
  118. package/expertise/antipatterns/code/async-antipatterns.md +622 -0
  119. package/expertise/antipatterns/code/code-smells.md +1186 -0
  120. package/expertise/antipatterns/code/dependency-antipatterns.md +1209 -0
  121. package/expertise/antipatterns/code/error-handling-antipatterns.md +1360 -0
  122. package/expertise/antipatterns/code/index.md +27 -0
  123. package/expertise/antipatterns/code/naming-and-abstraction.md +1118 -0
  124. package/expertise/antipatterns/code/state-management-antipatterns.md +1076 -0
  125. package/expertise/antipatterns/code/testing-antipatterns.md +1053 -0
  126. package/expertise/antipatterns/design/accessibility-antipatterns.md +1136 -0
  127. package/expertise/antipatterns/design/dark-patterns.md +1121 -0
  128. package/expertise/antipatterns/design/index.md +22 -0
  129. package/expertise/antipatterns/design/ui-antipatterns.md +1202 -0
  130. package/expertise/antipatterns/design/ux-antipatterns.md +680 -0
  131. package/expertise/antipatterns/frontend/css-layout-antipatterns.md +691 -0
  132. package/expertise/antipatterns/frontend/flutter-antipatterns.md +1827 -0
  133. package/expertise/antipatterns/frontend/index.md +23 -0
  134. package/expertise/antipatterns/frontend/mobile-antipatterns.md +573 -0
  135. package/expertise/antipatterns/frontend/react-antipatterns.md +1128 -0
  136. package/expertise/antipatterns/frontend/spa-antipatterns.md +1235 -0
  137. package/expertise/antipatterns/index.md +31 -0
  138. package/expertise/antipatterns/performance/index.md +20 -0
  139. package/expertise/antipatterns/performance/performance-antipatterns.md +1013 -0
  140. package/expertise/antipatterns/performance/premature-optimization.md +623 -0
  141. package/expertise/antipatterns/performance/scaling-antipatterns.md +785 -0
  142. package/expertise/antipatterns/process/ai-coding-antipatterns.md +853 -0
  143. package/expertise/antipatterns/process/code-review-antipatterns.md +656 -0
  144. package/expertise/antipatterns/process/deployment-antipatterns.md +920 -0
  145. package/expertise/antipatterns/process/index.md +23 -0
  146. package/expertise/antipatterns/process/technical-debt-antipatterns.md +647 -0
  147. package/expertise/antipatterns/security/index.md +20 -0
  148. package/expertise/antipatterns/security/secrets-antipatterns.md +849 -0
  149. package/expertise/antipatterns/security/security-theater.md +843 -0
  150. package/expertise/antipatterns/security/vulnerability-patterns.md +801 -0
  151. package/expertise/architecture/PROGRESS.md +70 -0
  152. package/expertise/architecture/data/caching-architecture.md +671 -0
  153. package/expertise/architecture/data/data-consistency.md +574 -0
  154. package/expertise/architecture/data/data-modeling.md +536 -0
  155. package/expertise/architecture/data/event-streams-and-queues.md +634 -0
  156. package/expertise/architecture/data/index.md +25 -0
  157. package/expertise/architecture/data/search-architecture.md +663 -0
  158. package/expertise/architecture/data/sql-vs-nosql.md +708 -0
  159. package/expertise/architecture/decisions/architecture-decision-records.md +640 -0
  160. package/expertise/architecture/decisions/build-vs-buy.md +616 -0
  161. package/expertise/architecture/decisions/index.md +23 -0
  162. package/expertise/architecture/decisions/monolith-to-microservices.md +790 -0
  163. package/expertise/architecture/decisions/technology-selection.md +616 -0
  164. package/expertise/architecture/distributed/cap-theorem-and-tradeoffs.md +800 -0
  165. package/expertise/architecture/distributed/circuit-breaker-bulkhead.md +741 -0
  166. package/expertise/architecture/distributed/consensus-and-coordination.md +796 -0
  167. package/expertise/architecture/distributed/distributed-systems-fundamentals.md +564 -0
  168. package/expertise/architecture/distributed/idempotency-and-retry.md +796 -0
  169. package/expertise/architecture/distributed/index.md +25 -0
  170. package/expertise/architecture/distributed/saga-pattern.md +797 -0
  171. package/expertise/architecture/foundations/architectural-thinking.md +460 -0
  172. package/expertise/architecture/foundations/coupling-and-cohesion.md +770 -0
  173. package/expertise/architecture/foundations/design-principles-solid.md +649 -0
  174. package/expertise/architecture/foundations/domain-driven-design.md +719 -0
  175. package/expertise/architecture/foundations/index.md +25 -0
  176. package/expertise/architecture/foundations/separation-of-concerns.md +472 -0
  177. package/expertise/architecture/foundations/twelve-factor-app.md +797 -0
  178. package/expertise/architecture/index.md +34 -0
  179. package/expertise/architecture/integration/api-design-graphql.md +638 -0
  180. package/expertise/architecture/integration/api-design-grpc.md +804 -0
  181. package/expertise/architecture/integration/api-design-rest.md +892 -0
  182. package/expertise/architecture/integration/index.md +25 -0
  183. package/expertise/architecture/integration/third-party-integration.md +795 -0
  184. package/expertise/architecture/integration/webhooks-and-callbacks.md +1152 -0
  185. package/expertise/architecture/integration/websockets-realtime.md +791 -0
  186. package/expertise/architecture/mobile-architecture/index.md +22 -0
  187. package/expertise/architecture/mobile-architecture/mobile-app-architecture.md +780 -0
  188. package/expertise/architecture/mobile-architecture/mobile-backend-for-frontend.md +670 -0
  189. package/expertise/architecture/mobile-architecture/offline-first.md +719 -0
  190. package/expertise/architecture/mobile-architecture/push-and-sync.md +782 -0
  191. package/expertise/architecture/patterns/cqrs-event-sourcing.md +717 -0
  192. package/expertise/architecture/patterns/event-driven.md +797 -0
  193. package/expertise/architecture/patterns/hexagonal-clean-architecture.md +870 -0
  194. package/expertise/architecture/patterns/index.md +27 -0
  195. package/expertise/architecture/patterns/layered-architecture.md +736 -0
  196. package/expertise/architecture/patterns/microservices.md +753 -0
  197. package/expertise/architecture/patterns/modular-monolith.md +692 -0
  198. package/expertise/architecture/patterns/monolith.md +626 -0
  199. package/expertise/architecture/patterns/plugin-architecture.md +735 -0
  200. package/expertise/architecture/patterns/serverless.md +780 -0
  201. package/expertise/architecture/scaling/database-scaling.md +615 -0
  202. package/expertise/architecture/scaling/feature-flags-and-rollouts.md +757 -0
  203. package/expertise/architecture/scaling/horizontal-vs-vertical.md +606 -0
  204. package/expertise/architecture/scaling/index.md +24 -0
  205. package/expertise/architecture/scaling/multi-tenancy.md +800 -0
  206. package/expertise/architecture/scaling/stateless-design.md +787 -0
  207. package/expertise/backend/embedded-firmware.md +625 -0
  208. package/expertise/backend/go.md +853 -0
  209. package/expertise/backend/index.md +24 -0
  210. package/expertise/backend/java-spring.md +448 -0
  211. package/expertise/backend/node-typescript.md +625 -0
  212. package/expertise/backend/python-fastapi.md +724 -0
  213. package/expertise/backend/rust.md +458 -0
  214. package/expertise/backend/solidity.md +711 -0
  215. package/expertise/composition-map.yaml +443 -0
  216. package/expertise/content/foundations/content-modeling.md +395 -0
  217. package/expertise/content/foundations/editorial-standards.md +449 -0
  218. package/expertise/content/foundations/index.md +24 -0
  219. package/expertise/content/foundations/microcopy.md +455 -0
  220. package/expertise/content/foundations/terminology-governance.md +509 -0
  221. package/expertise/content/index.md +34 -0
  222. package/expertise/content/patterns/accessibility-copy.md +518 -0
  223. package/expertise/content/patterns/index.md +24 -0
  224. package/expertise/content/patterns/notification-content.md +433 -0
  225. package/expertise/content/patterns/sample-content.md +486 -0
  226. package/expertise/content/patterns/state-copy.md +439 -0
  227. package/expertise/design/PROGRESS.md +58 -0
  228. package/expertise/design/disciplines/dark-mode-theming.md +577 -0
  229. package/expertise/design/disciplines/design-systems.md +595 -0
  230. package/expertise/design/disciplines/index.md +25 -0
  231. package/expertise/design/disciplines/information-architecture.md +800 -0
  232. package/expertise/design/disciplines/interaction-design.md +788 -0
  233. package/expertise/design/disciplines/responsive-design.md +552 -0
  234. package/expertise/design/disciplines/usability-testing.md +516 -0
  235. package/expertise/design/disciplines/user-research.md +792 -0
  236. package/expertise/design/foundations/accessibility-design.md +796 -0
  237. package/expertise/design/foundations/color-theory.md +797 -0
  238. package/expertise/design/foundations/iconography.md +795 -0
  239. package/expertise/design/foundations/index.md +26 -0
  240. package/expertise/design/foundations/motion-and-animation.md +653 -0
  241. package/expertise/design/foundations/rtl-design.md +585 -0
  242. package/expertise/design/foundations/spacing-and-layout.md +607 -0
  243. package/expertise/design/foundations/typography.md +800 -0
  244. package/expertise/design/foundations/visual-hierarchy.md +761 -0
  245. package/expertise/design/index.md +32 -0
  246. package/expertise/design/patterns/authentication-flows.md +474 -0
  247. package/expertise/design/patterns/content-consumption.md +789 -0
  248. package/expertise/design/patterns/data-display.md +618 -0
  249. package/expertise/design/patterns/e-commerce.md +1494 -0
  250. package/expertise/design/patterns/feedback-and-states.md +642 -0
  251. package/expertise/design/patterns/forms-and-input.md +819 -0
  252. package/expertise/design/patterns/gamification.md +801 -0
  253. package/expertise/design/patterns/index.md +31 -0
  254. package/expertise/design/patterns/microinteractions.md +449 -0
  255. package/expertise/design/patterns/navigation.md +800 -0
  256. package/expertise/design/patterns/notifications.md +705 -0
  257. package/expertise/design/patterns/onboarding.md +700 -0
  258. package/expertise/design/patterns/search-and-filter.md +601 -0
  259. package/expertise/design/patterns/settings-and-preferences.md +768 -0
  260. package/expertise/design/patterns/social-and-community.md +748 -0
  261. package/expertise/design/platforms/desktop-native.md +612 -0
  262. package/expertise/design/platforms/index.md +25 -0
  263. package/expertise/design/platforms/mobile-android.md +825 -0
  264. package/expertise/design/platforms/mobile-cross-platform.md +983 -0
  265. package/expertise/design/platforms/mobile-ios.md +699 -0
  266. package/expertise/design/platforms/tablet.md +794 -0
  267. package/expertise/design/platforms/web-dashboard.md +790 -0
  268. package/expertise/design/platforms/web-responsive.md +550 -0
  269. package/expertise/design/psychology/behavioral-nudges.md +449 -0
  270. package/expertise/design/psychology/cognitive-load.md +1191 -0
  271. package/expertise/design/psychology/error-psychology.md +778 -0
  272. package/expertise/design/psychology/index.md +22 -0
  273. package/expertise/design/psychology/persuasive-design.md +736 -0
  274. package/expertise/design/psychology/user-mental-models.md +623 -0
  275. package/expertise/design/tooling/open-pencil.md +266 -0
  276. package/expertise/frontend/angular.md +1073 -0
  277. package/expertise/frontend/desktop-electron.md +546 -0
  278. package/expertise/frontend/flutter.md +782 -0
  279. package/expertise/frontend/index.md +27 -0
  280. package/expertise/frontend/native-android.md +409 -0
  281. package/expertise/frontend/native-ios.md +490 -0
  282. package/expertise/frontend/react-native.md +1160 -0
  283. package/expertise/frontend/react.md +808 -0
  284. package/expertise/frontend/vue.md +1089 -0
  285. package/expertise/humanize/domain-rules-code.md +79 -0
  286. package/expertise/humanize/domain-rules-content.md +67 -0
  287. package/expertise/humanize/domain-rules-technical-docs.md +56 -0
  288. package/expertise/humanize/index.md +35 -0
  289. package/expertise/humanize/self-audit-checklist.md +87 -0
  290. package/expertise/humanize/sentence-patterns.md +218 -0
  291. package/expertise/humanize/vocabulary-blacklist.md +105 -0
  292. package/expertise/i18n/PROGRESS.md +65 -0
  293. package/expertise/i18n/advanced/accessibility-and-i18n.md +28 -0
  294. package/expertise/i18n/advanced/bidirectional-text-algorithm.md +38 -0
  295. package/expertise/i18n/advanced/complex-scripts.md +30 -0
  296. package/expertise/i18n/advanced/performance-and-i18n.md +27 -0
  297. package/expertise/i18n/advanced/testing-i18n.md +28 -0
  298. package/expertise/i18n/content/content-adaptation.md +23 -0
  299. package/expertise/i18n/content/locale-specific-formatting.md +23 -0
  300. package/expertise/i18n/content/machine-translation-integration.md +28 -0
  301. package/expertise/i18n/content/translation-management.md +29 -0
  302. package/expertise/i18n/foundations/date-time-calendars.md +67 -0
  303. package/expertise/i18n/foundations/i18n-architecture.md +272 -0
  304. package/expertise/i18n/foundations/locale-and-language-tags.md +79 -0
  305. package/expertise/i18n/foundations/numbers-currency-units.md +61 -0
  306. package/expertise/i18n/foundations/pluralization-and-gender.md +109 -0
  307. package/expertise/i18n/foundations/string-externalization.md +236 -0
  308. package/expertise/i18n/foundations/text-direction-bidi.md +241 -0
  309. package/expertise/i18n/foundations/unicode-and-encoding.md +86 -0
  310. package/expertise/i18n/index.md +38 -0
  311. package/expertise/i18n/platform/backend-i18n.md +31 -0
  312. package/expertise/i18n/platform/flutter-i18n.md +148 -0
  313. package/expertise/i18n/platform/native-android-i18n.md +36 -0
  314. package/expertise/i18n/platform/native-ios-i18n.md +36 -0
  315. package/expertise/i18n/platform/react-i18n.md +103 -0
  316. package/expertise/i18n/platform/web-css-i18n.md +81 -0
  317. package/expertise/i18n/rtl/arabic-specific.md +175 -0
  318. package/expertise/i18n/rtl/hebrew-specific.md +149 -0
  319. package/expertise/i18n/rtl/rtl-animations-and-transitions.md +111 -0
  320. package/expertise/i18n/rtl/rtl-forms-and-input.md +161 -0
  321. package/expertise/i18n/rtl/rtl-fundamentals.md +211 -0
  322. package/expertise/i18n/rtl/rtl-icons-and-images.md +181 -0
  323. package/expertise/i18n/rtl/rtl-layout-mirroring.md +252 -0
  324. package/expertise/i18n/rtl/rtl-navigation-and-gestures.md +107 -0
  325. package/expertise/i18n/rtl/rtl-testing-and-qa.md +147 -0
  326. package/expertise/i18n/rtl/rtl-typography.md +160 -0
  327. package/expertise/index.md +113 -0
  328. package/expertise/index.yaml +216 -0
  329. package/expertise/infrastructure/cloud-aws.md +597 -0
  330. package/expertise/infrastructure/cloud-gcp.md +599 -0
  331. package/expertise/infrastructure/cybersecurity.md +816 -0
  332. package/expertise/infrastructure/database-mongodb.md +447 -0
  333. package/expertise/infrastructure/database-postgres.md +400 -0
  334. package/expertise/infrastructure/devops-cicd.md +787 -0
  335. package/expertise/infrastructure/index.md +27 -0
  336. package/expertise/performance/PROGRESS.md +50 -0
  337. package/expertise/performance/backend/api-latency.md +1204 -0
  338. package/expertise/performance/backend/background-jobs.md +506 -0
  339. package/expertise/performance/backend/connection-pooling.md +1209 -0
  340. package/expertise/performance/backend/database-query-optimization.md +515 -0
  341. package/expertise/performance/backend/index.md +23 -0
  342. package/expertise/performance/backend/rate-limiting-and-throttling.md +971 -0
  343. package/expertise/performance/foundations/algorithmic-complexity.md +954 -0
  344. package/expertise/performance/foundations/caching-strategies.md +489 -0
  345. package/expertise/performance/foundations/concurrency-and-parallelism.md +847 -0
  346. package/expertise/performance/foundations/index.md +24 -0
  347. package/expertise/performance/foundations/measuring-and-profiling.md +440 -0
  348. package/expertise/performance/foundations/memory-management.md +964 -0
  349. package/expertise/performance/foundations/performance-budgets.md +1314 -0
  350. package/expertise/performance/index.md +31 -0
  351. package/expertise/performance/infrastructure/auto-scaling.md +1059 -0
  352. package/expertise/performance/infrastructure/cdn-and-edge.md +1081 -0
  353. package/expertise/performance/infrastructure/index.md +22 -0
  354. package/expertise/performance/infrastructure/load-balancing.md +1081 -0
  355. package/expertise/performance/infrastructure/observability.md +1079 -0
  356. package/expertise/performance/mobile/index.md +23 -0
  357. package/expertise/performance/mobile/mobile-animations.md +544 -0
  358. package/expertise/performance/mobile/mobile-memory-battery.md +416 -0
  359. package/expertise/performance/mobile/mobile-network.md +452 -0
  360. package/expertise/performance/mobile/mobile-rendering.md +599 -0
  361. package/expertise/performance/mobile/mobile-startup-time.md +505 -0
  362. package/expertise/performance/platform-specific/flutter-performance.md +647 -0
  363. package/expertise/performance/platform-specific/index.md +22 -0
  364. package/expertise/performance/platform-specific/node-performance.md +1307 -0
  365. package/expertise/performance/platform-specific/postgres-performance.md +1366 -0
  366. package/expertise/performance/platform-specific/react-performance.md +1403 -0
  367. package/expertise/performance/web/bundle-optimization.md +1239 -0
  368. package/expertise/performance/web/image-and-media.md +636 -0
  369. package/expertise/performance/web/index.md +24 -0
  370. package/expertise/performance/web/network-optimization.md +1133 -0
  371. package/expertise/performance/web/rendering-performance.md +1098 -0
  372. package/expertise/performance/web/ssr-and-hydration.md +918 -0
  373. package/expertise/performance/web/web-vitals.md +1374 -0
  374. package/expertise/quality/accessibility.md +985 -0
  375. package/expertise/quality/evidence-based-verification.md +499 -0
  376. package/expertise/quality/index.md +24 -0
  377. package/expertise/quality/ml-model-audit.md +614 -0
  378. package/expertise/quality/performance.md +600 -0
  379. package/expertise/quality/testing-api.md +891 -0
  380. package/expertise/quality/testing-mobile.md +496 -0
  381. package/expertise/quality/testing-web.md +849 -0
  382. package/expertise/security/PROGRESS.md +54 -0
  383. package/expertise/security/agentic-identity.md +540 -0
  384. package/expertise/security/compliance-frameworks.md +601 -0
  385. package/expertise/security/data/data-encryption.md +364 -0
  386. package/expertise/security/data/data-privacy-gdpr.md +692 -0
  387. package/expertise/security/data/database-security.md +1171 -0
  388. package/expertise/security/data/index.md +22 -0
  389. package/expertise/security/data/pii-handling.md +531 -0
  390. package/expertise/security/foundations/authentication.md +1041 -0
  391. package/expertise/security/foundations/authorization.md +603 -0
  392. package/expertise/security/foundations/cryptography.md +1001 -0
  393. package/expertise/security/foundations/index.md +25 -0
  394. package/expertise/security/foundations/owasp-top-10.md +1354 -0
  395. package/expertise/security/foundations/secrets-management.md +1217 -0
  396. package/expertise/security/foundations/secure-sdlc.md +700 -0
  397. package/expertise/security/foundations/supply-chain-security.md +698 -0
  398. package/expertise/security/index.md +31 -0
  399. package/expertise/security/infrastructure/cloud-security-aws.md +1296 -0
  400. package/expertise/security/infrastructure/cloud-security-gcp.md +1376 -0
  401. package/expertise/security/infrastructure/container-security.md +721 -0
  402. package/expertise/security/infrastructure/incident-response.md +1295 -0
  403. package/expertise/security/infrastructure/index.md +24 -0
  404. package/expertise/security/infrastructure/logging-and-monitoring.md +1618 -0
  405. package/expertise/security/infrastructure/network-security.md +1337 -0
  406. package/expertise/security/mobile/index.md +23 -0
  407. package/expertise/security/mobile/mobile-android-security.md +1218 -0
  408. package/expertise/security/mobile/mobile-binary-protection.md +1229 -0
  409. package/expertise/security/mobile/mobile-data-storage.md +1265 -0
  410. package/expertise/security/mobile/mobile-ios-security.md +1401 -0
  411. package/expertise/security/mobile/mobile-network-security.md +1520 -0
  412. package/expertise/security/smart-contract-security.md +594 -0
  413. package/expertise/security/testing/index.md +22 -0
  414. package/expertise/security/testing/penetration-testing.md +1258 -0
  415. package/expertise/security/testing/security-code-review.md +1765 -0
  416. package/expertise/security/testing/threat-modeling.md +1074 -0
  417. package/expertise/security/testing/vulnerability-scanning.md +1062 -0
  418. package/expertise/security/web/api-security.md +586 -0
  419. package/expertise/security/web/cors-and-headers.md +433 -0
  420. package/expertise/security/web/csrf.md +562 -0
  421. package/expertise/security/web/file-upload.md +1477 -0
  422. package/expertise/security/web/index.md +25 -0
  423. package/expertise/security/web/injection.md +1375 -0
  424. package/expertise/security/web/session-management.md +1101 -0
  425. package/expertise/security/web/xss.md +1158 -0
  426. package/exports/README.md +17 -0
  427. package/exports/hosts/claude/.claude/agents/clarifier.md +42 -0
  428. package/exports/hosts/claude/.claude/agents/content-author.md +63 -0
  429. package/exports/hosts/claude/.claude/agents/designer.md +55 -0
  430. package/exports/hosts/claude/.claude/agents/executor.md +55 -0
  431. package/exports/hosts/claude/.claude/agents/learner.md +51 -0
  432. package/exports/hosts/claude/.claude/agents/planner.md +53 -0
  433. package/exports/hosts/claude/.claude/agents/researcher.md +43 -0
  434. package/exports/hosts/claude/.claude/agents/reviewer.md +54 -0
  435. package/exports/hosts/claude/.claude/agents/specifier.md +47 -0
  436. package/exports/hosts/claude/.claude/agents/verifier.md +71 -0
  437. package/exports/hosts/claude/.claude/commands/author.md +42 -0
  438. package/exports/hosts/claude/.claude/commands/clarify.md +38 -0
  439. package/exports/hosts/claude/.claude/commands/design-review.md +46 -0
  440. package/exports/hosts/claude/.claude/commands/design.md +44 -0
  441. package/exports/hosts/claude/.claude/commands/discover.md +37 -0
  442. package/exports/hosts/claude/.claude/commands/execute.md +48 -0
  443. package/exports/hosts/claude/.claude/commands/learn.md +38 -0
  444. package/exports/hosts/claude/.claude/commands/plan-review.md +42 -0
  445. package/exports/hosts/claude/.claude/commands/plan.md +39 -0
  446. package/exports/hosts/claude/.claude/commands/prepare-next.md +37 -0
  447. package/exports/hosts/claude/.claude/commands/review.md +40 -0
  448. package/exports/hosts/claude/.claude/commands/run-audit.md +41 -0
  449. package/exports/hosts/claude/.claude/commands/spec-challenge.md +41 -0
  450. package/exports/hosts/claude/.claude/commands/specify.md +38 -0
  451. package/exports/hosts/claude/.claude/commands/verify.md +37 -0
  452. package/exports/hosts/claude/.claude/settings.json +34 -0
  453. package/exports/hosts/claude/CLAUDE.md +19 -0
  454. package/exports/hosts/claude/export.manifest.json +38 -0
  455. package/exports/hosts/claude/host-package.json +67 -0
  456. package/exports/hosts/codex/AGENTS.md +19 -0
  457. package/exports/hosts/codex/export.manifest.json +38 -0
  458. package/exports/hosts/codex/host-package.json +41 -0
  459. package/exports/hosts/cursor/.cursor/hooks.json +16 -0
  460. package/exports/hosts/cursor/.cursor/rules/wazir-core.mdc +19 -0
  461. package/exports/hosts/cursor/export.manifest.json +38 -0
  462. package/exports/hosts/cursor/host-package.json +42 -0
  463. package/exports/hosts/gemini/GEMINI.md +19 -0
  464. package/exports/hosts/gemini/export.manifest.json +38 -0
  465. package/exports/hosts/gemini/host-package.json +41 -0
  466. package/hooks/README.md +18 -0
  467. package/hooks/definitions/loop_cap_guard.yaml +21 -0
  468. package/hooks/definitions/post_tool_capture.yaml +24 -0
  469. package/hooks/definitions/pre_compact_summary.yaml +19 -0
  470. package/hooks/definitions/pre_tool_capture_route.yaml +19 -0
  471. package/hooks/definitions/protected_path_write_guard.yaml +19 -0
  472. package/hooks/definitions/session_start.yaml +19 -0
  473. package/hooks/definitions/stop_handoff_harvest.yaml +20 -0
  474. package/hooks/loop-cap-guard +17 -0
  475. package/hooks/post-tool-lint +36 -0
  476. package/hooks/protected-path-write-guard +17 -0
  477. package/hooks/session-start +41 -0
  478. package/llms-full.txt +2355 -0
  479. package/llms.txt +43 -0
  480. package/package.json +79 -0
  481. package/roles/README.md +20 -0
  482. package/roles/clarifier.md +42 -0
  483. package/roles/content-author.md +63 -0
  484. package/roles/designer.md +55 -0
  485. package/roles/executor.md +55 -0
  486. package/roles/learner.md +51 -0
  487. package/roles/planner.md +53 -0
  488. package/roles/researcher.md +43 -0
  489. package/roles/reviewer.md +54 -0
  490. package/roles/specifier.md +47 -0
  491. package/roles/verifier.md +71 -0
  492. package/schemas/README.md +24 -0
  493. package/schemas/accepted-learning.schema.json +20 -0
  494. package/schemas/author-artifact.schema.json +156 -0
  495. package/schemas/clarification.schema.json +19 -0
  496. package/schemas/design-artifact.schema.json +80 -0
  497. package/schemas/docs-claim.schema.json +18 -0
  498. package/schemas/export-manifest.schema.json +20 -0
  499. package/schemas/hook.schema.json +67 -0
  500. package/schemas/host-export-package.schema.json +18 -0
  501. package/schemas/implementation-plan.schema.json +19 -0
  502. package/schemas/proposed-learning.schema.json +19 -0
  503. package/schemas/research.schema.json +18 -0
  504. package/schemas/review.schema.json +29 -0
  505. package/schemas/run-manifest.schema.json +18 -0
  506. package/schemas/spec-challenge.schema.json +18 -0
  507. package/schemas/spec.schema.json +20 -0
  508. package/schemas/usage.schema.json +102 -0
  509. package/schemas/verification-proof.schema.json +29 -0
  510. package/schemas/wazir-manifest.schema.json +173 -0
  511. package/skills/README.md +40 -0
  512. package/skills/brainstorming/SKILL.md +77 -0
  513. package/skills/debugging/SKILL.md +50 -0
  514. package/skills/design/SKILL.md +61 -0
  515. package/skills/dispatching-parallel-agents/SKILL.md +128 -0
  516. package/skills/executing-plans/SKILL.md +70 -0
  517. package/skills/finishing-a-development-branch/SKILL.md +169 -0
  518. package/skills/humanize/SKILL.md +123 -0
  519. package/skills/init-pipeline/SKILL.md +124 -0
  520. package/skills/prepare-next/SKILL.md +20 -0
  521. package/skills/receiving-code-review/SKILL.md +123 -0
  522. package/skills/requesting-code-review/SKILL.md +105 -0
  523. package/skills/requesting-code-review/code-reviewer.md +108 -0
  524. package/skills/run-audit/SKILL.md +197 -0
  525. package/skills/scan-project/SKILL.md +41 -0
  526. package/skills/self-audit/SKILL.md +153 -0
  527. package/skills/subagent-driven-development/SKILL.md +154 -0
  528. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
  529. package/skills/subagent-driven-development/implementer-prompt.md +102 -0
  530. package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  531. package/skills/tdd/SKILL.md +23 -0
  532. package/skills/using-git-worktrees/SKILL.md +163 -0
  533. package/skills/using-skills/SKILL.md +95 -0
  534. package/skills/verification/SKILL.md +22 -0
  535. package/skills/wazir/SKILL.md +463 -0
  536. package/skills/writing-plans/SKILL.md +30 -0
  537. package/skills/writing-skills/SKILL.md +157 -0
  538. package/skills/writing-skills/anthropic-best-practices.md +122 -0
  539. package/skills/writing-skills/persuasion-principles.md +50 -0
  540. package/templates/README.md +20 -0
  541. package/templates/artifacts/README.md +10 -0
  542. package/templates/artifacts/accepted-learning.md +19 -0
  543. package/templates/artifacts/accepted-learning.template.json +12 -0
  544. package/templates/artifacts/author.md +74 -0
  545. package/templates/artifacts/author.template.json +19 -0
  546. package/templates/artifacts/clarification.md +21 -0
  547. package/templates/artifacts/clarification.template.json +12 -0
  548. package/templates/artifacts/execute-notes.md +19 -0
  549. package/templates/artifacts/implementation-plan.md +21 -0
  550. package/templates/artifacts/implementation-plan.template.json +11 -0
  551. package/templates/artifacts/learning-proposal.md +19 -0
  552. package/templates/artifacts/next-run-handoff.md +21 -0
  553. package/templates/artifacts/plan-review.md +19 -0
  554. package/templates/artifacts/proposed-learning.template.json +12 -0
  555. package/templates/artifacts/research.md +21 -0
  556. package/templates/artifacts/research.template.json +12 -0
  557. package/templates/artifacts/review-findings.md +19 -0
  558. package/templates/artifacts/review.template.json +11 -0
  559. package/templates/artifacts/run-manifest.template.json +8 -0
  560. package/templates/artifacts/spec-challenge.md +19 -0
  561. package/templates/artifacts/spec-challenge.template.json +11 -0
  562. package/templates/artifacts/spec.md +21 -0
  563. package/templates/artifacts/spec.template.json +12 -0
  564. package/templates/artifacts/verification-proof.md +19 -0
  565. package/templates/artifacts/verification-proof.template.json +11 -0
  566. package/templates/examples/accepted-learning.example.json +14 -0
  567. package/templates/examples/author.example.json +152 -0
  568. package/templates/examples/clarification.example.json +15 -0
  569. package/templates/examples/docs-claim.example.json +8 -0
  570. package/templates/examples/export-manifest.example.json +7 -0
  571. package/templates/examples/host-export-package.example.json +11 -0
  572. package/templates/examples/implementation-plan.example.json +17 -0
  573. package/templates/examples/proposed-learning.example.json +13 -0
  574. package/templates/examples/research.example.json +15 -0
  575. package/templates/examples/research.example.md +6 -0
  576. package/templates/examples/review.example.json +17 -0
  577. package/templates/examples/run-manifest.example.json +9 -0
  578. package/templates/examples/spec-challenge.example.json +14 -0
  579. package/templates/examples/spec.example.json +21 -0
  580. package/templates/examples/verification-proof.example.json +21 -0
  581. package/templates/examples/wazir-manifest.example.yaml +65 -0
  582. package/templates/task-definition-schema.md +99 -0
  583. package/tooling/README.md +20 -0
  584. package/tooling/src/adapters/context-mode.js +50 -0
  585. package/tooling/src/capture/command.js +376 -0
  586. package/tooling/src/capture/store.js +99 -0
  587. package/tooling/src/capture/usage.js +270 -0
  588. package/tooling/src/checks/branches.js +50 -0
  589. package/tooling/src/checks/brand-truth.js +110 -0
  590. package/tooling/src/checks/changelog.js +231 -0
  591. package/tooling/src/checks/command-registry.js +36 -0
  592. package/tooling/src/checks/commits.js +102 -0
  593. package/tooling/src/checks/docs-drift.js +103 -0
  594. package/tooling/src/checks/docs-truth.js +201 -0
  595. package/tooling/src/checks/runtime-surface.js +156 -0
  596. package/tooling/src/cli.js +116 -0
  597. package/tooling/src/command-options.js +56 -0
  598. package/tooling/src/commands/validate.js +320 -0
  599. package/tooling/src/doctor/command.js +91 -0
  600. package/tooling/src/export/command.js +77 -0
  601. package/tooling/src/export/compiler.js +498 -0
  602. package/tooling/src/guards/loop-cap-guard.js +52 -0
  603. package/tooling/src/guards/protected-path-write-guard.js +67 -0
  604. package/tooling/src/index/command.js +152 -0
  605. package/tooling/src/index/storage.js +1061 -0
  606. package/tooling/src/index/summarizers.js +261 -0
  607. package/tooling/src/loaders.js +18 -0
  608. package/tooling/src/project-root.js +22 -0
  609. package/tooling/src/recall/command.js +225 -0
  610. package/tooling/src/schema-validator.js +30 -0
  611. package/tooling/src/state-root.js +40 -0
  612. package/tooling/src/status/command.js +71 -0
  613. package/wazir.manifest.yaml +135 -0
  614. package/workflows/README.md +19 -0
  615. package/workflows/author.md +42 -0
  616. package/workflows/clarify.md +38 -0
  617. package/workflows/design-review.md +46 -0
  618. package/workflows/design.md +44 -0
  619. package/workflows/discover.md +37 -0
  620. package/workflows/execute.md +48 -0
  621. package/workflows/learn.md +38 -0
  622. package/workflows/plan-review.md +42 -0
  623. package/workflows/plan.md +39 -0
  624. package/workflows/prepare-next.md +37 -0
  625. package/workflows/review.md +40 -0
  626. package/workflows/run-audit.md +41 -0
  627. package/workflows/spec-challenge.md +41 -0
  628. package/workflows/specify.md +38 -0
  629. package/workflows/verify.md +37 -0
@@ -0,0 +1,1041 @@
1
+ # Authentication Security
2
+
3
+ > **Severity:** Critical
4
+ > **Applies to:** All (Web, Mobile, Backend, APIs)
5
+ > **Last updated:** 2026-03-08
6
+ > **Sources:** OWASP Authentication Cheat Sheet, NIST SP 800-63B-4, OWASP ASVS v5.0, PCI DSS 4.0, FIDO Alliance
7
+
8
+ ---
9
+
10
+ ## 1. Threat Landscape
11
+
12
+ Authentication is the single most targeted attack surface. In 2024-2025, 88% of breaches
13
+ involved stolen credentials to bypass network security (Verizon DBIR 2025). Credential-based
14
+ attacks are cheap, scalable, and automated. Understanding the threat landscape is prerequisite
15
+ to building defenses.
16
+
17
+ ### 1.1 Credential Stuffing
18
+
19
+ Attackers use username-password pairs leaked from prior breaches and test them across services.
20
+ Password reuse makes this devastatingly effective. The median daily percentage of credential
21
+ stuffing accounts for 19% of all authentication attempts, rising to 25% in enterprise
22
+ environments (Verizon DBIR 2025). IBM X-Force reports an 84% increase in infostealer delivery
23
+ via phishing in 2024 versus 2023, with a ~180% jump in early 2025.
24
+
25
+ **Real breach -- Snowflake (2024):** The hacking group UNC5537/Scattered Spider used
26
+ credentials stolen via infostealer malware to access 160+ organizations' Snowflake cloud
27
+ environments, including AT&T, Ticketmaster/Live Nation, Santander Bank, and Advance Auto
28
+ Parts. 79.7% of compromised accounts used credentials from infostealer campaigns dating back
29
+ to 2020. The root cause: no mandatory MFA on Snowflake customer accounts.
30
+
31
+ ### 1.2 MFA Fatigue / Prompt Bombing
32
+
33
+ Attackers with valid credentials repeatedly trigger MFA push notifications until the victim
34
+ approves one out of frustration or confusion.
35
+
36
+ **Real breach -- Uber (2022):** A Lapsus$ affiliate purchased a contractor's Uber corporate
37
+ credentials from the dark web (the contractor's device had been infected with malware). The
38
+ attacker bombarded the contractor with MFA push requests and then contacted them on WhatsApp,
39
+ impersonating Uber IT, saying the only way to stop the notifications was to accept. Once
40
+ approved, the attacker accessed Slack, G-Suite, AWS, Duo, and Uber's HackerOne dashboard.
41
+ PAM credentials were found in plaintext PowerShell scripts.
42
+
43
+ ### 1.3 Credential Theft via Compromised Accounts
44
+
45
+ Inactive, orphaned, or service accounts with static credentials and no MFA are prime targets.
46
+
47
+ **Real breach -- Colonial Pipeline (2021):** DarkSide ransomware group accessed Colonial
48
+ Pipeline's network through an inactive VPN account that had no MFA. The password was found in
49
+ a dark web credential dump, likely reused from another breached service. Impact: pipeline
50
+ shutdown, $4.4M ransom paid, fuel shortage across the US East Coast.
51
+
52
+ ### 1.4 Identity Provider Compromise
53
+
54
+ When the authentication provider itself is breached, downstream impact is catastrophic.
55
+
56
+ **Real breach -- Okta (2023):** An employee saved service account credentials for Okta's
57
+ customer support case management system to their personal Google account. When their personal
58
+ device was compromised, attackers used those credentials to access support cases containing
59
+ HAR files with session tokens. 134 customers were affected; 5 had active sessions hijacked.
60
+ All customer support user names and emails were exfiltrated.
61
+
62
+ ### 1.5 Phishing and Adversary-in-the-Middle (AitM)
63
+
64
+ Modern phishing kits like EvilProxy and Tycoon 2FA operate as real-time reverse proxies,
65
+ capturing both credentials and session tokens simultaneously. These bypass traditional MFA
66
+ (TOTP, SMS, push) because the attacker relays the legitimate authentication flow. Only
67
+ phishing-resistant authenticators (FIDO2/WebAuthn) defeat AitM attacks.
68
+
69
+ ### 1.6 Attacker Motivations and Trends
70
+
71
+ - **Financial gain:** Ransomware, fraud, cryptocurrency theft
72
+ - **Data exfiltration:** PII, healthcare records, financial data for sale on dark web
73
+ - **Supply chain access:** Compromise one vendor to reach hundreds of downstream targets
74
+ - **AI-assisted attacks:** AI predicts passwords, generates phishing content, automates
75
+ credential stuffing at scale (16% of breaches now involve attacker AI)
76
+
77
+ ---
78
+
79
+ ## 2. Core Security Principles
80
+
81
+ ### 2.1 Password Storage
82
+
83
+ Passwords must NEVER be stored in plaintext or using reversible encryption. The only acceptable
84
+ approach is one-way adaptive hashing with a unique salt per password.
85
+
86
+ **Algorithm hierarchy (strongest first):**
87
+
88
+ | Algorithm | Type | Recommendation | Min Parameters |
89
+ |-----------|------|---------------|----------------|
90
+ | Argon2id | Memory-hard | **Primary choice** (OWASP, NIST) | 19 MiB memory, 2 iterations, 1 parallelism |
91
+ | scrypt | Memory-hard | Secondary choice | N=2^17, r=8, p=1 |
92
+ | bcrypt | CPU-hard | Legacy systems only | cost factor 12+ |
93
+ | PBKDF2-HMAC-SHA256 | CPU-hard | FIPS-compliant environments | 600,000 iterations (OWASP 2025) |
94
+
95
+ **NEVER use:** MD5, SHA-1, SHA-256 (unsalted), DES-crypt, or any fast hash for passwords.
96
+ These can be brute-forced at billions of hashes per second on modern GPUs.
97
+
98
+ **Why Argon2id wins:** It is the winner of the Password Hashing Competition (2013-2015),
99
+ resistant to both GPU attacks (memory-hard) and side-channel attacks (data-independent memory
100
+ access in the id variant). NIST SP 800-63B-4 formally recommends Argon2id.
101
+
102
+ ### 2.2 Multi-Factor Authentication (MFA)
103
+
104
+ MFA is the single most impactful control. Microsoft analysis shows MFA stops 99.9% of
105
+ automated account compromises. Factors are categorized as:
106
+
107
+ - **Something you know:** Password, PIN, security questions (weakest)
108
+ - **Something you have:** Hardware key, authenticator app, smart card
109
+ - **Something you are:** Fingerprint, face scan, iris scan
110
+
111
+ **MFA strength hierarchy (strongest first):**
112
+
113
+ 1. **FIDO2/WebAuthn hardware keys** -- Phishing-resistant, no shared secrets
114
+ 2. **Platform authenticators (passkeys)** -- Synced via cloud, phishing-resistant
115
+ 3. **TOTP authenticator apps** -- Time-based codes (Google Authenticator, Authy)
116
+ 4. **Push notifications with number matching** -- Resist MFA fatigue
117
+ 5. **SMS/Email OTP** -- NIST "restricted" authenticators; vulnerable to SIM swap, interception
118
+
119
+ ### 2.3 Session Management Post-Authentication
120
+
121
+ Authentication is pointless if session management is broken. Critical rules:
122
+
123
+ - **Regenerate session ID after login** -- Prevents session fixation (CWE-384)
124
+ - **Set secure cookie attributes** -- `Secure`, `HttpOnly`, `SameSite=Strict`
125
+ - **Enforce idle timeout** -- 15-minute idle timeout (PCI DSS 4.0)
126
+ - **Enforce absolute timeout** -- Maximum session lifetime regardless of activity
127
+ - **Bind session to context** -- IP range, user agent, device fingerprint
128
+ - **Invalidate on logout** -- Server-side session destruction, not just cookie deletion
129
+
130
+ ### 2.4 Zero-Trust Authentication
131
+
132
+ Never trust, always verify. Every request must be authenticated and authorized regardless of
133
+ network location:
134
+
135
+ - **No implicit trust from network position** -- Internal services authenticate too
136
+ - **Continuous verification** -- Re-authenticate on privilege escalation
137
+ - **Least privilege** -- Tokens carry minimum necessary scopes
138
+ - **Device posture assessment** -- Check device health before granting access
139
+ - **Short-lived credentials** -- Access tokens expire in minutes, not days
140
+
141
+ ---
142
+
143
+ ## 3. Implementation Patterns
144
+
145
+ ### 3.1 Secure Password Hashing
146
+
147
+ **TypeScript (using argon2 library):**
148
+
149
+ ```typescript
150
+ import argon2 from 'argon2';
151
+
152
+ async function hashPassword(password: string): Promise<string> {
153
+ return argon2.hash(password, {
154
+ type: argon2.argon2id,
155
+ memoryCost: 19456, // 19 MiB (OWASP minimum)
156
+ timeCost: 2, // 2 iterations
157
+ parallelism: 1, // 1 thread
158
+ saltLength: 16, // 128-bit salt (auto-generated)
159
+ });
160
+ }
161
+
162
+ async function verifyPassword(
163
+ hash: string, password: string
164
+ ): Promise<boolean> {
165
+ return argon2.verify(hash, password);
166
+ }
167
+ ```
168
+
169
+ **Python (using argon2-cffi):**
170
+
171
+ ```python
172
+ from argon2 import PasswordHasher
173
+ from argon2.exceptions import VerifyMismatchError
174
+
175
+ ph = PasswordHasher(
176
+ memory_cost=19456, # 19 MiB
177
+ time_cost=2, # 2 iterations
178
+ parallelism=1, # 1 thread
179
+ hash_len=32, # 256-bit hash
180
+ salt_len=16, # 128-bit salt
181
+ )
182
+
183
+ def hash_password(password: str) -> str:
184
+ return ph.hash(password)
185
+
186
+ def verify_password(stored_hash: str, password: str) -> bool:
187
+ try:
188
+ return ph.verify(stored_hash, password)
189
+ except VerifyMismatchError:
190
+ return False
191
+ ```
192
+
193
+ ### 3.2 TOTP Verification
194
+
195
+ ```typescript
196
+ import { TOTP } from 'otpauth';
197
+
198
+ function createTOTPSecret(issuer: string, accountName: string) {
199
+ const totp = new TOTP({
200
+ issuer,
201
+ label: accountName,
202
+ algorithm: 'SHA1', // SHA1 is the standard for TOTP (RFC 6238)
203
+ digits: 6,
204
+ period: 30, // 30-second window
205
+ });
206
+ return {
207
+ secret: totp.secret.base32,
208
+ uri: totp.toString(), // otpauth:// URI for QR code generation
209
+ };
210
+ }
211
+
212
+ function verifyTOTP(secret: string, token: string): boolean {
213
+ const totp = new TOTP({ secret });
214
+ const delta = totp.validate({ token, window: 1 });
215
+ return delta !== null;
216
+ }
217
+ ```
218
+
219
+ ### 3.3 WebAuthn/FIDO2 Registration
220
+
221
+ ```typescript
222
+ import {
223
+ generateRegistrationOptions,
224
+ verifyRegistrationResponse,
225
+ } from '@simplewebauthn/server';
226
+
227
+ const rpName = 'My Application';
228
+ const rpID = 'example.com';
229
+ const origin = 'https://example.com';
230
+
231
+ async function startRegistration(user: User) {
232
+ const options = await generateRegistrationOptions({
233
+ rpName,
234
+ rpID,
235
+ userID: user.id,
236
+ userName: user.email,
237
+ attestationType: 'none',
238
+ authenticatorSelection: {
239
+ residentKey: 'preferred',
240
+ userVerification: 'required',
241
+ },
242
+ excludeCredentials: user.existingCredentials.map(cred => ({
243
+ id: cred.credentialID,
244
+ type: 'public-key',
245
+ })),
246
+ });
247
+ return options;
248
+ }
249
+
250
+ async function finishRegistration(
251
+ user: User, response: RegistrationResponse
252
+ ) {
253
+ const verification = await verifyRegistrationResponse({
254
+ response,
255
+ expectedChallenge: user.currentChallenge,
256
+ expectedOrigin: origin,
257
+ expectedRPID: rpID,
258
+ });
259
+ if (verification.verified && verification.registrationInfo) {
260
+ await storeCredential(user.id, verification.registrationInfo);
261
+ }
262
+ return verification.verified;
263
+ }
264
+ ```
265
+
266
+ ### 3.4 OAuth 2.0 / OIDC with PKCE
267
+
268
+ ```typescript
269
+ import crypto from 'node:crypto';
270
+
271
+ function generatePKCE() {
272
+ const verifier = crypto.randomBytes(32).toString('base64url');
273
+ const challenge = crypto
274
+ .createHash('sha256')
275
+ .update(verifier)
276
+ .digest('base64url');
277
+ return { verifier, challenge };
278
+ }
279
+
280
+ function getAuthorizationURL(clientId: string, redirectUri: string) {
281
+ const { verifier, challenge } = generatePKCE();
282
+ const state = crypto.randomBytes(16).toString('hex');
283
+
284
+ const url = new URL('https://auth.example.com/authorize');
285
+ url.searchParams.set('response_type', 'code');
286
+ url.searchParams.set('client_id', clientId);
287
+ url.searchParams.set('redirect_uri', redirectUri);
288
+ url.searchParams.set('scope', 'openid profile email');
289
+ url.searchParams.set('state', state);
290
+ url.searchParams.set('code_challenge', challenge);
291
+ url.searchParams.set('code_challenge_method', 'S256');
292
+ return { url: url.toString(), verifier, state };
293
+ }
294
+
295
+ async function exchangeCode(code: string, verifier: string) {
296
+ const response = await fetch('https://auth.example.com/token', {
297
+ method: 'POST',
298
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
299
+ body: new URLSearchParams({
300
+ grant_type: 'authorization_code',
301
+ code,
302
+ code_verifier: verifier,
303
+ client_id: 'your-client-id',
304
+ redirect_uri: 'https://app.example.com/callback',
305
+ }),
306
+ });
307
+ return response.json();
308
+ }
309
+ ```
310
+
311
+ ### 3.5 Rate Limiting Login Attempts
312
+
313
+ ```typescript
314
+ import Redis from 'ioredis';
315
+
316
+ const redis = new Redis();
317
+
318
+ interface RateLimitResult {
319
+ allowed: boolean;
320
+ remaining: number;
321
+ retryAfterMs: number;
322
+ }
323
+
324
+ async function checkLoginRateLimit(
325
+ identifier: string,
326
+ maxAttempts: number = 5,
327
+ windowSeconds: number = 900
328
+ ): Promise<RateLimitResult> {
329
+ const key = `login_rate:${identifier}`;
330
+ const now = Date.now();
331
+ const windowMs = windowSeconds * 1000;
332
+
333
+ const multi = redis.multi();
334
+ multi.zremrangebyscore(key, 0, now - windowMs);
335
+ multi.zadd(key, now.toString(), `${now}-${Math.random()}`);
336
+ multi.zcard(key);
337
+ multi.expire(key, windowSeconds);
338
+
339
+ const results = await multi.exec();
340
+ const currentCount = results?.[2]?.[1] as number;
341
+
342
+ if (currentCount > maxAttempts) {
343
+ return { allowed: false, remaining: 0, retryAfterMs: windowMs };
344
+ }
345
+ return {
346
+ allowed: true,
347
+ remaining: maxAttempts - currentCount,
348
+ retryAfterMs: 0,
349
+ };
350
+ }
351
+ ```
352
+
353
+ ### 3.6 Account Lockout Policy
354
+
355
+ Implement progressive delays, not permanent lockout (which enables denial-of-service):
356
+
357
+ - **5 failed attempts:** 1-minute soft lockout
358
+ - **10 failed attempts:** 5-minute lockout + CAPTCHA required
359
+ - **20 failed attempts:** 30-minute lockout + account owner notified
360
+ - **50 failed attempts:** Account locked pending manual review
361
+
362
+ Always allow unlock via verified email/phone to prevent attacker-induced denial of service.
363
+
364
+ ---
365
+
366
+ ## 4. Vulnerability Catalog
367
+
368
+ ### V1. Plaintext Password Storage
369
+ - **CWE-256:** Plaintext Storage of a Password
370
+ - **Impact:** Total account compromise on any data leak
371
+ - **Fix:** Use Argon2id hashing (see Section 3.1)
372
+
373
+ ```python
374
+ # VULNERABLE
375
+ user.password = request.form['password']
376
+ db.save(user)
377
+
378
+ # SECURE
379
+ user.password_hash = ph.hash(request.form['password'])
380
+ db.save(user)
381
+ ```
382
+
383
+ ### V2. Weak Hashing (MD5/SHA1/SHA256 unsalted)
384
+ - **CWE-328:** Use of Weak Hash
385
+ - **Impact:** Hashcat cracks MD5 at 60+ billion hashes/sec on consumer GPU
386
+ - **Fix:** Migrate to Argon2id; rehash on next successful login
387
+
388
+ ```python
389
+ # VULNERABLE
390
+ import hashlib
391
+ hashed = hashlib.md5(password.encode()).hexdigest()
392
+
393
+ # SECURE
394
+ from argon2 import PasswordHasher
395
+ ph = PasswordHasher()
396
+ hashed = ph.hash(password)
397
+ ```
398
+
399
+ ### V3. Missing Multi-Factor Authentication
400
+ - **CWE-308:** Use of Single-Factor Authentication
401
+ - **Impact:** Credential stuffing, phishing, and brute force all succeed
402
+ - **Real-world:** Snowflake 2024 -- 160+ orgs breached, no MFA enforced
403
+ - **Fix:** Enforce MFA for all users; prioritize FIDO2/passkeys
404
+
405
+ ### V4. Timing Attack on Password Comparison
406
+ - **CWE-208:** Observable Timing Discrepancy
407
+ - **Impact:** Attacker determines correct password characters via response time
408
+
409
+ ```typescript
410
+ // VULNERABLE: Early-exit string comparison
411
+ function checkPassword(input: string, stored: string): boolean {
412
+ return input === stored;
413
+ }
414
+
415
+ // SECURE: Constant-time comparison
416
+ import crypto from 'node:crypto';
417
+ function checkPassword(inputHash: Buffer, storedHash: Buffer): boolean {
418
+ return crypto.timingSafeEqual(inputHash, storedHash);
419
+ }
420
+ ```
421
+
422
+ ### V5. User Enumeration via Error Messages
423
+ - **CWE-204:** Observable Response Discrepancy
424
+ - **Impact:** Attacker discovers valid usernames for targeted attacks
425
+
426
+ ```typescript
427
+ // VULNERABLE
428
+ if (!userExists) return res.json({ error: 'User not found' });
429
+ if (!passwordValid) return res.json({ error: 'Invalid password' });
430
+
431
+ // SECURE
432
+ if (!userExists || !passwordValid) {
433
+ return res.json({ error: 'Invalid email or password' });
434
+ }
435
+ // Hash a dummy password when user does not exist to prevent
436
+ // timing-based enumeration
437
+ ```
438
+
439
+ ### V6. Session Fixation Post-Login
440
+ - **CWE-384:** Session Fixation
441
+ - **Impact:** Attacker pre-sets session ID, victim authenticates, attacker hijacks
442
+
443
+ ```typescript
444
+ // VULNERABLE
445
+ app.post('/login', (req, res) => {
446
+ if (authenticate(req.body)) {
447
+ req.session.authenticated = true; // Same session ID
448
+ }
449
+ });
450
+
451
+ // SECURE
452
+ app.post('/login', (req, res) => {
453
+ if (authenticate(req.body)) {
454
+ req.session.regenerate((err) => {
455
+ req.session.authenticated = true;
456
+ req.session.save();
457
+ });
458
+ }
459
+ });
460
+ ```
461
+
462
+ ### V7. JWT Algorithm Confusion
463
+ - **CWE-327:** Use of Broken or Risky Cryptographic Algorithm
464
+ - **CVE-2024-54150, CVE-2026-22817 (Hono, CVSS 8.2), CVE-2026-23993**
465
+ - **Impact:** Attacker forges valid tokens by switching RS256 to HS256
466
+
467
+ ```typescript
468
+ // VULNERABLE
469
+ const decoded = jwt.verify(token, publicKey);
470
+
471
+ // SECURE
472
+ const decoded = jwt.verify(token, publicKey, {
473
+ algorithms: ['RS256'],
474
+ issuer: 'https://auth.example.com',
475
+ audience: 'my-app',
476
+ });
477
+ ```
478
+
479
+ ### V8. JWT "none" Algorithm Attack
480
+ - **CWE-345:** Insufficient Verification of Data Authenticity
481
+ - **Impact:** Attacker removes signature; unsigned token accepted as valid
482
+ - **Fix:** Always specify allowed algorithms; reject `alg: none` (case-insensitive)
483
+
484
+ ### V9. Weak Password Requirements
485
+ - **CWE-521:** Weak Password Requirements
486
+ - **Impact:** Users choose easily guessable passwords
487
+ - **Fix:** Min 12 chars (NIST/PCI DSS 4.0); check against breached lists; do NOT
488
+ enforce arbitrary complexity rules (leads to predictable patterns like "Password1!")
489
+
490
+ ### V10. Insecure Password Reset Flow
491
+ - **CWE-640:** Weak Password Recovery Mechanism
492
+ - **Impact:** Account takeover via predictable tokens or no expiry
493
+ - **Fix:** Cryptographically random tokens (128-bit entropy), 15-min expiry,
494
+ single-use, via confirmed email/phone only
495
+
496
+ ### V11. Missing Rate Limiting
497
+ - **CWE-307:** Improper Restriction of Excessive Authentication Attempts
498
+ - **Impact:** Unlimited brute force attempts
499
+ - **Fix:** Sliding window rate limiting (see Section 3.5)
500
+
501
+ ### V12. Credential Transmission Without TLS
502
+ - **CWE-523:** Unprotected Transport of Credentials
503
+ - **Impact:** Network interception of passwords in transit
504
+ - **Fix:** HTTPS everywhere; HSTS with preload; redirect HTTP to HTTPS
505
+
506
+ ### V13. Hardcoded Credentials
507
+ - **CWE-798:** Use of Hard-coded Credentials
508
+ - **Impact:** Trivial unauthorized access
509
+ - **Fix:** Require password change on first login; scan code for credential patterns
510
+
511
+ ### V14. Insufficient Session Expiration
512
+ - **CWE-613:** Insufficient Session Expiration
513
+ - **Impact:** Stolen session tokens remain valid indefinitely
514
+ - **Fix:** 15-min idle timeout, 8-24 hr absolute timeout, revoke on password change
515
+
516
+ ### V15. Insecure "Remember Me"
517
+ - **CWE-539:** Use of Persistent Cookies Without Expiration
518
+ - **Impact:** Long-lived tokens without rotation enable persistent compromise
519
+ - **Fix:** Separate persistent token rotated on each use with device binding
520
+
521
+ ---
522
+
523
+ ## 5. Security Checklist
524
+
525
+ ### Password Policy
526
+ - [ ] Minimum password length of 12 characters enforced
527
+ - [ ] Maximum password length of at least 64 characters allowed
528
+ - [ ] No arbitrary complexity rules (no mandatory uppercase/special mandates)
529
+ - [ ] Passwords checked against breached password list (HIBP, top 100K)
530
+ - [ ] Unicode characters permitted in passwords (NIST 800-63B)
531
+ - [ ] No password hints or knowledge-based questions
532
+
533
+ ### Password Storage
534
+ - [ ] Argon2id used with OWASP parameters (19 MiB, 2 iterations)
535
+ - [ ] Unique random salt per password (minimum 128 bits)
536
+ - [ ] No reversible encryption of passwords
537
+ - [ ] Migration path for legacy hashes (rehash on successful login)
538
+
539
+ ### Multi-Factor Authentication
540
+ - [ ] MFA enforced for all users (not optional)
541
+ - [ ] FIDO2/WebAuthn supported as primary MFA method
542
+ - [ ] TOTP authenticator apps supported as fallback
543
+ - [ ] SMS/Email OTP being phased out (NIST "restricted")
544
+ - [ ] MFA fatigue mitigated (number matching, rate limit on prompts)
545
+ - [ ] Recovery codes generated (8+ codes, single-use, stored hashed)
546
+
547
+ ### Rate Limiting and Lockout
548
+ - [ ] Login attempts rate-limited per IP and per account
549
+ - [ ] Progressive delays on repeated failures (not permanent lockout)
550
+ - [ ] CAPTCHA triggered after threshold failures
551
+ - [ ] Rate limiting on password reset and MFA verification endpoints
552
+ - [ ] Distributed rate limiting across all application instances
553
+
554
+ ### Session Management
555
+ - [ ] Session ID regenerated after successful authentication
556
+ - [ ] Session cookies: Secure, HttpOnly, SameSite=Strict
557
+ - [ ] Idle timeout enforced (15 minutes for sensitive apps)
558
+ - [ ] Absolute session timeout enforced (8-24 hours)
559
+ - [ ] All sessions invalidated on password change
560
+ - [ ] Logout destroys server-side session state
561
+
562
+ ### Password Reset
563
+ - [ ] Reset tokens are cryptographically random (128+ bit entropy)
564
+ - [ ] Reset tokens expire within 15 minutes
565
+ - [ ] Reset tokens are single-use
566
+ - [ ] Prior reset tokens invalidated on new request
567
+ - [ ] Generic response regardless of whether account exists
568
+ - [ ] Notification sent to registered email on password change
569
+
570
+ ### Transport and Infrastructure
571
+ - [ ] All auth endpoints served over HTTPS only
572
+ - [ ] HSTS header with includeSubDomains and preload
573
+ - [ ] Credentials never logged (mask in application logs)
574
+ - [ ] Credentials never in URL query parameters
575
+
576
+ ---
577
+
578
+ ## 6. Tools and Automation
579
+
580
+ ### Authentication Libraries
581
+
582
+ | Library | Platform | Notes |
583
+ |---------|----------|-------|
584
+ | **Passport.js** | Node.js | Strategy-based; 500+ auth providers |
585
+ | **NextAuth.js / Auth.js** | Next.js / SvelteKit | Built-in providers, JWT/session modes |
586
+ | **Firebase Auth** | Multi-platform | Managed; phone, email, social, anonymous |
587
+ | **Supabase Auth** | Multi-platform | Open-source; GoTrue-based; RLS integration |
588
+ | **Lucia** | Node.js | Lightweight, framework-agnostic |
589
+ | **Keycloak** | Java / Self-hosted | Enterprise IAM; SAML + OIDC |
590
+ | **@simplewebauthn** | Node.js + Browser | WebAuthn/FIDO2 registration and auth |
591
+
592
+ ### Password Strength Assessment
593
+
594
+ | Tool | Type | Usage |
595
+ |------|------|-------|
596
+ | **zxcvbn / zxcvbn-ts** | Library | Realistic strength estimation; penalizes patterns |
597
+ | **Have I Been Pwned API** | API | k-Anonymity model; 800M+ breached credentials |
598
+ | **HIBP Downloader** | Offline DB | Full SHA-1 hash set for air-gapped environments |
599
+
600
+ ### Credential Leak Detection
601
+
602
+ | Tool | Purpose |
603
+ |------|---------|
604
+ | **Have I Been Pwned** | Check emails/passwords against known breaches |
605
+ | **Enzoic** | Real-time compromised credential screening |
606
+ | **SpyCloud** | Enterprise credential exposure monitoring |
607
+ | **GitGuardian** | Detect credentials committed to repositories |
608
+
609
+ ### Static Analysis Rules
610
+
611
+ | Tool | Auth-Related Rules |
612
+ |------|-------------------|
613
+ | **Semgrep** | `jwt-none-alg`, `insecure-hash`, `secrets` |
614
+ | **CodeQL** | `CWE-312` (cleartext storage), `CWE-327` (weak crypto) |
615
+ | **Bearer CLI** | `observable_timing`, `hardcoded_credential` |
616
+ | **ESLint Plugin Security** | `detect-possible-timing-attacks` |
617
+
618
+ ---
619
+
620
+ ## 7. Platform-Specific Guidance
621
+
622
+ ### 7.1 Web Applications
623
+
624
+ **Cookie-Based Sessions (server-rendered apps):**
625
+ ```
626
+ Set-Cookie: session=<random-id>;
627
+ Secure; HttpOnly; SameSite=Strict;
628
+ Path=/; Max-Age=28800; Domain=example.com
629
+ ```
630
+
631
+ - Store session data server-side (Redis, database); cookie holds only session ID
632
+ - Session ID: at least 128 bits of cryptographic randomness
633
+ - Never store sensitive data in the cookie itself
634
+
635
+ **JWT-Based Authentication (SPAs, APIs):**
636
+ - Store access tokens in memory only (not localStorage or sessionStorage)
637
+ - Short-lived access tokens (5-15 minutes)
638
+ - HttpOnly cookie for refresh tokens
639
+ - Validate: signature, `exp`, `iss`, `aud`, `iat`
640
+ - Specify algorithm explicitly (prevent algorithm confusion)
641
+ - Token revocation via server-side blocklist for logout
642
+
643
+ **Content Security Policy for login pages:**
644
+ ```
645
+ Content-Security-Policy: default-src 'self';
646
+ script-src 'self'; form-action 'self'; frame-ancestors 'none';
647
+ ```
648
+
649
+ ### 7.2 Mobile Applications
650
+
651
+ **Biometric Authentication:**
652
+ - Use platform APIs: `BiometricPrompt` (Android), `LAContext` (iOS)
653
+ - Biometrics unlock a cryptographic key, not directly grant access
654
+ - Fall back to device PIN/passcode, not application password
655
+
656
+ **Secure Key Storage:**
657
+ - **iOS:** Keychain with `kSecAttrAccessibleWhenUnlockedThisDeviceOnly`
658
+ - **Android:** Android Keystore with TEE/StrongBox binding
659
+ - Never store tokens in SharedPreferences or UserDefaults unencrypted
660
+
661
+ **Certificate Pinning:**
662
+ - Pin leaf certificate or public key hash for auth endpoints
663
+ - Implement backup pins for rotation
664
+ - Use `TrustKit` (iOS) or `OkHttp CertificatePinner` (Android)
665
+
666
+ **Encrypted Token Storage (Android):**
667
+
668
+ ```kotlin
669
+ val masterKey = MasterKey.Builder(context)
670
+ .setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
671
+ .build()
672
+
673
+ val sharedPrefs = EncryptedSharedPreferences.create(
674
+ context, "auth_prefs", masterKey,
675
+ EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
676
+ EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
677
+ )
678
+ sharedPrefs.edit().putString("refresh_token", token).apply()
679
+ ```
680
+
681
+ ### 7.3 Backend / Service-to-Service
682
+
683
+ **API Keys vs Tokens:**
684
+ - API keys identify the calling application, not the user
685
+ - OAuth tokens identify both application and user
686
+ - Never embed API keys in client-side code or mobile apps
687
+
688
+ **Mutual TLS (mTLS):**
689
+ - Both client and server present certificates
690
+ - Ideal for service mesh (Istio, Linkerd) and zero-trust internal networks
691
+ - Automate certificate rotation (short-lived certs via ACME/Vault)
692
+
693
+ **Service Account Best Practices:**
694
+ - Use workload identity (GCP), IAM roles (AWS), managed identity (Azure)
695
+ - Rotate keys automatically (maximum 90-day lifetime)
696
+ - Apply least-privilege scopes; audit usage
697
+
698
+ **JWT for Microservices:**
699
+
700
+ ```typescript
701
+ function validateServiceToken(token: string) {
702
+ return jwt.verify(token, SERVICE_PUBLIC_KEY, {
703
+ algorithms: ['RS256'],
704
+ issuer: 'auth-service.internal',
705
+ audience: 'inventory-service',
706
+ maxAge: '5m',
707
+ });
708
+ }
709
+ ```
710
+
711
+ ---
712
+
713
+ ## 8. Incident Patterns
714
+
715
+ ### 8.1 Credential Stuffing Attack Chain
716
+
717
+ **Detection signals:**
718
+ 1. Spike in failed logins from diverse IP addresses
719
+ 2. Login attempts using email addresses not registered in the system
720
+ 3. Successful logins from unusual geographic locations
721
+ 4. Multiple accounts accessed from the same IP in rapid succession
722
+ 5. User-agent strings matching known bot frameworks
723
+
724
+ **Response steps:**
725
+ 1. Enable enhanced CAPTCHA on login endpoints immediately
726
+ 2. Force password resets for accounts with suspicious successful logins
727
+ 3. Cross-reference login timestamps with known breach credential dumps
728
+ 4. Temporarily block IP ranges associated with the attack
729
+ 5. Notify affected users and recommend enabling MFA
730
+ 6. Review and strengthen rate limiting thresholds
731
+
732
+ ### 8.2 Account Takeover Detection
733
+
734
+ **Detection signals:**
735
+ 1. Password change followed by MFA method change
736
+ 2. Login from new device/location followed by sensitive operations
737
+ 3. Multiple simultaneous active sessions from different locations
738
+ 4. Recovery email or phone number changed shortly after login
739
+ 5. Unusual API access patterns (data export, privilege changes)
740
+
741
+ **Response steps:**
742
+ 1. Lock the account immediately pending verification
743
+ 2. Invalidate all active sessions and tokens
744
+ 3. Require identity verification (ID document, phone call)
745
+ 4. Review account activity log for data exfiltration
746
+ 5. Reset all credentials (password, MFA, recovery methods)
747
+ 6. Notify user through pre-compromise contact method
748
+
749
+ ### 8.3 MFA Bypass Detection
750
+
751
+ **Detection signals:**
752
+ 1. Repeated MFA prompts to same user in short succession (fatigue attack)
753
+ 2. MFA approval from different location than initial login
754
+ 3. Session token reuse from different IP/device (token theft)
755
+ 4. Successful auth that bypasses MFA step in server logs
756
+
757
+ **Response steps:**
758
+ 1. Revoke all active sessions for the affected account
759
+ 2. Disable push-based MFA; switch to FIDO2 or TOTP
760
+ 3. Investigate for AitM phishing kit deployment
761
+ 4. Check if session tokens were exposed in support cases or logs
762
+ 5. Enforce number-matching for push MFA across all accounts
763
+ 6. Audit all actions taken during the compromised session
764
+
765
+ ---
766
+
767
+ ## 9. Compliance and Standards
768
+
769
+ ### 9.1 NIST SP 800-63B-4
770
+
771
+ - **AAL1:** Single-factor allowed; memorized secrets min 8 chars (12+ recommended)
772
+ - **AAL2:** Multi-factor required; NIST recognizes synced passkeys as AAL2-capable
773
+ - **AAL3:** Hardware-based, phishing-resistant (FIDO2); verifier impersonation resistance
774
+ - **Password rules:** No composition rules; no periodic rotation unless evidence of
775
+ compromise; min 8 chars; check breached lists; allow paste into fields
776
+ - **Restricted authenticators:** SMS and email OTP require alternative options and
777
+ user notification of risk
778
+
779
+ ### 9.2 OWASP ASVS v5.0
780
+
781
+ V2 (Authentication) verification requirements:
782
+ - **V2.1:** Password security (length, complexity, storage)
783
+ - **V2.2:** General authenticator requirements
784
+ - **V2.3:** Authenticator lifecycle (reset, recovery, expiry)
785
+ - **V2.4:** Credential storage (Argon2id/bcrypt/scrypt/PBKDF2)
786
+ - **V2.5:** Credential recovery requirements
787
+ - **V2.6:** Lookup secret verifier (recovery codes)
788
+ - **V2.7:** Out-of-band verifier (SMS/email -- restricted)
789
+ - **V2.8:** Time-based OTP
790
+ - **V2.9:** Cryptographic authenticator (FIDO2, client certificates)
791
+ - **V2.10:** Service authentication (API keys, service accounts)
792
+ - ASVS L1 maps to NIST AAL1, L2 to AAL2, L3 to AAL3
793
+
794
+ ### 9.3 PCI DSS 4.0
795
+
796
+ - **Req 8.2:** Minimum 12-character passwords
797
+ - **Req 8.3.6:** Password change every 90 days (only if no MFA)
798
+ - **Req 8.4.2:** MFA for ALL access to cardholder data environment
799
+ - **Req 8.5:** MFA factors must be independent
800
+ - **Req 8.6:** Inactive accounts disabled after 90 days
801
+ - **Req 8.2.8:** Re-authenticate after 15 minutes of inactivity
802
+ - **PCI DSS 4.0.1:** Phishing-resistant factor substitutes MFA for non-admin CDE access
803
+
804
+ ### 9.4 SOC 2 Authentication Controls
805
+
806
+ - **CC6.1:** Logical access controls -- unique user IDs, role-based access
807
+ - **CC6.2:** Registration and authorization -- identity proofing before provisioning
808
+ - **CC6.3:** Security for registered users -- MFA enforcement, session controls
809
+ - **CC6.6:** Restrictions on access -- least privilege, periodic access review
810
+ - Evidence required: MFA enforcement logs, access reviews, password policy config,
811
+ deprovisioning procedures for terminated users
812
+
813
+ ---
814
+
815
+ ## 10. Code Examples
816
+
817
+ ### 10.1 Secure JWT Validation (TypeScript)
818
+
819
+ ```typescript
820
+ import jwt, { JwtPayload } from 'jsonwebtoken';
821
+ import jwksClient from 'jwks-rsa';
822
+
823
+ const client = jwksClient({
824
+ jwksUri: 'https://auth.example.com/.well-known/jwks.json',
825
+ cache: true,
826
+ rateLimit: true,
827
+ jwksRequestsPerMinute: 10,
828
+ });
829
+
830
+ function getSigningKey(header: jwt.JwtHeader): Promise<string> {
831
+ return new Promise((resolve, reject) => {
832
+ if (!header.kid) {
833
+ return reject(new Error('Missing kid in JWT header'));
834
+ }
835
+ client.getSigningKey(header.kid, (err, key) => {
836
+ if (err) return reject(err);
837
+ resolve(key!.getPublicKey());
838
+ });
839
+ });
840
+ }
841
+
842
+ async function validateAccessToken(
843
+ token: string
844
+ ): Promise<JwtPayload> {
845
+ return new Promise((resolve, reject) => {
846
+ jwt.verify(
847
+ token,
848
+ (header, callback) => {
849
+ getSigningKey(header)
850
+ .then(key => callback(null, key))
851
+ .catch(err => callback(err));
852
+ },
853
+ {
854
+ algorithms: ['RS256'],
855
+ issuer: 'https://auth.example.com',
856
+ audience: 'my-api',
857
+ clockTolerance: 30,
858
+ maxAge: '15m',
859
+ },
860
+ (err, decoded) => {
861
+ if (err) return reject(err);
862
+ resolve(decoded as JwtPayload);
863
+ }
864
+ );
865
+ });
866
+ }
867
+ ```
868
+
869
+ ### 10.2 Password Hashing Migration (Python)
870
+
871
+ ```python
872
+ """Migrate legacy MD5/SHA hashes to Argon2id on successful login."""
873
+ import hashlib
874
+ from argon2 import PasswordHasher
875
+ from argon2.exceptions import VerifyMismatchError
876
+
877
+ ph = PasswordHasher(memory_cost=19456, time_cost=2, parallelism=1)
878
+
879
+ def verify_and_migrate(user, password: str) -> bool:
880
+ if user.hash_algorithm == 'argon2id':
881
+ try:
882
+ ph.verify(user.password_hash, password)
883
+ if ph.check_needs_rehash(user.password_hash):
884
+ user.password_hash = ph.hash(password)
885
+ user.save()
886
+ return True
887
+ except VerifyMismatchError:
888
+ return False
889
+
890
+ # Legacy verification then upgrade
891
+ if user.hash_algorithm == 'md5':
892
+ legacy_hash = hashlib.md5(
893
+ (user.salt + password).encode()
894
+ ).hexdigest()
895
+ elif user.hash_algorithm == 'sha256':
896
+ legacy_hash = hashlib.sha256(
897
+ (user.salt + password).encode()
898
+ ).hexdigest()
899
+ else:
900
+ return False
901
+
902
+ if legacy_hash != user.password_hash:
903
+ return False
904
+
905
+ # Upgrade to Argon2id
906
+ user.password_hash = ph.hash(password)
907
+ user.hash_algorithm = 'argon2id'
908
+ user.salt = None # Argon2 manages its own salt
909
+ user.save()
910
+ return True
911
+ ```
912
+
913
+ ### 10.3 Rate Limiter Middleware (TypeScript/Express)
914
+
915
+ ```typescript
916
+ import { Request, Response, NextFunction } from 'express';
917
+ import Redis from 'ioredis';
918
+
919
+ const redis = new Redis();
920
+
921
+ interface RateLimitConfig {
922
+ windowMs: number;
923
+ maxAttempts: number;
924
+ keyPrefix: string;
925
+ }
926
+
927
+ function loginRateLimiter(config: RateLimitConfig) {
928
+ return async (req: Request, res: Response, next: NextFunction) => {
929
+ const ip = req.ip;
930
+ const username = req.body?.email?.toLowerCase() || 'unknown';
931
+ const ipKey = `${config.keyPrefix}:ip:${ip}`;
932
+ const userKey = `${config.keyPrefix}:user:${username}`;
933
+
934
+ const [ipCount, userCount] = await Promise.all([
935
+ incrementAndCount(ipKey, config.windowMs),
936
+ incrementAndCount(userKey, config.windowMs),
937
+ ]);
938
+
939
+ if (userCount > config.maxAttempts) {
940
+ res.set('Retry-After', String(config.windowMs / 1000));
941
+ return res.status(429).json({
942
+ error: 'Too many login attempts. Please try again later.',
943
+ });
944
+ }
945
+
946
+ if (ipCount > config.maxAttempts * 10) {
947
+ res.set('Retry-After', String(config.windowMs / 1000));
948
+ return res.status(429).json({
949
+ error: 'Too many requests. Please try again later.',
950
+ });
951
+ }
952
+
953
+ next();
954
+ };
955
+ }
956
+
957
+ async function incrementAndCount(
958
+ key: string, windowMs: number
959
+ ): Promise<number> {
960
+ const now = Date.now();
961
+ const multi = redis.multi();
962
+ multi.zremrangebyscore(key, 0, now - windowMs);
963
+ multi.zadd(key, now.toString(), `${now}:${Math.random()}`);
964
+ multi.zcard(key);
965
+ multi.pexpire(key, windowMs);
966
+ const results = await multi.exec();
967
+ return (results?.[2]?.[1] as number) || 0;
968
+ }
969
+
970
+ // Usage
971
+ app.post('/api/login',
972
+ loginRateLimiter({
973
+ windowMs: 15 * 60 * 1000,
974
+ maxAttempts: 5,
975
+ keyPrefix: 'rl:login',
976
+ }),
977
+ loginHandler
978
+ );
979
+ ```
980
+
981
+ ### 10.4 Constant-Time Comparison
982
+
983
+ ```typescript
984
+ // TypeScript/Node.js
985
+ import crypto from 'node:crypto';
986
+
987
+ function safeCompare(a: string, b: string): boolean {
988
+ const bufA = Buffer.from(a);
989
+ const bufB = Buffer.from(b);
990
+ const hashA = crypto.createHash('sha256').update(bufA).digest();
991
+ const hashB = crypto.createHash('sha256').update(bufB).digest();
992
+ return crypto.timingSafeEqual(hashA, hashB);
993
+ }
994
+ ```
995
+
996
+ ```python
997
+ # Python
998
+ import hmac
999
+
1000
+ def safe_compare(a: str, b: str) -> bool:
1001
+ return hmac.compare_digest(a.encode(), b.encode())
1002
+ ```
1003
+
1004
+ ---
1005
+
1006
+ ## Passkey Adoption Status (2025)
1007
+
1008
+ As of 2025, passkeys have reached mainstream adoption:
1009
+
1010
+ - **69% of users** have at least one passkey; awareness at 74-75%
1011
+ - **3 billion+ passkeys** in active use globally
1012
+ - **48% of top 100 websites** support passkeys (doubled since 2022)
1013
+ - **87% of businesses** have deployed or are deploying passkeys
1014
+ - **NIST formally recognizes** passkeys as syncable authenticators at AAL2
1015
+ - Apple, Google, and Microsoft provide native passkey support across all platforms
1016
+ - Mobile adoption at 55-60%; desktop at ~20%
1017
+
1018
+ Organizations should begin passkey deployment now and plan for password deprecation.
1019
+
1020
+ ---
1021
+
1022
+ ## References
1023
+
1024
+ - [OWASP Authentication Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html)
1025
+ - [OWASP MFA Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Multifactor_Authentication_Cheat_Sheet.html)
1026
+ - [OWASP Password Storage Cheat Sheet](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Password_Storage_Cheat_Sheet.md)
1027
+ - [OWASP Credential Stuffing Prevention](https://cheatsheetseries.owasp.org/cheatsheets/Credential_Stuffing_Prevention_Cheat_Sheet.html)
1028
+ - [OWASP Session Management Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html)
1029
+ - [NIST SP 800-63B-4](https://csrc.nist.gov/pubs/sp/800/63/b/4/final)
1030
+ - [OWASP ASVS v5.0 - V2 Authentication](https://github.com/OWASP/ASVS/blob/master/4.0/en/0x11-V2-Authentication.md)
1031
+ - [FIDO Alliance - Passkey Adoption 2025](https://fidoalliance.org/fido-alliance-champions-widespread-passkey-adoption-and-a-passwordless-future-on-world-passkey-day-2025/)
1032
+ - [Verizon 2025 DBIR - Credential Stuffing](https://www.verizon.com/business/resources/articles/credential-stuffing-attacks-2025-dbir-research/)
1033
+ - [PCI DSS 4.0 Auth Requirements](https://www.hypr.com/blog/pci-dss-4-password-mfa-requirements)
1034
+ - [CWE-208: Observable Timing Discrepancy](https://cwe.mitre.org/data/definitions/208.html)
1035
+ - [CWE-384: Session Fixation](https://cwe.mitre.org/data/definitions/384.html)
1036
+ - [CWE-204: Observable Response Discrepancy](https://cwe.mitre.org/data/definitions/204.html)
1037
+ - [PortSwigger - JWT Attacks](https://portswigger.net/web-security/jwt)
1038
+ - [Snowflake Breach 2024](https://cloudsecurityalliance.org/blog/2025/05/07/unpacking-the-2024-snowflake-data-breach)
1039
+ - [Uber 2022 Breach](https://www.darkreading.com/cyberattacks-data-breaches/uber-breach-external-contractor-mfa-bombing-attack)
1040
+ - [Colonial Pipeline Attack](https://thehackernews.com/2021/06/hackers-breached-colonial-pipeline.html)
1041
+ - [Okta 2023 Support Breach](https://sec.okta.com/articles/2023/11/unauthorized-access-oktas-support-case-management-system-root-cause/)