@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,1337 @@
|
|
|
1
|
+
# Network Security — Security Expertise Module
|
|
2
|
+
|
|
3
|
+
> **Purpose:** Comprehensive reference for AI agents to implement secure network architectures,
|
|
4
|
+
> prevent network-layer attacks, and enforce defense-in-depth across cloud and on-premise
|
|
5
|
+
> environments.
|
|
6
|
+
>
|
|
7
|
+
> **Last updated:** 2026-03-08
|
|
8
|
+
> **Sources:** NIST SP 800-207 (Zero Trust Architecture), NIST SP 800-53 Rev 5, OWASP SSRF
|
|
9
|
+
> Prevention Cheat Sheet, PCI-DSS v4.0.1, CISA Zero Trust Guidance, Cloudflare DDoS Reports
|
|
10
|
+
> 2024, Verizon DBIR 2024, CWE/MITRE, vendor documentation (AWS, GCP, Kubernetes).
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 1. Threat Landscape
|
|
15
|
+
|
|
16
|
+
### 1.1 Scale of the Problem
|
|
17
|
+
|
|
18
|
+
Network-layer attacks remain among the most damaging vectors in cybersecurity. The attack
|
|
19
|
+
surface has expanded dramatically with cloud adoption, microservices, and remote work:
|
|
20
|
+
|
|
21
|
+
- **DDoS attacks increased 49%** in Q3 2024, with record-breaking attacks reaching
|
|
22
|
+
**4.2 terabits per second** (Cloudflare).
|
|
23
|
+
- **SSRF (CWE-918)** entered the OWASP Top 10 in 2021 and remains a critical threat in
|
|
24
|
+
cloud-native environments where metadata services expose credentials.
|
|
25
|
+
- **Lateral movement** is present in **70% of successful breaches** — attackers who gain
|
|
26
|
+
initial access pivot through flat networks to reach high-value targets.
|
|
27
|
+
- **DNS attacks** affect **90% of organizations** annually, with DNS tunneling and cache
|
|
28
|
+
poisoning among the most common vectors (IDC Global DNS Threat Report).
|
|
29
|
+
- The average **breakout time** (initial access to lateral movement) is **48 minutes**
|
|
30
|
+
(CrowdStrike 2024 Global Threat Report).
|
|
31
|
+
- **Man-in-the-middle (MITM)** attacks exploit unencrypted internal traffic — a problem
|
|
32
|
+
worsened by the misconception that internal networks are inherently trusted.
|
|
33
|
+
|
|
34
|
+
### 1.2 Common Network Attack Vectors
|
|
35
|
+
|
|
36
|
+
| Attack Vector | Description | Impact |
|
|
37
|
+
|----------------------------|------------------------------------------------------------------|------------|
|
|
38
|
+
| SSRF (CWE-918) | Server makes requests to attacker-controlled destinations | Critical |
|
|
39
|
+
| DDoS (Volumetric/App) | Overwhelms resources with traffic or application-layer requests | High |
|
|
40
|
+
| DNS Cache Poisoning | Corrupts DNS resolver cache to redirect traffic | High |
|
|
41
|
+
| DNS Tunneling | Exfiltrates data by encoding it in DNS queries | High |
|
|
42
|
+
| Man-in-the-Middle (MITM) | Intercepts unencrypted communication between services | Critical |
|
|
43
|
+
| Lateral Movement | Pivots from compromised host to other internal systems | Critical |
|
|
44
|
+
| Network Sniffing | Captures unencrypted traffic on shared network segments | High |
|
|
45
|
+
| ARP Spoofing | Redirects local network traffic via forged ARP responses | Medium |
|
|
46
|
+
| BGP Hijacking | Redirects internet traffic by announcing false routing info | Critical |
|
|
47
|
+
| Port Scanning/Enumeration | Discovers exposed services and open ports for exploitation | Medium |
|
|
48
|
+
|
|
49
|
+
### 1.3 Real-World Breaches
|
|
50
|
+
|
|
51
|
+
**Capital One (2019) — SSRF via Metadata Service**
|
|
52
|
+
A former AWS employee exploited a Server-Side Request Forgery (SSRF) vulnerability in Capital
|
|
53
|
+
One's misconfigured Web Application Firewall (WAF). The attacker crafted requests that
|
|
54
|
+
reached the AWS EC2 instance metadata service at `169.254.169.254`, retrieving temporary IAM
|
|
55
|
+
role credentials. These credentials had overly permissive S3 access, allowing the attacker to
|
|
56
|
+
exfiltrate data on **106 million customers**, including Social Security numbers, bank account
|
|
57
|
+
numbers, and credit scores. The breach went undetected for four months (March to July 2019).
|
|
58
|
+
AWS subsequently released IMDSv2, requiring session tokens for metadata access. Capital One
|
|
59
|
+
was fined **$80 million** by the OCC.
|
|
60
|
+
|
|
61
|
+
Key lessons:
|
|
62
|
+
- SSRF + cloud metadata services = credential theft at scale
|
|
63
|
+
- WAF components should never have broad S3 read permissions (least privilege)
|
|
64
|
+
- IMDSv2 with hop limit of 1 blocks SSRF-based metadata access
|
|
65
|
+
- Egress filtering would have prevented the WAF from reaching the metadata endpoint
|
|
66
|
+
|
|
67
|
+
**SolarWinds (2020) — Supply Chain to Lateral Movement**
|
|
68
|
+
Russian state-sponsored attackers (APT29/Cozy Bear) compromised the SolarWinds Orion build
|
|
69
|
+
system, injecting the SUNBURST backdoor into updates distributed to approximately 18,000
|
|
70
|
+
organizations. Once inside target networks, the attackers employed sophisticated lateral
|
|
71
|
+
movement techniques:
|
|
72
|
+
- **TEARDROP** malware dropped Cobalt Strike BEACON payloads for lateral movement
|
|
73
|
+
- **Raindrop** malware spread across victim networks to additional hosts
|
|
74
|
+
- **Golden Ticket attacks** forged Kerberos tickets for domain-wide access
|
|
75
|
+
- **Token manipulation** spoofed authentication tokens to move between systems
|
|
76
|
+
- Attackers used legitimate tools (PsExec, RDP, PowerShell) to blend with normal activity
|
|
77
|
+
|
|
78
|
+
The attackers maintained persistent access to US federal agencies and Fortune 500 companies
|
|
79
|
+
for over 9 months before detection. The breach demonstrated that flat internal networks with
|
|
80
|
+
implicit trust allow catastrophic lateral movement.
|
|
81
|
+
|
|
82
|
+
Key lessons:
|
|
83
|
+
- Network segmentation limits blast radius of supply chain compromises
|
|
84
|
+
- Zero trust architecture would have required re-authentication at each segment boundary
|
|
85
|
+
- East-west traffic monitoring is as critical as perimeter monitoring
|
|
86
|
+
- Behavioral analytics can detect anomalous internal access patterns
|
|
87
|
+
|
|
88
|
+
### 1.4 Emerging Trends
|
|
89
|
+
|
|
90
|
+
- **SSRF in cloud-native**: Container orchestration, serverless functions, and service meshes
|
|
91
|
+
create new SSRF targets (Kubernetes API server, cloud metadata endpoints)
|
|
92
|
+
- **Zero trust adoption**: Gartner projects 10% of large enterprises will have mature zero
|
|
93
|
+
trust programs by 2026, up from less than 1% in 2022
|
|
94
|
+
- **AI-powered DDoS**: Attacks increasingly use AI to adapt patterns in real-time, evading
|
|
95
|
+
static mitigation rules
|
|
96
|
+
- **Encrypted traffic abuse**: Attackers hide C2 traffic in legitimate TLS connections,
|
|
97
|
+
requiring TLS inspection at network boundaries
|
|
98
|
+
- **API-layer attacks**: Network security must extend to API gateways as east-west API
|
|
99
|
+
traffic grows exponentially in microservice architectures
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 2. Core Security Principles
|
|
104
|
+
|
|
105
|
+
### 2.1 Defense in Depth
|
|
106
|
+
|
|
107
|
+
No single control is sufficient. Layer network defenses so that failure of one control does
|
|
108
|
+
not result in a breach:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
Internet → CDN/DDoS Protection → WAF → Load Balancer → Network Firewall
|
|
112
|
+
→ Security Group → Subnet ACL → Host Firewall → Application Controls
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Each layer filters progressively more specific threats. Perimeter controls stop volumetric
|
|
116
|
+
attacks; inner layers enforce application-specific policies.
|
|
117
|
+
|
|
118
|
+
### 2.2 Zero Trust Architecture (NIST SP 800-207)
|
|
119
|
+
|
|
120
|
+
Core tenets:
|
|
121
|
+
1. **Never trust, always verify** — No implicit trust based on network location
|
|
122
|
+
2. **Assume breach** — Design controls assuming attackers are already inside
|
|
123
|
+
3. **Verify explicitly** — Authenticate and authorize every access request using identity,
|
|
124
|
+
device posture, and context
|
|
125
|
+
4. **Least privilege access** — Grant minimum permissions per session
|
|
126
|
+
5. **All communication secured** — Encrypt all traffic regardless of network location
|
|
127
|
+
6. **Per-session access** — No persistent access grants; re-evaluate continuously
|
|
128
|
+
|
|
129
|
+
Zero trust components (NIST 800-207):
|
|
130
|
+
- **Policy Engine (PE)**: Decides whether to grant access based on policy
|
|
131
|
+
- **Policy Administrator (PA)**: Establishes or shuts down communication paths
|
|
132
|
+
- **Policy Enforcement Point (PEP)**: Enables, monitors, and terminates connections
|
|
133
|
+
|
|
134
|
+
### 2.3 Network Segmentation
|
|
135
|
+
|
|
136
|
+
Divide networks into isolated zones with controlled communication paths:
|
|
137
|
+
|
|
138
|
+
- **DMZ**: Public-facing services isolated from internal networks
|
|
139
|
+
- **Application tier**: Business logic services, no direct internet access
|
|
140
|
+
- **Data tier**: Databases and storage, accessible only from application tier
|
|
141
|
+
- **Management plane**: Administrative access via bastion hosts or VPN only
|
|
142
|
+
- **Microsegmentation**: Per-workload policies (e.g., Kubernetes NetworkPolicy, VM-level
|
|
143
|
+
security groups) that restrict communication to only declared dependencies
|
|
144
|
+
|
|
145
|
+
### 2.4 Least Privilege Network Access
|
|
146
|
+
|
|
147
|
+
- Services should only be able to reach the specific hosts and ports they need
|
|
148
|
+
- Default-deny firewall rules: block everything, then allow specific flows
|
|
149
|
+
- Separate management traffic from data traffic
|
|
150
|
+
- Restrict outbound (egress) traffic to known-good destinations
|
|
151
|
+
|
|
152
|
+
### 2.5 Mutual TLS (mTLS)
|
|
153
|
+
|
|
154
|
+
Encrypt and authenticate all service-to-service communication:
|
|
155
|
+
- Both client and server present certificates, proving identity
|
|
156
|
+
- Prevents MITM, eavesdropping, and unauthorized service impersonation
|
|
157
|
+
- Service meshes (Istio, Linkerd) automate mTLS across microservices
|
|
158
|
+
- Use TLS 1.3 for all new deployments — stronger cipher suites, faster handshake
|
|
159
|
+
|
|
160
|
+
### 2.6 Egress Filtering
|
|
161
|
+
|
|
162
|
+
Control what leaves your network, not just what enters:
|
|
163
|
+
- Block all outbound traffic by default; allow only known destinations
|
|
164
|
+
- Prevents data exfiltration, C2 communication, and SSRF exploitation
|
|
165
|
+
- Log all egress traffic for forensic analysis
|
|
166
|
+
- Use DNS-based filtering to block connections to known malicious domains
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## 3. Implementation Patterns
|
|
171
|
+
|
|
172
|
+
### 3.1 SSRF Prevention
|
|
173
|
+
|
|
174
|
+
SSRF is the most critical network vulnerability in cloud environments. A multi-layered
|
|
175
|
+
approach is required:
|
|
176
|
+
|
|
177
|
+
**Layer 1: Input Validation and URL Allowlisting**
|
|
178
|
+
```typescript
|
|
179
|
+
// VULNERABLE: No URL validation — attacker controls destination
|
|
180
|
+
async function fetchUrl(req: Request, res: Response) {
|
|
181
|
+
const url = req.query.url as string;
|
|
182
|
+
const response = await fetch(url); // SSRF: attacker can target internal services
|
|
183
|
+
res.json(await response.json());
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// SECURE: Strict URL allowlist with validation
|
|
187
|
+
import { URL } from 'url';
|
|
188
|
+
import net from 'net';
|
|
189
|
+
|
|
190
|
+
const ALLOWED_HOSTS = new Set([
|
|
191
|
+
'api.example.com',
|
|
192
|
+
'cdn.example.com',
|
|
193
|
+
'images.example.com',
|
|
194
|
+
]);
|
|
195
|
+
|
|
196
|
+
const BLOCKED_IP_RANGES = [
|
|
197
|
+
/^127\./, // Loopback
|
|
198
|
+
/^10\./, // RFC 1918 Class A
|
|
199
|
+
/^172\.(1[6-9]|2\d|3[01])\./, // RFC 1918 Class B
|
|
200
|
+
/^192\.168\./, // RFC 1918 Class C
|
|
201
|
+
/^169\.254\./, // Link-local (AWS metadata!)
|
|
202
|
+
/^0\./, // Current network
|
|
203
|
+
/^::1$/, // IPv6 loopback
|
|
204
|
+
/^fc00:/, // IPv6 ULA
|
|
205
|
+
/^fe80:/, // IPv6 link-local
|
|
206
|
+
];
|
|
207
|
+
|
|
208
|
+
function isBlockedIP(ip: string): boolean {
|
|
209
|
+
return BLOCKED_IP_RANGES.some(range => range.test(ip));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async function resolveAndValidate(urlString: string): Promise<URL> {
|
|
213
|
+
let parsed: URL;
|
|
214
|
+
try {
|
|
215
|
+
parsed = new URL(urlString);
|
|
216
|
+
} catch {
|
|
217
|
+
throw new Error('Invalid URL format');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Protocol allowlist — only HTTPS
|
|
221
|
+
if (parsed.protocol !== 'https:') {
|
|
222
|
+
throw new Error('Only HTTPS URLs are allowed');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Host allowlist
|
|
226
|
+
if (!ALLOWED_HOSTS.has(parsed.hostname)) {
|
|
227
|
+
throw new Error(`Host not in allowlist: ${parsed.hostname}`);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// DNS resolution check — prevent DNS rebinding
|
|
231
|
+
const { address } = await import('dns').then(dns =>
|
|
232
|
+
dns.promises.resolve4(parsed.hostname).then(addrs => ({ address: addrs[0] }))
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
if (isBlockedIP(address)) {
|
|
236
|
+
throw new Error('Resolved IP is in a blocked range');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return parsed;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async function fetchUrlSecure(req: Request, res: Response) {
|
|
243
|
+
try {
|
|
244
|
+
const validatedUrl = await resolveAndValidate(req.query.url as string);
|
|
245
|
+
const controller = new AbortController();
|
|
246
|
+
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
247
|
+
|
|
248
|
+
const response = await fetch(validatedUrl.toString(), {
|
|
249
|
+
signal: controller.signal,
|
|
250
|
+
redirect: 'error', // Do not follow redirects (redirect-based SSRF bypass)
|
|
251
|
+
});
|
|
252
|
+
clearTimeout(timeout);
|
|
253
|
+
|
|
254
|
+
res.json(await response.json());
|
|
255
|
+
} catch (error) {
|
|
256
|
+
res.status(400).json({ error: 'Request blocked by security policy' });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
**Layer 2: Cloud Metadata Service Protection**
|
|
262
|
+
```bash
|
|
263
|
+
# AWS: Enforce IMDSv2 (requires session token, blocks SSRF from containers)
|
|
264
|
+
aws ec2 modify-instance-metadata-options \
|
|
265
|
+
--instance-id i-1234567890abcdef0 \
|
|
266
|
+
--http-tokens required \
|
|
267
|
+
--http-put-response-hop-limit 1 \
|
|
268
|
+
--http-endpoint enabled
|
|
269
|
+
|
|
270
|
+
# GCP: Disable legacy metadata endpoint
|
|
271
|
+
# Set metadata header requirement in instance template
|
|
272
|
+
gcloud compute instances add-metadata INSTANCE_NAME \
|
|
273
|
+
--metadata disable-legacy-endpoints=true
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Layer 3: Network-Level Controls**
|
|
277
|
+
```bash
|
|
278
|
+
# iptables: Block outbound requests to metadata service from application containers
|
|
279
|
+
iptables -A OUTPUT -d 169.254.169.254 -j DROP
|
|
280
|
+
|
|
281
|
+
# AWS Security Group: Restrict outbound to specific destinations only
|
|
282
|
+
# (Default security groups allow all outbound — change this)
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### 3.2 Network Segmentation
|
|
286
|
+
|
|
287
|
+
**AWS VPC Architecture:**
|
|
288
|
+
```hcl
|
|
289
|
+
# Terraform: Three-tier VPC with strict segmentation
|
|
290
|
+
resource "aws_vpc" "main" {
|
|
291
|
+
cidr_block = "10.0.0.0/16"
|
|
292
|
+
enable_dns_support = true
|
|
293
|
+
enable_dns_hostnames = true
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
# Public subnet — load balancers only, no direct app access
|
|
297
|
+
resource "aws_subnet" "public" {
|
|
298
|
+
vpc_id = aws_vpc.main.id
|
|
299
|
+
cidr_block = "10.0.1.0/24"
|
|
300
|
+
availability_zone = "us-east-1a"
|
|
301
|
+
map_public_ip_on_launch = false # No auto-assign public IPs
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
# Private subnet — application tier
|
|
305
|
+
resource "aws_subnet" "app" {
|
|
306
|
+
vpc_id = aws_vpc.main.id
|
|
307
|
+
cidr_block = "10.0.10.0/24"
|
|
308
|
+
availability_zone = "us-east-1a"
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
# Isolated subnet — databases, no internet access
|
|
312
|
+
resource "aws_subnet" "data" {
|
|
313
|
+
vpc_id = aws_vpc.main.id
|
|
314
|
+
cidr_block = "10.0.20.0/24"
|
|
315
|
+
availability_zone = "us-east-1a"
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
# Network ACL: Data tier only accepts traffic from app tier
|
|
319
|
+
resource "aws_network_acl" "data_tier" {
|
|
320
|
+
vpc_id = aws_vpc.main.id
|
|
321
|
+
subnet_ids = [aws_subnet.data.id]
|
|
322
|
+
|
|
323
|
+
ingress {
|
|
324
|
+
rule_no = 100
|
|
325
|
+
protocol = "tcp"
|
|
326
|
+
action = "allow"
|
|
327
|
+
cidr_block = "10.0.10.0/24" # App tier only
|
|
328
|
+
from_port = 5432 # PostgreSQL
|
|
329
|
+
to_port = 5432
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
ingress {
|
|
333
|
+
rule_no = 999
|
|
334
|
+
protocol = "-1"
|
|
335
|
+
action = "deny"
|
|
336
|
+
cidr_block = "0.0.0.0/0" # Deny everything else
|
|
337
|
+
from_port = 0
|
|
338
|
+
to_port = 0
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
egress {
|
|
342
|
+
rule_no = 100
|
|
343
|
+
protocol = "tcp"
|
|
344
|
+
action = "allow"
|
|
345
|
+
cidr_block = "10.0.10.0/24"
|
|
346
|
+
from_port = 1024
|
|
347
|
+
to_port = 65535 # Ephemeral ports for responses
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### 3.3 mTLS Implementation
|
|
353
|
+
|
|
354
|
+
**Node.js mTLS Server and Client:**
|
|
355
|
+
```typescript
|
|
356
|
+
import https from 'https';
|
|
357
|
+
import fs from 'fs';
|
|
358
|
+
import tls from 'tls';
|
|
359
|
+
|
|
360
|
+
// mTLS Server — requires client certificate
|
|
361
|
+
const serverOptions: https.ServerOptions = {
|
|
362
|
+
key: fs.readFileSync('/certs/server-key.pem'),
|
|
363
|
+
cert: fs.readFileSync('/certs/server-cert.pem'),
|
|
364
|
+
ca: fs.readFileSync('/certs/ca-cert.pem'), // CA that signed client certs
|
|
365
|
+
requestCert: true, // Require client certificate
|
|
366
|
+
rejectUnauthorized: true, // Reject connections without valid client cert
|
|
367
|
+
minVersion: 'TLSv1.3' as tls.SecureVersion, // Enforce TLS 1.3
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
const server = https.createServer(serverOptions, (req, res) => {
|
|
371
|
+
const clientCert = req.socket.getPeerCertificate();
|
|
372
|
+
console.log(`Authenticated client: ${clientCert.subject.CN}`);
|
|
373
|
+
res.writeHead(200);
|
|
374
|
+
res.end(JSON.stringify({ status: 'authenticated', client: clientCert.subject.CN }));
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
server.listen(8443);
|
|
378
|
+
|
|
379
|
+
// mTLS Client — presents client certificate
|
|
380
|
+
const clientOptions: https.RequestOptions = {
|
|
381
|
+
hostname: 'service.internal',
|
|
382
|
+
port: 8443,
|
|
383
|
+
path: '/api/data',
|
|
384
|
+
method: 'GET',
|
|
385
|
+
key: fs.readFileSync('/certs/client-key.pem'),
|
|
386
|
+
cert: fs.readFileSync('/certs/client-cert.pem'),
|
|
387
|
+
ca: fs.readFileSync('/certs/ca-cert.pem'),
|
|
388
|
+
minVersion: 'TLSv1.3' as tls.SecureVersion,
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
const req = https.request(clientOptions, (res) => {
|
|
392
|
+
res.on('data', (data) => console.log(data.toString()));
|
|
393
|
+
});
|
|
394
|
+
req.end();
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**Istio Service Mesh — Mesh-wide Strict mTLS:**
|
|
398
|
+
```yaml
|
|
399
|
+
# PeerAuthentication: enforce mTLS for all services in the mesh
|
|
400
|
+
apiVersion: security.istio.io/v1beta1
|
|
401
|
+
kind: PeerAuthentication
|
|
402
|
+
metadata:
|
|
403
|
+
name: default
|
|
404
|
+
namespace: istio-system # Mesh-wide policy
|
|
405
|
+
spec:
|
|
406
|
+
mtls:
|
|
407
|
+
mode: STRICT # Only accept mTLS connections
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
# DestinationRule: ensure all outgoing traffic uses mTLS
|
|
411
|
+
apiVersion: networking.istio.io/v1beta1
|
|
412
|
+
kind: DestinationRule
|
|
413
|
+
metadata:
|
|
414
|
+
name: default
|
|
415
|
+
namespace: istio-system
|
|
416
|
+
spec:
|
|
417
|
+
host: "*.local"
|
|
418
|
+
trafficPolicy:
|
|
419
|
+
tls:
|
|
420
|
+
mode: ISTIO_MUTUAL # Use Istio-managed certificates
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### 3.4 DNS Security
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
# BIND DNSSEC configuration — sign your zones
|
|
427
|
+
# Generate Zone Signing Key (ZSK) and Key Signing Key (KSK)
|
|
428
|
+
dnssec-keygen -a ECDSAP256SHA256 -n ZONE example.com # ZSK
|
|
429
|
+
dnssec-keygen -a ECDSAP256SHA256 -n ZONE -f KSK example.com # KSK
|
|
430
|
+
|
|
431
|
+
# Sign the zone
|
|
432
|
+
dnssec-signzone -A -3 $(head -c 1000 /dev/urandom | sha1sum | cut -b 1-16) \
|
|
433
|
+
-N INCREMENT -o example.com -t example.com.zone
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
DNS transport security options:
|
|
437
|
+
- **DoT (DNS over TLS)**: Uses TCP port 853; encrypted but identifiable as DNS traffic
|
|
438
|
+
- **DoH (DNS over HTTPS)**: Uses TCP port 443; encrypted and indistinguishable from HTTPS
|
|
439
|
+
- **DoQ (DNS over QUIC)**: Emerging standard with lower latency than DoT/DoH
|
|
440
|
+
- **DNSSEC**: Validates DNS response authenticity via cryptographic signatures (does not
|
|
441
|
+
encrypt, complements DoT/DoH)
|
|
442
|
+
|
|
443
|
+
Best practice: Deploy DNSSEC for response validation + DoT/DoH for transport encryption.
|
|
444
|
+
|
|
445
|
+
### 3.5 DDoS Mitigation
|
|
446
|
+
|
|
447
|
+
Multi-layered DDoS defense:
|
|
448
|
+
|
|
449
|
+
```
|
|
450
|
+
Layer 3/4 (Network/Transport):
|
|
451
|
+
├── CDN absorption (Cloudflare, AWS CloudFront, Akamai)
|
|
452
|
+
├── Anycast routing (distribute traffic across global PoPs)
|
|
453
|
+
├── BGP blackholing (last resort for volumetric attacks)
|
|
454
|
+
└── SYN cookies (prevent SYN flood state exhaustion)
|
|
455
|
+
|
|
456
|
+
Layer 7 (Application):
|
|
457
|
+
├── WAF rules (block malicious request patterns)
|
|
458
|
+
├── Rate limiting (per-IP, per-API-key, per-geo)
|
|
459
|
+
├── CAPTCHA challenges (for suspected bot traffic)
|
|
460
|
+
└── Request size limits (prevent Slowloris/slow POST)
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
**Rate Limiting Middleware (TypeScript/Express):**
|
|
464
|
+
```typescript
|
|
465
|
+
import rateLimit from 'express-rate-limit';
|
|
466
|
+
import RedisStore from 'rate-limit-redis';
|
|
467
|
+
import Redis from 'ioredis';
|
|
468
|
+
|
|
469
|
+
const redis = new Redis({ host: 'redis.internal', port: 6379, tls: {} });
|
|
470
|
+
|
|
471
|
+
// General API rate limit
|
|
472
|
+
const apiLimiter = rateLimit({
|
|
473
|
+
store: new RedisStore({ sendCommand: (...args: string[]) => redis.call(...args) }),
|
|
474
|
+
windowMs: 15 * 60 * 1000, // 15-minute window
|
|
475
|
+
max: 100, // 100 requests per window per IP
|
|
476
|
+
standardHeaders: true,
|
|
477
|
+
legacyHeaders: false,
|
|
478
|
+
keyGenerator: (req) => {
|
|
479
|
+
// Use X-Forwarded-For behind trusted proxy, fall back to IP
|
|
480
|
+
return req.ip || req.socket.remoteAddress || 'unknown';
|
|
481
|
+
},
|
|
482
|
+
handler: (req, res) => {
|
|
483
|
+
res.status(429).json({
|
|
484
|
+
error: 'Too many requests',
|
|
485
|
+
retryAfter: res.getHeader('Retry-After'),
|
|
486
|
+
});
|
|
487
|
+
},
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
// Strict rate limit for authentication endpoints
|
|
491
|
+
const authLimiter = rateLimit({
|
|
492
|
+
windowMs: 15 * 60 * 1000,
|
|
493
|
+
max: 5, // Only 5 login attempts per 15 minutes
|
|
494
|
+
skipSuccessfulRequests: true, // Don't count successful logins
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
app.use('/api/', apiLimiter);
|
|
498
|
+
app.use('/api/auth/login', authLimiter);
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
### 3.6 Egress Filtering
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
# iptables: Default-deny outbound, allow only specific destinations
|
|
505
|
+
# Drop all outbound traffic by default
|
|
506
|
+
iptables -P OUTPUT DROP
|
|
507
|
+
|
|
508
|
+
# Allow DNS to internal resolver only
|
|
509
|
+
iptables -A OUTPUT -p udp --dport 53 -d 10.0.0.2 -j ACCEPT
|
|
510
|
+
iptables -A OUTPUT -p tcp --dport 53 -d 10.0.0.2 -j ACCEPT
|
|
511
|
+
|
|
512
|
+
# Allow HTTPS to specific external services
|
|
513
|
+
iptables -A OUTPUT -p tcp --dport 443 -d api.stripe.com -j ACCEPT
|
|
514
|
+
iptables -A OUTPUT -p tcp --dport 443 -d api.github.com -j ACCEPT
|
|
515
|
+
|
|
516
|
+
# Allow established connections (responses to allowed outbound)
|
|
517
|
+
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
|
|
518
|
+
|
|
519
|
+
# Log and drop everything else
|
|
520
|
+
iptables -A OUTPUT -j LOG --log-prefix "EGRESS_BLOCKED: "
|
|
521
|
+
iptables -A OUTPUT -j DROP
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### 3.7 Bastion Hosts and VPN Alternatives
|
|
525
|
+
|
|
526
|
+
Traditional bastion/jump host pattern:
|
|
527
|
+
- Single hardened SSH entry point for administrative access
|
|
528
|
+
- All admin traffic tunneled through bastion; no direct access to internal hosts
|
|
529
|
+
- Session logging and MFA required on bastion
|
|
530
|
+
|
|
531
|
+
Modern alternatives:
|
|
532
|
+
- **WireGuard**: Lightweight kernel-level VPN; minimal attack surface, ~4,000 lines of code
|
|
533
|
+
vs OpenVPN's ~100,000
|
|
534
|
+
- **Tailscale**: WireGuard-based mesh VPN with identity-aware access; no exposed ports
|
|
535
|
+
- **Cloudflare Access / AWS SSM Session Manager**: Zero-trust alternatives that eliminate
|
|
536
|
+
the need for VPNs or bastions entirely; access granted per-session based on identity
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
## 4. Vulnerability Catalog
|
|
541
|
+
|
|
542
|
+
### 4.1 SSRF — Server-Side Request Forgery (CWE-918)
|
|
543
|
+
|
|
544
|
+
**Severity:** Critical | **CVSS:** 7.5-9.8
|
|
545
|
+
**Description:** Application makes HTTP requests to attacker-controlled URLs, accessing
|
|
546
|
+
internal services, cloud metadata, or arbitrary endpoints.
|
|
547
|
+
**Detection:** Review all code paths that fetch external URLs; scan for `fetch()`, `axios`,
|
|
548
|
+
`http.get()`, `urllib`, `requests.get()` with user-controlled input.
|
|
549
|
+
**Fix:** URL allowlisting, DNS resolution validation, block private IP ranges, enforce
|
|
550
|
+
IMDSv2, disable HTTP redirects in outbound requests.
|
|
551
|
+
|
|
552
|
+
### 4.2 Open DNS Resolver (CWE-406)
|
|
553
|
+
|
|
554
|
+
**Severity:** High | **CVSS:** 7.5
|
|
555
|
+
**Description:** DNS server responds to queries from any source, enabling DNS amplification
|
|
556
|
+
DDoS attacks and cache poisoning.
|
|
557
|
+
**Detection:** `nmap -sU -p 53 --script dns-recursion <target>`
|
|
558
|
+
**Fix:** Restrict recursive queries to internal clients only; configure `allow-recursion`
|
|
559
|
+
in BIND or equivalent.
|
|
560
|
+
|
|
561
|
+
### 4.3 Missing Network Segmentation (CWE-1008)
|
|
562
|
+
|
|
563
|
+
**Severity:** High | **CVSS:** 7.0-9.0
|
|
564
|
+
**Description:** Flat network topology allows unrestricted lateral movement after initial
|
|
565
|
+
compromise.
|
|
566
|
+
**Detection:** Network topology review; attempt cross-tier connectivity tests.
|
|
567
|
+
**Fix:** Implement VPC/VLAN segmentation, security groups, NACLs with default-deny.
|
|
568
|
+
|
|
569
|
+
### 4.4 Permissive Egress Rules (CWE-441)
|
|
570
|
+
|
|
571
|
+
**Severity:** High | **CVSS:** 6.5-8.0
|
|
572
|
+
**Description:** Outbound traffic not restricted, allowing data exfiltration and C2
|
|
573
|
+
communication after compromise.
|
|
574
|
+
**Detection:** Review security group and firewall egress rules; test outbound connectivity
|
|
575
|
+
to arbitrary hosts.
|
|
576
|
+
**Fix:** Default-deny egress; allow only specific required destinations and ports.
|
|
577
|
+
|
|
578
|
+
### 4.5 Unencrypted Internal Traffic (CWE-319)
|
|
579
|
+
|
|
580
|
+
**Severity:** High | **CVSS:** 6.5-7.5
|
|
581
|
+
**Description:** Service-to-service communication uses plaintext HTTP, allowing MITM
|
|
582
|
+
attacks and credential interception on internal networks.
|
|
583
|
+
**Detection:** Network traffic capture; check for HTTP (not HTTPS) on internal ports.
|
|
584
|
+
**Fix:** Enforce mTLS for all service-to-service communication; use service mesh.
|
|
585
|
+
|
|
586
|
+
### 4.6 Exposed Management Ports (CWE-284)
|
|
587
|
+
|
|
588
|
+
**Severity:** Critical | **CVSS:** 8.0-9.8
|
|
589
|
+
**Description:** Administrative interfaces (SSH:22, RDP:3389, database ports, Kubernetes
|
|
590
|
+
API:6443) exposed to the internet or overly broad network ranges.
|
|
591
|
+
**Detection:** `nmap -sV -p 22,3389,5432,3306,6443,8443,9200 <target>`
|
|
592
|
+
**Fix:** Restrict management ports to bastion/VPN only; use security groups; disable
|
|
593
|
+
public IP assignment on management interfaces.
|
|
594
|
+
|
|
595
|
+
### 4.7 Missing DNSSEC Validation (CWE-345)
|
|
596
|
+
|
|
597
|
+
**Severity:** Medium | **CVSS:** 5.9
|
|
598
|
+
**Description:** DNS resolver does not validate DNSSEC signatures, allowing cache poisoning
|
|
599
|
+
and DNS spoofing attacks.
|
|
600
|
+
**Detection:** `dig +dnssec example.com`; verify AD (Authenticated Data) flag in response.
|
|
601
|
+
**Fix:** Enable DNSSEC validation on recursive resolvers; sign authoritative zones.
|
|
602
|
+
|
|
603
|
+
### 4.8 Insecure TLS Configuration (CWE-326)
|
|
604
|
+
|
|
605
|
+
**Severity:** High | **CVSS:** 7.4
|
|
606
|
+
**Description:** Server supports deprecated TLS versions (1.0, 1.1) or weak cipher suites,
|
|
607
|
+
enabling protocol downgrade attacks.
|
|
608
|
+
**Detection:** `nmap --script ssl-enum-ciphers -p 443 <target>` or `testssl.sh`.
|
|
609
|
+
**Fix:** Enforce TLS 1.2+ minimum (TLS 1.3 preferred); disable CBC-mode ciphers;
|
|
610
|
+
use ECDHE key exchange.
|
|
611
|
+
|
|
612
|
+
### 4.9 DNS Rebinding (CWE-350)
|
|
613
|
+
|
|
614
|
+
**Severity:** High | **CVSS:** 7.5
|
|
615
|
+
**Description:** Attacker-controlled DNS alternates between public and private IPs, bypassing
|
|
616
|
+
SSRF protections that only validate at initial resolution time.
|
|
617
|
+
**Detection:** Test URL fetch functions with DNS names that resolve to private IPs after TTL.
|
|
618
|
+
**Fix:** Re-resolve DNS immediately before connection; pin resolved IP; set minimum TTL
|
|
619
|
+
for SSRF validation.
|
|
620
|
+
|
|
621
|
+
### 4.10 Missing Rate Limiting (CWE-770)
|
|
622
|
+
|
|
623
|
+
**Severity:** Medium | **CVSS:** 5.3-7.5
|
|
624
|
+
**Description:** No request rate limits on APIs or authentication endpoints, enabling brute
|
|
625
|
+
force attacks and application-layer DDoS.
|
|
626
|
+
**Detection:** Send high-volume requests and check for 429 responses.
|
|
627
|
+
**Fix:** Implement per-IP and per-user rate limiting with progressive backoff.
|
|
628
|
+
|
|
629
|
+
### 4.11 Unrestricted Cross-Zone Traffic (CWE-923)
|
|
630
|
+
|
|
631
|
+
**Severity:** High | **CVSS:** 7.0
|
|
632
|
+
**Description:** Kubernetes pods or cloud instances can communicate across namespaces or
|
|
633
|
+
security zones without restriction.
|
|
634
|
+
**Detection:** Deploy a test pod and attempt connections to pods in other namespaces.
|
|
635
|
+
**Fix:** Default-deny NetworkPolicy in every namespace; explicit ingress/egress rules.
|
|
636
|
+
|
|
637
|
+
### 4.12 Exposed Cloud Metadata Endpoint (CWE-918)
|
|
638
|
+
|
|
639
|
+
**Severity:** Critical | **CVSS:** 9.0
|
|
640
|
+
**Description:** Cloud instance metadata service (169.254.169.254) accessible to application
|
|
641
|
+
code, enabling credential theft via SSRF.
|
|
642
|
+
**Detection:** `curl http://169.254.169.254/latest/meta-data/` from application container.
|
|
643
|
+
**Fix:** Enforce IMDSv2 (AWS), disable legacy endpoints (GCP), use managed identities with
|
|
644
|
+
minimal permissions.
|
|
645
|
+
|
|
646
|
+
### 4.13 Unmonitored East-West Traffic (CWE-778)
|
|
647
|
+
|
|
648
|
+
**Severity:** Medium | **CVSS:** 5.0-6.5
|
|
649
|
+
**Description:** No logging or monitoring of internal (east-west) network traffic, preventing
|
|
650
|
+
detection of lateral movement.
|
|
651
|
+
**Detection:** Check for VPC flow logs, network monitoring tools, IDS coverage of internal
|
|
652
|
+
segments.
|
|
653
|
+
**Fix:** Enable VPC flow logs, deploy IDS on internal segments, implement behavioral
|
|
654
|
+
analytics for east-west traffic.
|
|
655
|
+
|
|
656
|
+
---
|
|
657
|
+
|
|
658
|
+
## 5. Security Checklist
|
|
659
|
+
|
|
660
|
+
### Network Architecture
|
|
661
|
+
- [ ] Network segmented into security zones (DMZ, app, data, management)
|
|
662
|
+
- [ ] Default-deny firewall rules on all network boundaries
|
|
663
|
+
- [ ] VPC flow logs enabled and shipped to SIEM
|
|
664
|
+
- [ ] No flat network topology — microsegmentation applied
|
|
665
|
+
- [ ] Private subnets have no direct internet access (use NAT gateway)
|
|
666
|
+
- [ ] Management ports accessible only via bastion host or zero-trust proxy
|
|
667
|
+
|
|
668
|
+
### SSRF Prevention
|
|
669
|
+
- [ ] All user-supplied URLs validated against strict allowlist
|
|
670
|
+
- [ ] Private/reserved IP ranges blocked in outbound requests
|
|
671
|
+
- [ ] Cloud metadata endpoint protected (IMDSv2 enforced, hop limit = 1)
|
|
672
|
+
- [ ] HTTP redirects disabled in server-side URL fetching
|
|
673
|
+
- [ ] DNS resolution validated before connection (prevent DNS rebinding)
|
|
674
|
+
|
|
675
|
+
### Encryption & Authentication
|
|
676
|
+
- [ ] mTLS enforced for all service-to-service communication
|
|
677
|
+
- [ ] TLS 1.3 used for all new services; TLS 1.2 minimum for legacy
|
|
678
|
+
- [ ] No plaintext HTTP on any internal or external endpoint
|
|
679
|
+
- [ ] Certificate rotation automated (cert-manager, ACME, or equivalent)
|
|
680
|
+
- [ ] Certificate pinning for critical service-to-service connections
|
|
681
|
+
|
|
682
|
+
### DNS Security
|
|
683
|
+
- [ ] DNSSEC enabled and validated on all resolvers
|
|
684
|
+
- [ ] DNS over TLS (DoT) or DNS over HTTPS (DoH) for transport encryption
|
|
685
|
+
- [ ] DNS query logging enabled for forensic analysis
|
|
686
|
+
- [ ] No open DNS resolvers exposed to the internet
|
|
687
|
+
|
|
688
|
+
### DDoS & Rate Limiting
|
|
689
|
+
- [ ] CDN with DDoS absorption in front of all public endpoints
|
|
690
|
+
- [ ] WAF deployed with OWASP Core Rule Set
|
|
691
|
+
- [ ] Rate limiting on all API endpoints (per-IP and per-user)
|
|
692
|
+
- [ ] Stricter rate limits on authentication endpoints
|
|
693
|
+
- [ ] SYN cookies enabled on all public-facing servers
|
|
694
|
+
|
|
695
|
+
### Egress & Monitoring
|
|
696
|
+
- [ ] Egress traffic filtered — default-deny outbound
|
|
697
|
+
- [ ] All outbound connections logged and monitored
|
|
698
|
+
- [ ] IDS/IPS deployed on internal network segments
|
|
699
|
+
- [ ] Anomalous lateral movement triggers alerts
|
|
700
|
+
- [ ] Regular external penetration tests of network perimeter
|
|
701
|
+
|
|
702
|
+
---
|
|
703
|
+
|
|
704
|
+
## 6. Tools & Automation
|
|
705
|
+
|
|
706
|
+
### Network Scanning & Assessment
|
|
707
|
+
|
|
708
|
+
| Tool | Purpose | Usage |
|
|
709
|
+
|-------------------|----------------------------------------------|--------------------------------------|
|
|
710
|
+
| **nmap** | Port scanning, service enumeration | `nmap -sV -sC -p- target` |
|
|
711
|
+
| **Wireshark** | Packet capture and analysis | GUI analysis of pcap files |
|
|
712
|
+
| **masscan** | High-speed port scanning | `masscan -p0-65535 --rate=10000` |
|
|
713
|
+
| **testssl.sh** | TLS configuration testing | `testssl.sh https://target` |
|
|
714
|
+
| **dig/drill** | DNS interrogation and DNSSEC validation | `dig +dnssec +trace example.com` |
|
|
715
|
+
| **Nuclei** | Vulnerability scanning with templates | `nuclei -u target -t network/` |
|
|
716
|
+
|
|
717
|
+
### Intrusion Detection & Prevention
|
|
718
|
+
|
|
719
|
+
| Tool | Purpose | Deployment |
|
|
720
|
+
|-------------------|----------------------------------------------|--------------------------------------|
|
|
721
|
+
| **Suricata** | IDS/IPS with multi-threading | Inline or passive on network taps |
|
|
722
|
+
| **Snort** | Signature-based IDS/IPS | Network tap or span port |
|
|
723
|
+
| **Zeek (Bro)** | Network traffic analysis and logging | Passive monitoring, metadata logging |
|
|
724
|
+
| **OSSEC/Wazuh** | Host-based intrusion detection | Agent on each host |
|
|
725
|
+
| **Falco** | Runtime container/K8s threat detection | DaemonSet in Kubernetes |
|
|
726
|
+
|
|
727
|
+
### WAF & DDoS Protection
|
|
728
|
+
|
|
729
|
+
| Tool/Service | Purpose | Type |
|
|
730
|
+
|-------------------------|----------------------------------------|------------|
|
|
731
|
+
| **Cloudflare** | CDN, DDoS protection, WAF | SaaS |
|
|
732
|
+
| **AWS Shield + WAF** | AWS-native DDoS and WAF | Cloud |
|
|
733
|
+
| **GCP Cloud Armor** | GCP-native DDoS and WAF | Cloud |
|
|
734
|
+
| **ModSecurity** | Open-source WAF (OWASP CRS) | Self-hosted|
|
|
735
|
+
| **Fastly / Akamai** | CDN with advanced DDoS mitigation | SaaS |
|
|
736
|
+
|
|
737
|
+
### Network Policy & Service Mesh
|
|
738
|
+
|
|
739
|
+
| Tool | Purpose | Platform |
|
|
740
|
+
|-------------------|----------------------------------------------|-------------------------|
|
|
741
|
+
| **Calico** | Kubernetes network policy engine | Kubernetes |
|
|
742
|
+
| **Cilium** | eBPF-based networking and security | Kubernetes |
|
|
743
|
+
| **Istio** | Service mesh with mTLS, traffic control | Kubernetes |
|
|
744
|
+
| **Linkerd** | Lightweight service mesh with mTLS | Kubernetes |
|
|
745
|
+
| **Consul Connect**| Service mesh with intentions-based access | Multi-platform |
|
|
746
|
+
|
|
747
|
+
---
|
|
748
|
+
|
|
749
|
+
## 7. Platform-Specific Guidance
|
|
750
|
+
|
|
751
|
+
### 7.1 AWS VPC Security
|
|
752
|
+
|
|
753
|
+
```hcl
|
|
754
|
+
# Security Group: application tier — strict ingress/egress
|
|
755
|
+
resource "aws_security_group" "app_tier" {
|
|
756
|
+
vpc_id = aws_vpc.main.id
|
|
757
|
+
name = "app-tier-sg"
|
|
758
|
+
|
|
759
|
+
# Ingress: only from load balancer on port 8080
|
|
760
|
+
ingress {
|
|
761
|
+
from_port = 8080
|
|
762
|
+
to_port = 8080
|
|
763
|
+
protocol = "tcp"
|
|
764
|
+
security_groups = [aws_security_group.lb.id]
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
# Egress: only to database tier on PostgreSQL port
|
|
768
|
+
egress {
|
|
769
|
+
from_port = 5432
|
|
770
|
+
to_port = 5432
|
|
771
|
+
protocol = "tcp"
|
|
772
|
+
security_groups = [aws_security_group.data_tier.id]
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
# Egress: HTTPS to specific external services via NAT
|
|
776
|
+
egress {
|
|
777
|
+
from_port = 443
|
|
778
|
+
to_port = 443
|
|
779
|
+
protocol = "tcp"
|
|
780
|
+
cidr_blocks = ["0.0.0.0/0"] # Filtered further by NACL/proxy
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
Key AWS controls:
|
|
786
|
+
- **VPC Flow Logs**: Enable on all VPCs; ship to CloudWatch/S3 for analysis
|
|
787
|
+
- **AWS Network Firewall**: Stateful inspection for VPC traffic; deploy in dedicated subnet
|
|
788
|
+
- **PrivateLink**: Access AWS services without internet exposure
|
|
789
|
+
- **GuardDuty**: ML-based network threat detection (DNS anomalies, unusual traffic patterns)
|
|
790
|
+
- **IMDSv2**: Mandatory for all EC2 instances; blocks SSRF metadata attacks
|
|
791
|
+
|
|
792
|
+
### 7.2 GCP VPC Security
|
|
793
|
+
|
|
794
|
+
Key GCP controls:
|
|
795
|
+
- **VPC Service Controls**: Create security perimeters around GCP services
|
|
796
|
+
- **Shared VPC**: Centralize network administration across projects
|
|
797
|
+
- **Private Google Access**: Access GCP APIs without public IP
|
|
798
|
+
- **Cloud Armor**: WAF and DDoS protection for external load balancers
|
|
799
|
+
- **Packet Mirroring**: Full packet capture for forensic analysis
|
|
800
|
+
- **Firewall Policies**: Hierarchical policies at organization, folder, and project levels
|
|
801
|
+
- Disable legacy metadata endpoint (`disable-legacy-endpoints=true`)
|
|
802
|
+
|
|
803
|
+
### 7.3 Kubernetes Network Policies
|
|
804
|
+
|
|
805
|
+
```yaml
|
|
806
|
+
# Default deny all ingress and egress in a namespace
|
|
807
|
+
apiVersion: networking.k8s.io/v1
|
|
808
|
+
kind: NetworkPolicy
|
|
809
|
+
metadata:
|
|
810
|
+
name: default-deny-all
|
|
811
|
+
namespace: production
|
|
812
|
+
spec:
|
|
813
|
+
podSelector: {} # Applies to ALL pods in namespace
|
|
814
|
+
policyTypes:
|
|
815
|
+
- Ingress
|
|
816
|
+
- Egress
|
|
817
|
+
|
|
818
|
+
---
|
|
819
|
+
# Allow specific traffic: frontend -> backend on port 8080
|
|
820
|
+
apiVersion: networking.k8s.io/v1
|
|
821
|
+
kind: NetworkPolicy
|
|
822
|
+
metadata:
|
|
823
|
+
name: allow-frontend-to-backend
|
|
824
|
+
namespace: production
|
|
825
|
+
spec:
|
|
826
|
+
podSelector:
|
|
827
|
+
matchLabels:
|
|
828
|
+
tier: backend
|
|
829
|
+
policyTypes:
|
|
830
|
+
- Ingress
|
|
831
|
+
ingress:
|
|
832
|
+
- from:
|
|
833
|
+
- podSelector:
|
|
834
|
+
matchLabels:
|
|
835
|
+
tier: frontend
|
|
836
|
+
ports:
|
|
837
|
+
- protocol: TCP
|
|
838
|
+
port: 8080
|
|
839
|
+
|
|
840
|
+
---
|
|
841
|
+
# Backend -> database only, plus DNS for service discovery
|
|
842
|
+
apiVersion: networking.k8s.io/v1
|
|
843
|
+
kind: NetworkPolicy
|
|
844
|
+
metadata:
|
|
845
|
+
name: backend-egress
|
|
846
|
+
namespace: production
|
|
847
|
+
spec:
|
|
848
|
+
podSelector:
|
|
849
|
+
matchLabels:
|
|
850
|
+
tier: backend
|
|
851
|
+
policyTypes:
|
|
852
|
+
- Egress
|
|
853
|
+
egress:
|
|
854
|
+
- to:
|
|
855
|
+
- podSelector:
|
|
856
|
+
matchLabels:
|
|
857
|
+
tier: database
|
|
858
|
+
ports:
|
|
859
|
+
- protocol: TCP
|
|
860
|
+
port: 5432
|
|
861
|
+
- to: # Allow DNS resolution
|
|
862
|
+
- namespaceSelector: {}
|
|
863
|
+
podSelector:
|
|
864
|
+
matchLabels:
|
|
865
|
+
k8s-app: kube-dns
|
|
866
|
+
ports:
|
|
867
|
+
- protocol: UDP
|
|
868
|
+
port: 53
|
|
869
|
+
- protocol: TCP
|
|
870
|
+
port: 53
|
|
871
|
+
|
|
872
|
+
---
|
|
873
|
+
# Block access to cloud metadata from all pods
|
|
874
|
+
apiVersion: networking.k8s.io/v1
|
|
875
|
+
kind: NetworkPolicy
|
|
876
|
+
metadata:
|
|
877
|
+
name: block-metadata-service
|
|
878
|
+
namespace: production
|
|
879
|
+
spec:
|
|
880
|
+
podSelector: {}
|
|
881
|
+
policyTypes:
|
|
882
|
+
- Egress
|
|
883
|
+
egress:
|
|
884
|
+
- to:
|
|
885
|
+
- ipBlock:
|
|
886
|
+
cidr: 0.0.0.0/0
|
|
887
|
+
except:
|
|
888
|
+
- 169.254.169.254/32 # Block cloud metadata endpoint
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
Important: NetworkPolicy requires a CNI plugin that supports it (Calico, Cilium, Weave Net).
|
|
892
|
+
The default kubenet CNI does NOT enforce NetworkPolicy resources.
|
|
893
|
+
|
|
894
|
+
### 7.4 On-Premise Firewalls
|
|
895
|
+
|
|
896
|
+
- Deploy next-generation firewalls (NGFW) at zone boundaries with application-layer inspection
|
|
897
|
+
- Enable IPS functionality with regularly updated signature databases
|
|
898
|
+
- Implement 802.1X for network access control (NAC) on all switch ports
|
|
899
|
+
- Use VLANs to segment network tiers; trunk ports only between network devices
|
|
900
|
+
- Enable DHCP snooping and Dynamic ARP Inspection (DAI) to prevent ARP spoofing
|
|
901
|
+
- Configure port security to limit MAC addresses per port (prevent MAC flooding)
|
|
902
|
+
|
|
903
|
+
---
|
|
904
|
+
|
|
905
|
+
## 8. Incident Patterns
|
|
906
|
+
|
|
907
|
+
### 8.1 SSRF Exploitation Chain
|
|
908
|
+
|
|
909
|
+
```
|
|
910
|
+
1. RECONNAISSANCE
|
|
911
|
+
Attacker identifies URL fetch functionality (webhooks, image proxy, URL preview)
|
|
912
|
+
|
|
913
|
+
2. INITIAL PROBE
|
|
914
|
+
Attacker submits internal URLs: http://169.254.169.254/latest/meta-data/
|
|
915
|
+
or http://localhost:6379/ (Redis), http://localhost:9200/ (Elasticsearch)
|
|
916
|
+
|
|
917
|
+
3. CREDENTIAL THEFT (Cloud)
|
|
918
|
+
GET http://169.254.169.254/latest/meta-data/iam/security-credentials/<role-name>
|
|
919
|
+
→ Returns temporary AccessKeyId, SecretAccessKey, SessionToken
|
|
920
|
+
|
|
921
|
+
4. LATERAL ACCESS
|
|
922
|
+
Attacker uses stolen credentials to access S3 buckets, databases, other AWS services
|
|
923
|
+
|
|
924
|
+
5. DATA EXFILTRATION
|
|
925
|
+
Bulk download of sensitive data using stolen cloud credentials
|
|
926
|
+
|
|
927
|
+
DETECTION SIGNALS:
|
|
928
|
+
- Outbound requests to 169.254.169.254 from application containers
|
|
929
|
+
- Unusual IAM credential usage from unexpected source IPs
|
|
930
|
+
- S3 bucket access patterns deviating from baseline
|
|
931
|
+
- DNS queries for internal hostnames from external-facing services
|
|
932
|
+
|
|
933
|
+
RESPONSE:
|
|
934
|
+
- Immediately revoke compromised IAM credentials
|
|
935
|
+
- Enforce IMDSv2 on all instances
|
|
936
|
+
- Block metadata endpoint at network level
|
|
937
|
+
- Audit all S3 bucket access logs for data exfiltration
|
|
938
|
+
- Patch or disable the vulnerable URL fetch functionality
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
### 8.2 DDoS Detection and Response
|
|
942
|
+
|
|
943
|
+
```
|
|
944
|
+
DETECTION:
|
|
945
|
+
- Traffic volume exceeds baseline by 5-10x within minutes
|
|
946
|
+
- Spike in connections from geographically unusual sources
|
|
947
|
+
- Increased error rates (503, connection timeouts)
|
|
948
|
+
- CDN/WAF alerts on anomalous traffic patterns
|
|
949
|
+
|
|
950
|
+
TRIAGE (first 5 minutes):
|
|
951
|
+
- Confirm attack type: volumetric (L3/4) vs application-layer (L7)
|
|
952
|
+
- Engage CDN/DDoS protection provider's SOC
|
|
953
|
+
- Enable "Under Attack" mode if available (e.g., Cloudflare)
|
|
954
|
+
|
|
955
|
+
MITIGATION:
|
|
956
|
+
- L3/4: Activate upstream scrubbing; apply rate limits at edge; enable SYN cookies
|
|
957
|
+
- L7: Deploy WAF rules targeting attack signature; enable CAPTCHA; block by ASN/geo
|
|
958
|
+
- Scale horizontally: auto-scale backend capacity during attack
|
|
959
|
+
- Blackhole routing: last resort for extreme volumetric attacks
|
|
960
|
+
|
|
961
|
+
POST-INCIDENT:
|
|
962
|
+
- Analyze attack patterns for permanent WAF rule creation
|
|
963
|
+
- Review auto-scaling configurations
|
|
964
|
+
- Update incident response runbook with attack-specific details
|
|
965
|
+
- Consider always-on DDoS protection if attacks are recurring
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
### 8.3 Lateral Movement Detection
|
|
969
|
+
|
|
970
|
+
```
|
|
971
|
+
DETECTION SIGNALS:
|
|
972
|
+
- Unusual Kerberos ticket requests (Event ID 4768/4769 with non-standard encryption)
|
|
973
|
+
- Unexpected SMB/RDP/SSH connections between workloads
|
|
974
|
+
- Service accounts authenticating from new source hosts
|
|
975
|
+
- Process execution of recon tools (whoami, net group, nltest, AdFind)
|
|
976
|
+
- Anomalous east-west traffic volume or new communication pairs
|
|
977
|
+
- Pass-the-hash indicators: NTLM authentication from unexpected sources
|
|
978
|
+
|
|
979
|
+
INVESTIGATION:
|
|
980
|
+
- Correlate network flow logs with authentication logs
|
|
981
|
+
- Map all connections from the suspected compromised host
|
|
982
|
+
- Check for credential dumping artifacts (LSASS access, Mimikatz indicators)
|
|
983
|
+
- Review DNS query logs for internal reconnaissance patterns
|
|
984
|
+
- Timeline the attack: initial access → discovery → lateral movement → objective
|
|
985
|
+
|
|
986
|
+
CONTAINMENT:
|
|
987
|
+
- Isolate compromised hosts (disable network interface, quarantine VLAN)
|
|
988
|
+
- Force password reset for all accounts accessed from compromised hosts
|
|
989
|
+
- Revoke all active sessions and tokens
|
|
990
|
+
- Block lateral movement protocols between compromised and clean segments
|
|
991
|
+
- Deploy enhanced monitoring on all hosts the attacker may have reached
|
|
992
|
+
|
|
993
|
+
ERADICATION:
|
|
994
|
+
- Reimage compromised hosts (do not attempt to clean in place)
|
|
995
|
+
- Rotate all credentials that were accessible from compromised systems
|
|
996
|
+
- Audit and remediate the initial access vector
|
|
997
|
+
- Verify network segmentation prevents the same lateral movement path
|
|
998
|
+
```
|
|
999
|
+
|
|
1000
|
+
---
|
|
1001
|
+
|
|
1002
|
+
## 9. Compliance & Standards
|
|
1003
|
+
|
|
1004
|
+
### 9.1 NIST SP 800-53 Rev 5 — Network Controls
|
|
1005
|
+
|
|
1006
|
+
| Control Family | Key Controls |
|
|
1007
|
+
|-------------------|-----------------------------------------------------------|
|
|
1008
|
+
| **SC (System & Comm)** | SC-7 (Boundary Protection), SC-8 (Transmission Confidentiality), SC-23 (Session Authenticity) |
|
|
1009
|
+
| **AC (Access Control)** | AC-4 (Information Flow Enforcement), AC-17 (Remote Access), AC-20 (External Systems) |
|
|
1010
|
+
| **SI (System & Info)** | SI-4 (System Monitoring), SI-3 (Malicious Code Protection) |
|
|
1011
|
+
| **CA (Assessment)** | CA-7 (Continuous Monitoring), CA-8 (Penetration Testing) |
|
|
1012
|
+
| **IA (Identification)** | IA-3 (Device Identification and Authentication) |
|
|
1013
|
+
|
|
1014
|
+
SC-7 (Boundary Protection) is the cornerstone network control:
|
|
1015
|
+
- Implement managed interfaces at external and key internal boundaries
|
|
1016
|
+
- Limit the number of external connections
|
|
1017
|
+
- Route internal traffic through authenticated proxy servers
|
|
1018
|
+
- Prevent unauthorized exfiltration at managed interfaces
|
|
1019
|
+
- Implement host-based boundary protection mechanisms
|
|
1020
|
+
|
|
1021
|
+
### 9.2 PCI-DSS v4.0.1 — Network Requirements
|
|
1022
|
+
|
|
1023
|
+
| Requirement | Description |
|
|
1024
|
+
|-------------------|-----------------------------------------------------------|
|
|
1025
|
+
| **Req 1** | Install and maintain network security controls (firewalls, ACLs) |
|
|
1026
|
+
| **Req 2** | Apply secure configurations to all system components |
|
|
1027
|
+
| **Req 4** | Protect cardholder data with strong cryptography during transmission |
|
|
1028
|
+
| **Req 10** | Log and monitor all access to system components and cardholder data |
|
|
1029
|
+
| **Req 11** | Test security of systems and networks regularly (vulnerability scans, pen tests) |
|
|
1030
|
+
|
|
1031
|
+
PCI-DSS mandates:
|
|
1032
|
+
- Cardholder data environment (CDE) must be segmented from all other networks
|
|
1033
|
+
- All inbound and outbound traffic to CDE must be restricted to necessary connections
|
|
1034
|
+
- Quarterly internal and external vulnerability scans (ASV for external)
|
|
1035
|
+
- Annual penetration testing of network segmentation controls
|
|
1036
|
+
- Wireless networks must be isolated from the CDE or use encryption
|
|
1037
|
+
|
|
1038
|
+
### 9.3 NIST SP 800-207 — Zero Trust Architecture
|
|
1039
|
+
|
|
1040
|
+
The zero trust framework defines deployment models:
|
|
1041
|
+
|
|
1042
|
+
- **Enhanced Identity Governance**: Access decisions based on user/device identity and
|
|
1043
|
+
attributes; requires strong identity provider integration
|
|
1044
|
+
- **Micro-segmentation**: Network divided into zones with gateway enforcement points;
|
|
1045
|
+
traffic between zones inspected and authorized
|
|
1046
|
+
- **Software Defined Perimeter (SDP)**: Network infrastructure hidden from unauthorized
|
|
1047
|
+
users; connectivity established only after authentication
|
|
1048
|
+
|
|
1049
|
+
Implementation phases:
|
|
1050
|
+
1. **Identify**: Map all assets, subjects, data flows, and business processes
|
|
1051
|
+
2. **Protect**: Deploy PEPs at critical access points; enforce MFA everywhere
|
|
1052
|
+
3. **Detect**: Monitor all access patterns; establish behavioral baselines
|
|
1053
|
+
4. **Respond**: Automate response to policy violations; adaptive access controls
|
|
1054
|
+
5. **Recover**: Maintain resilience; practice incident response for zero trust failures
|
|
1055
|
+
|
|
1056
|
+
---
|
|
1057
|
+
|
|
1058
|
+
## 10. Code Examples
|
|
1059
|
+
|
|
1060
|
+
### 10.1 SSRF Prevention Middleware (Express/TypeScript)
|
|
1061
|
+
|
|
1062
|
+
```typescript
|
|
1063
|
+
import { Request, Response, NextFunction } from 'express';
|
|
1064
|
+
import { URL } from 'url';
|
|
1065
|
+
import dns from 'dns/promises';
|
|
1066
|
+
|
|
1067
|
+
// --- VULNERABLE middleware: no SSRF protection ---
|
|
1068
|
+
// app.get('/proxy', async (req, res) => {
|
|
1069
|
+
// const response = await fetch(req.query.url as string);
|
|
1070
|
+
// res.send(await response.text());
|
|
1071
|
+
// });
|
|
1072
|
+
|
|
1073
|
+
// --- SECURE middleware: comprehensive SSRF prevention ---
|
|
1074
|
+
interface SSRFConfig {
|
|
1075
|
+
allowedHosts: Set<string>;
|
|
1076
|
+
allowedProtocols: Set<string>;
|
|
1077
|
+
maxRedirects: number;
|
|
1078
|
+
timeoutMs: number;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
const SSRF_CONFIG: SSRFConfig = {
|
|
1082
|
+
allowedHosts: new Set(['api.trusted-partner.com', 'cdn.example.com']),
|
|
1083
|
+
allowedProtocols: new Set(['https:']),
|
|
1084
|
+
maxRedirects: 0,
|
|
1085
|
+
timeoutMs: 5000,
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
const PRIVATE_RANGES = [
|
|
1089
|
+
{ start: 0x0A000000, end: 0x0AFFFFFF }, // 10.0.0.0/8
|
|
1090
|
+
{ start: 0xAC100000, end: 0xAC1FFFFF }, // 172.16.0.0/12
|
|
1091
|
+
{ start: 0xC0A80000, end: 0xC0A8FFFF }, // 192.168.0.0/16
|
|
1092
|
+
{ start: 0x7F000000, end: 0x7FFFFFFF }, // 127.0.0.0/8
|
|
1093
|
+
{ start: 0xA9FE0000, end: 0xA9FEFFFF }, // 169.254.0.0/16 (metadata!)
|
|
1094
|
+
];
|
|
1095
|
+
|
|
1096
|
+
function ipToInt(ip: string): number {
|
|
1097
|
+
return ip.split('.').reduce((acc, octet) => (acc << 8) + parseInt(octet, 10), 0) >>> 0;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
function isPrivateIP(ip: string): boolean {
|
|
1101
|
+
const ipInt = ipToInt(ip);
|
|
1102
|
+
return PRIVATE_RANGES.some(range => ipInt >= range.start && ipInt <= range.end);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
export async function ssrfGuard(
|
|
1106
|
+
req: Request,
|
|
1107
|
+
res: Response,
|
|
1108
|
+
next: NextFunction
|
|
1109
|
+
): Promise<void> {
|
|
1110
|
+
const targetUrl = req.query.url as string;
|
|
1111
|
+
if (!targetUrl) {
|
|
1112
|
+
res.status(400).json({ error: 'URL parameter required' });
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
let parsed: URL;
|
|
1117
|
+
try {
|
|
1118
|
+
parsed = new URL(targetUrl);
|
|
1119
|
+
} catch {
|
|
1120
|
+
res.status(400).json({ error: 'Invalid URL' });
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
// Check protocol
|
|
1125
|
+
if (!SSRF_CONFIG.allowedProtocols.has(parsed.protocol)) {
|
|
1126
|
+
res.status(403).json({ error: 'Protocol not allowed' });
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
// Check host allowlist
|
|
1131
|
+
if (!SSRF_CONFIG.allowedHosts.has(parsed.hostname)) {
|
|
1132
|
+
res.status(403).json({ error: 'Host not in allowlist' });
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
// Resolve DNS and check for private IPs
|
|
1137
|
+
try {
|
|
1138
|
+
const addresses = await dns.resolve4(parsed.hostname);
|
|
1139
|
+
if (addresses.some(isPrivateIP)) {
|
|
1140
|
+
res.status(403).json({ error: 'Resolved to private IP range' });
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
} catch {
|
|
1144
|
+
res.status(502).json({ error: 'DNS resolution failed' });
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
next();
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
// Usage: app.get('/proxy', ssrfGuard, proxyHandler);
|
|
1152
|
+
```
|
|
1153
|
+
|
|
1154
|
+
### 10.2 Network Security Configuration (Nginx Hardening)
|
|
1155
|
+
|
|
1156
|
+
```nginx
|
|
1157
|
+
# --- VULNERABLE: default Nginx config ---
|
|
1158
|
+
# server {
|
|
1159
|
+
# listen 80;
|
|
1160
|
+
# server_name _;
|
|
1161
|
+
# location / { proxy_pass http://backend; }
|
|
1162
|
+
# }
|
|
1163
|
+
|
|
1164
|
+
# --- SECURE: hardened Nginx reverse proxy ---
|
|
1165
|
+
server {
|
|
1166
|
+
listen 443 ssl http2;
|
|
1167
|
+
server_name api.example.com;
|
|
1168
|
+
|
|
1169
|
+
# TLS 1.3 only (fall back to 1.2 for compatibility if needed)
|
|
1170
|
+
ssl_protocols TLSv1.3;
|
|
1171
|
+
ssl_prefer_server_ciphers off; # TLS 1.3 manages cipher negotiation
|
|
1172
|
+
ssl_certificate /etc/ssl/certs/server.crt;
|
|
1173
|
+
ssl_certificate_key /etc/ssl/private/server.key;
|
|
1174
|
+
|
|
1175
|
+
# HSTS: force HTTPS for 1 year, including subdomains
|
|
1176
|
+
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
|
|
1177
|
+
|
|
1178
|
+
# Prevent information disclosure
|
|
1179
|
+
server_tokens off;
|
|
1180
|
+
|
|
1181
|
+
# Rate limiting zone
|
|
1182
|
+
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
|
|
1183
|
+
limit_req zone=api burst=20 nodelay;
|
|
1184
|
+
limit_req_status 429;
|
|
1185
|
+
|
|
1186
|
+
# Request size limits (prevent large payload attacks)
|
|
1187
|
+
client_max_body_size 1m;
|
|
1188
|
+
client_body_timeout 10s;
|
|
1189
|
+
client_header_timeout 10s;
|
|
1190
|
+
|
|
1191
|
+
# Proxy to backend with security headers
|
|
1192
|
+
location /api/ {
|
|
1193
|
+
proxy_pass http://backend-upstream;
|
|
1194
|
+
proxy_set_header Host $host;
|
|
1195
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
1196
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
1197
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
1198
|
+
|
|
1199
|
+
# Prevent proxy from following redirects to internal services
|
|
1200
|
+
proxy_redirect off;
|
|
1201
|
+
proxy_intercept_errors on;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
# Block access to sensitive paths
|
|
1205
|
+
location ~ /\.(env|git|svn|htaccess) {
|
|
1206
|
+
deny all;
|
|
1207
|
+
return 404;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
# Redirect all HTTP to HTTPS
|
|
1212
|
+
server {
|
|
1213
|
+
listen 80;
|
|
1214
|
+
server_name api.example.com;
|
|
1215
|
+
return 301 https://$server_name$request_uri;
|
|
1216
|
+
}
|
|
1217
|
+
```
|
|
1218
|
+
|
|
1219
|
+
### 10.3 Kubernetes Network Security (Complete Namespace Policy)
|
|
1220
|
+
|
|
1221
|
+
```yaml
|
|
1222
|
+
# Complete network security for a production namespace:
|
|
1223
|
+
# - Default deny all traffic
|
|
1224
|
+
# - Allow only declared communication paths
|
|
1225
|
+
# - Block cloud metadata endpoint
|
|
1226
|
+
# - Restrict DNS to kube-dns only
|
|
1227
|
+
|
|
1228
|
+
apiVersion: networking.k8s.io/v1
|
|
1229
|
+
kind: NetworkPolicy
|
|
1230
|
+
metadata:
|
|
1231
|
+
name: default-deny-all
|
|
1232
|
+
namespace: production
|
|
1233
|
+
spec:
|
|
1234
|
+
podSelector: {}
|
|
1235
|
+
policyTypes: [Ingress, Egress]
|
|
1236
|
+
|
|
1237
|
+
---
|
|
1238
|
+
# Ingress controller -> frontend (port 3000)
|
|
1239
|
+
apiVersion: networking.k8s.io/v1
|
|
1240
|
+
kind: NetworkPolicy
|
|
1241
|
+
metadata:
|
|
1242
|
+
name: frontend-ingress
|
|
1243
|
+
namespace: production
|
|
1244
|
+
spec:
|
|
1245
|
+
podSelector:
|
|
1246
|
+
matchLabels:
|
|
1247
|
+
app: frontend
|
|
1248
|
+
policyTypes: [Ingress]
|
|
1249
|
+
ingress:
|
|
1250
|
+
- from:
|
|
1251
|
+
- namespaceSelector:
|
|
1252
|
+
matchLabels:
|
|
1253
|
+
name: ingress-nginx
|
|
1254
|
+
ports:
|
|
1255
|
+
- protocol: TCP
|
|
1256
|
+
port: 3000
|
|
1257
|
+
|
|
1258
|
+
---
|
|
1259
|
+
# Frontend -> API service (port 8080), plus DNS
|
|
1260
|
+
apiVersion: networking.k8s.io/v1
|
|
1261
|
+
kind: NetworkPolicy
|
|
1262
|
+
metadata:
|
|
1263
|
+
name: frontend-egress
|
|
1264
|
+
namespace: production
|
|
1265
|
+
spec:
|
|
1266
|
+
podSelector:
|
|
1267
|
+
matchLabels:
|
|
1268
|
+
app: frontend
|
|
1269
|
+
policyTypes: [Egress]
|
|
1270
|
+
egress:
|
|
1271
|
+
- to:
|
|
1272
|
+
- podSelector:
|
|
1273
|
+
matchLabels:
|
|
1274
|
+
app: api
|
|
1275
|
+
ports:
|
|
1276
|
+
- { protocol: TCP, port: 8080 }
|
|
1277
|
+
- to:
|
|
1278
|
+
- namespaceSelector: {}
|
|
1279
|
+
podSelector:
|
|
1280
|
+
matchLabels:
|
|
1281
|
+
k8s-app: kube-dns
|
|
1282
|
+
ports:
|
|
1283
|
+
- { protocol: UDP, port: 53 }
|
|
1284
|
+
|
|
1285
|
+
---
|
|
1286
|
+
# API -> Database (port 5432), external HTTPS, DNS
|
|
1287
|
+
apiVersion: networking.k8s.io/v1
|
|
1288
|
+
kind: NetworkPolicy
|
|
1289
|
+
metadata:
|
|
1290
|
+
name: api-egress
|
|
1291
|
+
namespace: production
|
|
1292
|
+
spec:
|
|
1293
|
+
podSelector:
|
|
1294
|
+
matchLabels:
|
|
1295
|
+
app: api
|
|
1296
|
+
policyTypes: [Egress]
|
|
1297
|
+
egress:
|
|
1298
|
+
- to:
|
|
1299
|
+
- podSelector:
|
|
1300
|
+
matchLabels:
|
|
1301
|
+
app: database
|
|
1302
|
+
ports:
|
|
1303
|
+
- { protocol: TCP, port: 5432 }
|
|
1304
|
+
- to:
|
|
1305
|
+
- ipBlock:
|
|
1306
|
+
cidr: 0.0.0.0/0
|
|
1307
|
+
except:
|
|
1308
|
+
- 10.0.0.0/8
|
|
1309
|
+
- 172.16.0.0/12
|
|
1310
|
+
- 192.168.0.0/16
|
|
1311
|
+
- 169.254.169.254/32 # Block metadata endpoint
|
|
1312
|
+
ports:
|
|
1313
|
+
- { protocol: TCP, port: 443 }
|
|
1314
|
+
- to:
|
|
1315
|
+
- namespaceSelector: {}
|
|
1316
|
+
podSelector:
|
|
1317
|
+
matchLabels:
|
|
1318
|
+
k8s-app: kube-dns
|
|
1319
|
+
ports:
|
|
1320
|
+
- { protocol: UDP, port: 53 }
|
|
1321
|
+
```
|
|
1322
|
+
|
|
1323
|
+
---
|
|
1324
|
+
|
|
1325
|
+
## References
|
|
1326
|
+
|
|
1327
|
+
- NIST SP 800-207: Zero Trust Architecture — https://csrc.nist.gov/pubs/sp/800/207/final
|
|
1328
|
+
- NIST SP 800-53 Rev 5: Security and Privacy Controls — https://csrc.nist.gov/pubs/sp/800/53/r5/upd1/final
|
|
1329
|
+
- OWASP SSRF Prevention Cheat Sheet — https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
|
|
1330
|
+
- CISA Zero Trust Architecture Implementation — https://www.dhs.gov/sites/default/files/2025-04/2025_0129_cisa_zero_trust_architecture_implementation.pdf
|
|
1331
|
+
- CWE-918: Server-Side Request Forgery — https://cwe.mitre.org/data/definitions/918.html
|
|
1332
|
+
- Cloudflare DDoS Threat Report Q3 2024 — https://developers.cloudflare.com/ddos-protection/
|
|
1333
|
+
- Capital One Breach Analysis — https://krebsonsecurity.com/2019/08/what-we-can-learn-from-the-capital-one-hack/
|
|
1334
|
+
- SolarWinds TTPs Analysis — https://www.picussecurity.com/resource/blog/ttps-used-in-the-solarwinds-breach
|
|
1335
|
+
- Kubernetes Network Policies — https://kubernetes.io/docs/concepts/services-networking/network-policies/
|
|
1336
|
+
- PCI-DSS v4.0.1 — https://www.pcisecuritystandards.org/
|
|
1337
|
+
- Istio mTLS Documentation — https://istio.io/latest/blog/2023/secure-apps-with-istio/
|