@wazir-dev/cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (629) hide show
  1. package/AGENTS.md +111 -0
  2. package/CHANGELOG.md +14 -0
  3. package/CONTRIBUTING.md +101 -0
  4. package/LICENSE +21 -0
  5. package/README.md +314 -0
  6. package/assets/composition-engine.mmd +34 -0
  7. package/assets/demo-script.sh +17 -0
  8. package/assets/logo-dark.svg +14 -0
  9. package/assets/logo.svg +14 -0
  10. package/assets/pipeline.mmd +39 -0
  11. package/assets/record-demo.sh +51 -0
  12. package/docs/README.md +51 -0
  13. package/docs/adapters/context-mode.md +60 -0
  14. package/docs/concepts/architecture.md +87 -0
  15. package/docs/concepts/artifact-model.md +60 -0
  16. package/docs/concepts/composition-engine.md +36 -0
  17. package/docs/concepts/indexing-and-recall.md +160 -0
  18. package/docs/concepts/observability.md +41 -0
  19. package/docs/concepts/roles-and-workflows.md +59 -0
  20. package/docs/concepts/terminology-policy.md +27 -0
  21. package/docs/getting-started/01-installation.md +78 -0
  22. package/docs/getting-started/02-first-run.md +102 -0
  23. package/docs/getting-started/03-adding-to-project.md +15 -0
  24. package/docs/getting-started/04-host-setup.md +15 -0
  25. package/docs/guides/ci-integration.md +15 -0
  26. package/docs/guides/creating-skills.md +15 -0
  27. package/docs/guides/expertise-module-authoring.md +15 -0
  28. package/docs/guides/hook-development.md +15 -0
  29. package/docs/guides/memory-and-learnings.md +34 -0
  30. package/docs/guides/multi-host-export.md +15 -0
  31. package/docs/guides/troubleshooting.md +101 -0
  32. package/docs/guides/writing-custom-roles.md +15 -0
  33. package/docs/plans/2026-03-15-cli-pipeline-integration-design.md +592 -0
  34. package/docs/plans/2026-03-15-cli-pipeline-integration-plan.md +598 -0
  35. package/docs/plans/2026-03-15-docs-enforcement-plan.md +238 -0
  36. package/docs/readmes/INDEX.md +99 -0
  37. package/docs/readmes/features/expertise/README.md +171 -0
  38. package/docs/readmes/features/exports/README.md +222 -0
  39. package/docs/readmes/features/hooks/README.md +103 -0
  40. package/docs/readmes/features/hooks/loop-cap-guard.md +133 -0
  41. package/docs/readmes/features/hooks/post-tool-capture.md +121 -0
  42. package/docs/readmes/features/hooks/post-tool-lint.md +130 -0
  43. package/docs/readmes/features/hooks/pre-compact-summary.md +122 -0
  44. package/docs/readmes/features/hooks/pre-tool-capture-route.md +100 -0
  45. package/docs/readmes/features/hooks/protected-path-write-guard.md +128 -0
  46. package/docs/readmes/features/hooks/session-start.md +119 -0
  47. package/docs/readmes/features/hooks/stop-handoff-harvest.md +125 -0
  48. package/docs/readmes/features/roles/README.md +157 -0
  49. package/docs/readmes/features/roles/clarifier.md +152 -0
  50. package/docs/readmes/features/roles/content-author.md +190 -0
  51. package/docs/readmes/features/roles/designer.md +193 -0
  52. package/docs/readmes/features/roles/executor.md +184 -0
  53. package/docs/readmes/features/roles/learner.md +210 -0
  54. package/docs/readmes/features/roles/planner.md +182 -0
  55. package/docs/readmes/features/roles/researcher.md +164 -0
  56. package/docs/readmes/features/roles/reviewer.md +184 -0
  57. package/docs/readmes/features/roles/specifier.md +162 -0
  58. package/docs/readmes/features/roles/verifier.md +215 -0
  59. package/docs/readmes/features/schemas/README.md +178 -0
  60. package/docs/readmes/features/skills/README.md +63 -0
  61. package/docs/readmes/features/skills/brainstorming.md +96 -0
  62. package/docs/readmes/features/skills/debugging.md +148 -0
  63. package/docs/readmes/features/skills/design.md +120 -0
  64. package/docs/readmes/features/skills/prepare-next.md +109 -0
  65. package/docs/readmes/features/skills/run-audit.md +159 -0
  66. package/docs/readmes/features/skills/scan-project.md +109 -0
  67. package/docs/readmes/features/skills/self-audit.md +176 -0
  68. package/docs/readmes/features/skills/tdd.md +137 -0
  69. package/docs/readmes/features/skills/using-skills.md +92 -0
  70. package/docs/readmes/features/skills/verification.md +120 -0
  71. package/docs/readmes/features/skills/writing-plans.md +104 -0
  72. package/docs/readmes/features/tooling/README.md +320 -0
  73. package/docs/readmes/features/workflows/README.md +186 -0
  74. package/docs/readmes/features/workflows/author.md +181 -0
  75. package/docs/readmes/features/workflows/clarify.md +154 -0
  76. package/docs/readmes/features/workflows/design-review.md +171 -0
  77. package/docs/readmes/features/workflows/design.md +169 -0
  78. package/docs/readmes/features/workflows/discover.md +162 -0
  79. package/docs/readmes/features/workflows/execute.md +173 -0
  80. package/docs/readmes/features/workflows/learn.md +167 -0
  81. package/docs/readmes/features/workflows/plan-review.md +165 -0
  82. package/docs/readmes/features/workflows/plan.md +170 -0
  83. package/docs/readmes/features/workflows/prepare-next.md +167 -0
  84. package/docs/readmes/features/workflows/review.md +169 -0
  85. package/docs/readmes/features/workflows/run-audit.md +191 -0
  86. package/docs/readmes/features/workflows/spec-challenge.md +159 -0
  87. package/docs/readmes/features/workflows/specify.md +160 -0
  88. package/docs/readmes/features/workflows/verify.md +177 -0
  89. package/docs/readmes/packages/README.md +50 -0
  90. package/docs/readmes/packages/ajv.md +117 -0
  91. package/docs/readmes/packages/context-mode.md +118 -0
  92. package/docs/readmes/packages/gray-matter.md +116 -0
  93. package/docs/readmes/packages/node-test.md +137 -0
  94. package/docs/readmes/packages/yaml.md +112 -0
  95. package/docs/reference/configuration-reference.md +159 -0
  96. package/docs/reference/expertise-index.md +52 -0
  97. package/docs/reference/git-flow.md +43 -0
  98. package/docs/reference/hooks.md +87 -0
  99. package/docs/reference/host-exports.md +50 -0
  100. package/docs/reference/launch-checklist.md +172 -0
  101. package/docs/reference/marketplace-listings.md +76 -0
  102. package/docs/reference/release-process.md +34 -0
  103. package/docs/reference/roles-reference.md +77 -0
  104. package/docs/reference/skills.md +33 -0
  105. package/docs/reference/templates.md +29 -0
  106. package/docs/reference/tooling-cli.md +94 -0
  107. package/docs/truth-claims.yaml +222 -0
  108. package/expertise/PROGRESS.md +63 -0
  109. package/expertise/README.md +18 -0
  110. package/expertise/antipatterns/PROGRESS.md +56 -0
  111. package/expertise/antipatterns/backend/api-design-antipatterns.md +1271 -0
  112. package/expertise/antipatterns/backend/auth-antipatterns.md +1195 -0
  113. package/expertise/antipatterns/backend/caching-antipatterns.md +622 -0
  114. package/expertise/antipatterns/backend/database-antipatterns.md +1038 -0
  115. package/expertise/antipatterns/backend/index.md +24 -0
  116. package/expertise/antipatterns/backend/microservices-antipatterns.md +850 -0
  117. package/expertise/antipatterns/code/architecture-antipatterns.md +919 -0
  118. package/expertise/antipatterns/code/async-antipatterns.md +622 -0
  119. package/expertise/antipatterns/code/code-smells.md +1186 -0
  120. package/expertise/antipatterns/code/dependency-antipatterns.md +1209 -0
  121. package/expertise/antipatterns/code/error-handling-antipatterns.md +1360 -0
  122. package/expertise/antipatterns/code/index.md +27 -0
  123. package/expertise/antipatterns/code/naming-and-abstraction.md +1118 -0
  124. package/expertise/antipatterns/code/state-management-antipatterns.md +1076 -0
  125. package/expertise/antipatterns/code/testing-antipatterns.md +1053 -0
  126. package/expertise/antipatterns/design/accessibility-antipatterns.md +1136 -0
  127. package/expertise/antipatterns/design/dark-patterns.md +1121 -0
  128. package/expertise/antipatterns/design/index.md +22 -0
  129. package/expertise/antipatterns/design/ui-antipatterns.md +1202 -0
  130. package/expertise/antipatterns/design/ux-antipatterns.md +680 -0
  131. package/expertise/antipatterns/frontend/css-layout-antipatterns.md +691 -0
  132. package/expertise/antipatterns/frontend/flutter-antipatterns.md +1827 -0
  133. package/expertise/antipatterns/frontend/index.md +23 -0
  134. package/expertise/antipatterns/frontend/mobile-antipatterns.md +573 -0
  135. package/expertise/antipatterns/frontend/react-antipatterns.md +1128 -0
  136. package/expertise/antipatterns/frontend/spa-antipatterns.md +1235 -0
  137. package/expertise/antipatterns/index.md +31 -0
  138. package/expertise/antipatterns/performance/index.md +20 -0
  139. package/expertise/antipatterns/performance/performance-antipatterns.md +1013 -0
  140. package/expertise/antipatterns/performance/premature-optimization.md +623 -0
  141. package/expertise/antipatterns/performance/scaling-antipatterns.md +785 -0
  142. package/expertise/antipatterns/process/ai-coding-antipatterns.md +853 -0
  143. package/expertise/antipatterns/process/code-review-antipatterns.md +656 -0
  144. package/expertise/antipatterns/process/deployment-antipatterns.md +920 -0
  145. package/expertise/antipatterns/process/index.md +23 -0
  146. package/expertise/antipatterns/process/technical-debt-antipatterns.md +647 -0
  147. package/expertise/antipatterns/security/index.md +20 -0
  148. package/expertise/antipatterns/security/secrets-antipatterns.md +849 -0
  149. package/expertise/antipatterns/security/security-theater.md +843 -0
  150. package/expertise/antipatterns/security/vulnerability-patterns.md +801 -0
  151. package/expertise/architecture/PROGRESS.md +70 -0
  152. package/expertise/architecture/data/caching-architecture.md +671 -0
  153. package/expertise/architecture/data/data-consistency.md +574 -0
  154. package/expertise/architecture/data/data-modeling.md +536 -0
  155. package/expertise/architecture/data/event-streams-and-queues.md +634 -0
  156. package/expertise/architecture/data/index.md +25 -0
  157. package/expertise/architecture/data/search-architecture.md +663 -0
  158. package/expertise/architecture/data/sql-vs-nosql.md +708 -0
  159. package/expertise/architecture/decisions/architecture-decision-records.md +640 -0
  160. package/expertise/architecture/decisions/build-vs-buy.md +616 -0
  161. package/expertise/architecture/decisions/index.md +23 -0
  162. package/expertise/architecture/decisions/monolith-to-microservices.md +790 -0
  163. package/expertise/architecture/decisions/technology-selection.md +616 -0
  164. package/expertise/architecture/distributed/cap-theorem-and-tradeoffs.md +800 -0
  165. package/expertise/architecture/distributed/circuit-breaker-bulkhead.md +741 -0
  166. package/expertise/architecture/distributed/consensus-and-coordination.md +796 -0
  167. package/expertise/architecture/distributed/distributed-systems-fundamentals.md +564 -0
  168. package/expertise/architecture/distributed/idempotency-and-retry.md +796 -0
  169. package/expertise/architecture/distributed/index.md +25 -0
  170. package/expertise/architecture/distributed/saga-pattern.md +797 -0
  171. package/expertise/architecture/foundations/architectural-thinking.md +460 -0
  172. package/expertise/architecture/foundations/coupling-and-cohesion.md +770 -0
  173. package/expertise/architecture/foundations/design-principles-solid.md +649 -0
  174. package/expertise/architecture/foundations/domain-driven-design.md +719 -0
  175. package/expertise/architecture/foundations/index.md +25 -0
  176. package/expertise/architecture/foundations/separation-of-concerns.md +472 -0
  177. package/expertise/architecture/foundations/twelve-factor-app.md +797 -0
  178. package/expertise/architecture/index.md +34 -0
  179. package/expertise/architecture/integration/api-design-graphql.md +638 -0
  180. package/expertise/architecture/integration/api-design-grpc.md +804 -0
  181. package/expertise/architecture/integration/api-design-rest.md +892 -0
  182. package/expertise/architecture/integration/index.md +25 -0
  183. package/expertise/architecture/integration/third-party-integration.md +795 -0
  184. package/expertise/architecture/integration/webhooks-and-callbacks.md +1152 -0
  185. package/expertise/architecture/integration/websockets-realtime.md +791 -0
  186. package/expertise/architecture/mobile-architecture/index.md +22 -0
  187. package/expertise/architecture/mobile-architecture/mobile-app-architecture.md +780 -0
  188. package/expertise/architecture/mobile-architecture/mobile-backend-for-frontend.md +670 -0
  189. package/expertise/architecture/mobile-architecture/offline-first.md +719 -0
  190. package/expertise/architecture/mobile-architecture/push-and-sync.md +782 -0
  191. package/expertise/architecture/patterns/cqrs-event-sourcing.md +717 -0
  192. package/expertise/architecture/patterns/event-driven.md +797 -0
  193. package/expertise/architecture/patterns/hexagonal-clean-architecture.md +870 -0
  194. package/expertise/architecture/patterns/index.md +27 -0
  195. package/expertise/architecture/patterns/layered-architecture.md +736 -0
  196. package/expertise/architecture/patterns/microservices.md +753 -0
  197. package/expertise/architecture/patterns/modular-monolith.md +692 -0
  198. package/expertise/architecture/patterns/monolith.md +626 -0
  199. package/expertise/architecture/patterns/plugin-architecture.md +735 -0
  200. package/expertise/architecture/patterns/serverless.md +780 -0
  201. package/expertise/architecture/scaling/database-scaling.md +615 -0
  202. package/expertise/architecture/scaling/feature-flags-and-rollouts.md +757 -0
  203. package/expertise/architecture/scaling/horizontal-vs-vertical.md +606 -0
  204. package/expertise/architecture/scaling/index.md +24 -0
  205. package/expertise/architecture/scaling/multi-tenancy.md +800 -0
  206. package/expertise/architecture/scaling/stateless-design.md +787 -0
  207. package/expertise/backend/embedded-firmware.md +625 -0
  208. package/expertise/backend/go.md +853 -0
  209. package/expertise/backend/index.md +24 -0
  210. package/expertise/backend/java-spring.md +448 -0
  211. package/expertise/backend/node-typescript.md +625 -0
  212. package/expertise/backend/python-fastapi.md +724 -0
  213. package/expertise/backend/rust.md +458 -0
  214. package/expertise/backend/solidity.md +711 -0
  215. package/expertise/composition-map.yaml +443 -0
  216. package/expertise/content/foundations/content-modeling.md +395 -0
  217. package/expertise/content/foundations/editorial-standards.md +449 -0
  218. package/expertise/content/foundations/index.md +24 -0
  219. package/expertise/content/foundations/microcopy.md +455 -0
  220. package/expertise/content/foundations/terminology-governance.md +509 -0
  221. package/expertise/content/index.md +34 -0
  222. package/expertise/content/patterns/accessibility-copy.md +518 -0
  223. package/expertise/content/patterns/index.md +24 -0
  224. package/expertise/content/patterns/notification-content.md +433 -0
  225. package/expertise/content/patterns/sample-content.md +486 -0
  226. package/expertise/content/patterns/state-copy.md +439 -0
  227. package/expertise/design/PROGRESS.md +58 -0
  228. package/expertise/design/disciplines/dark-mode-theming.md +577 -0
  229. package/expertise/design/disciplines/design-systems.md +595 -0
  230. package/expertise/design/disciplines/index.md +25 -0
  231. package/expertise/design/disciplines/information-architecture.md +800 -0
  232. package/expertise/design/disciplines/interaction-design.md +788 -0
  233. package/expertise/design/disciplines/responsive-design.md +552 -0
  234. package/expertise/design/disciplines/usability-testing.md +516 -0
  235. package/expertise/design/disciplines/user-research.md +792 -0
  236. package/expertise/design/foundations/accessibility-design.md +796 -0
  237. package/expertise/design/foundations/color-theory.md +797 -0
  238. package/expertise/design/foundations/iconography.md +795 -0
  239. package/expertise/design/foundations/index.md +26 -0
  240. package/expertise/design/foundations/motion-and-animation.md +653 -0
  241. package/expertise/design/foundations/rtl-design.md +585 -0
  242. package/expertise/design/foundations/spacing-and-layout.md +607 -0
  243. package/expertise/design/foundations/typography.md +800 -0
  244. package/expertise/design/foundations/visual-hierarchy.md +761 -0
  245. package/expertise/design/index.md +32 -0
  246. package/expertise/design/patterns/authentication-flows.md +474 -0
  247. package/expertise/design/patterns/content-consumption.md +789 -0
  248. package/expertise/design/patterns/data-display.md +618 -0
  249. package/expertise/design/patterns/e-commerce.md +1494 -0
  250. package/expertise/design/patterns/feedback-and-states.md +642 -0
  251. package/expertise/design/patterns/forms-and-input.md +819 -0
  252. package/expertise/design/patterns/gamification.md +801 -0
  253. package/expertise/design/patterns/index.md +31 -0
  254. package/expertise/design/patterns/microinteractions.md +449 -0
  255. package/expertise/design/patterns/navigation.md +800 -0
  256. package/expertise/design/patterns/notifications.md +705 -0
  257. package/expertise/design/patterns/onboarding.md +700 -0
  258. package/expertise/design/patterns/search-and-filter.md +601 -0
  259. package/expertise/design/patterns/settings-and-preferences.md +768 -0
  260. package/expertise/design/patterns/social-and-community.md +748 -0
  261. package/expertise/design/platforms/desktop-native.md +612 -0
  262. package/expertise/design/platforms/index.md +25 -0
  263. package/expertise/design/platforms/mobile-android.md +825 -0
  264. package/expertise/design/platforms/mobile-cross-platform.md +983 -0
  265. package/expertise/design/platforms/mobile-ios.md +699 -0
  266. package/expertise/design/platforms/tablet.md +794 -0
  267. package/expertise/design/platforms/web-dashboard.md +790 -0
  268. package/expertise/design/platforms/web-responsive.md +550 -0
  269. package/expertise/design/psychology/behavioral-nudges.md +449 -0
  270. package/expertise/design/psychology/cognitive-load.md +1191 -0
  271. package/expertise/design/psychology/error-psychology.md +778 -0
  272. package/expertise/design/psychology/index.md +22 -0
  273. package/expertise/design/psychology/persuasive-design.md +736 -0
  274. package/expertise/design/psychology/user-mental-models.md +623 -0
  275. package/expertise/design/tooling/open-pencil.md +266 -0
  276. package/expertise/frontend/angular.md +1073 -0
  277. package/expertise/frontend/desktop-electron.md +546 -0
  278. package/expertise/frontend/flutter.md +782 -0
  279. package/expertise/frontend/index.md +27 -0
  280. package/expertise/frontend/native-android.md +409 -0
  281. package/expertise/frontend/native-ios.md +490 -0
  282. package/expertise/frontend/react-native.md +1160 -0
  283. package/expertise/frontend/react.md +808 -0
  284. package/expertise/frontend/vue.md +1089 -0
  285. package/expertise/humanize/domain-rules-code.md +79 -0
  286. package/expertise/humanize/domain-rules-content.md +67 -0
  287. package/expertise/humanize/domain-rules-technical-docs.md +56 -0
  288. package/expertise/humanize/index.md +35 -0
  289. package/expertise/humanize/self-audit-checklist.md +87 -0
  290. package/expertise/humanize/sentence-patterns.md +218 -0
  291. package/expertise/humanize/vocabulary-blacklist.md +105 -0
  292. package/expertise/i18n/PROGRESS.md +65 -0
  293. package/expertise/i18n/advanced/accessibility-and-i18n.md +28 -0
  294. package/expertise/i18n/advanced/bidirectional-text-algorithm.md +38 -0
  295. package/expertise/i18n/advanced/complex-scripts.md +30 -0
  296. package/expertise/i18n/advanced/performance-and-i18n.md +27 -0
  297. package/expertise/i18n/advanced/testing-i18n.md +28 -0
  298. package/expertise/i18n/content/content-adaptation.md +23 -0
  299. package/expertise/i18n/content/locale-specific-formatting.md +23 -0
  300. package/expertise/i18n/content/machine-translation-integration.md +28 -0
  301. package/expertise/i18n/content/translation-management.md +29 -0
  302. package/expertise/i18n/foundations/date-time-calendars.md +67 -0
  303. package/expertise/i18n/foundations/i18n-architecture.md +272 -0
  304. package/expertise/i18n/foundations/locale-and-language-tags.md +79 -0
  305. package/expertise/i18n/foundations/numbers-currency-units.md +61 -0
  306. package/expertise/i18n/foundations/pluralization-and-gender.md +109 -0
  307. package/expertise/i18n/foundations/string-externalization.md +236 -0
  308. package/expertise/i18n/foundations/text-direction-bidi.md +241 -0
  309. package/expertise/i18n/foundations/unicode-and-encoding.md +86 -0
  310. package/expertise/i18n/index.md +38 -0
  311. package/expertise/i18n/platform/backend-i18n.md +31 -0
  312. package/expertise/i18n/platform/flutter-i18n.md +148 -0
  313. package/expertise/i18n/platform/native-android-i18n.md +36 -0
  314. package/expertise/i18n/platform/native-ios-i18n.md +36 -0
  315. package/expertise/i18n/platform/react-i18n.md +103 -0
  316. package/expertise/i18n/platform/web-css-i18n.md +81 -0
  317. package/expertise/i18n/rtl/arabic-specific.md +175 -0
  318. package/expertise/i18n/rtl/hebrew-specific.md +149 -0
  319. package/expertise/i18n/rtl/rtl-animations-and-transitions.md +111 -0
  320. package/expertise/i18n/rtl/rtl-forms-and-input.md +161 -0
  321. package/expertise/i18n/rtl/rtl-fundamentals.md +211 -0
  322. package/expertise/i18n/rtl/rtl-icons-and-images.md +181 -0
  323. package/expertise/i18n/rtl/rtl-layout-mirroring.md +252 -0
  324. package/expertise/i18n/rtl/rtl-navigation-and-gestures.md +107 -0
  325. package/expertise/i18n/rtl/rtl-testing-and-qa.md +147 -0
  326. package/expertise/i18n/rtl/rtl-typography.md +160 -0
  327. package/expertise/index.md +113 -0
  328. package/expertise/index.yaml +216 -0
  329. package/expertise/infrastructure/cloud-aws.md +597 -0
  330. package/expertise/infrastructure/cloud-gcp.md +599 -0
  331. package/expertise/infrastructure/cybersecurity.md +816 -0
  332. package/expertise/infrastructure/database-mongodb.md +447 -0
  333. package/expertise/infrastructure/database-postgres.md +400 -0
  334. package/expertise/infrastructure/devops-cicd.md +787 -0
  335. package/expertise/infrastructure/index.md +27 -0
  336. package/expertise/performance/PROGRESS.md +50 -0
  337. package/expertise/performance/backend/api-latency.md +1204 -0
  338. package/expertise/performance/backend/background-jobs.md +506 -0
  339. package/expertise/performance/backend/connection-pooling.md +1209 -0
  340. package/expertise/performance/backend/database-query-optimization.md +515 -0
  341. package/expertise/performance/backend/index.md +23 -0
  342. package/expertise/performance/backend/rate-limiting-and-throttling.md +971 -0
  343. package/expertise/performance/foundations/algorithmic-complexity.md +954 -0
  344. package/expertise/performance/foundations/caching-strategies.md +489 -0
  345. package/expertise/performance/foundations/concurrency-and-parallelism.md +847 -0
  346. package/expertise/performance/foundations/index.md +24 -0
  347. package/expertise/performance/foundations/measuring-and-profiling.md +440 -0
  348. package/expertise/performance/foundations/memory-management.md +964 -0
  349. package/expertise/performance/foundations/performance-budgets.md +1314 -0
  350. package/expertise/performance/index.md +31 -0
  351. package/expertise/performance/infrastructure/auto-scaling.md +1059 -0
  352. package/expertise/performance/infrastructure/cdn-and-edge.md +1081 -0
  353. package/expertise/performance/infrastructure/index.md +22 -0
  354. package/expertise/performance/infrastructure/load-balancing.md +1081 -0
  355. package/expertise/performance/infrastructure/observability.md +1079 -0
  356. package/expertise/performance/mobile/index.md +23 -0
  357. package/expertise/performance/mobile/mobile-animations.md +544 -0
  358. package/expertise/performance/mobile/mobile-memory-battery.md +416 -0
  359. package/expertise/performance/mobile/mobile-network.md +452 -0
  360. package/expertise/performance/mobile/mobile-rendering.md +599 -0
  361. package/expertise/performance/mobile/mobile-startup-time.md +505 -0
  362. package/expertise/performance/platform-specific/flutter-performance.md +647 -0
  363. package/expertise/performance/platform-specific/index.md +22 -0
  364. package/expertise/performance/platform-specific/node-performance.md +1307 -0
  365. package/expertise/performance/platform-specific/postgres-performance.md +1366 -0
  366. package/expertise/performance/platform-specific/react-performance.md +1403 -0
  367. package/expertise/performance/web/bundle-optimization.md +1239 -0
  368. package/expertise/performance/web/image-and-media.md +636 -0
  369. package/expertise/performance/web/index.md +24 -0
  370. package/expertise/performance/web/network-optimization.md +1133 -0
  371. package/expertise/performance/web/rendering-performance.md +1098 -0
  372. package/expertise/performance/web/ssr-and-hydration.md +918 -0
  373. package/expertise/performance/web/web-vitals.md +1374 -0
  374. package/expertise/quality/accessibility.md +985 -0
  375. package/expertise/quality/evidence-based-verification.md +499 -0
  376. package/expertise/quality/index.md +24 -0
  377. package/expertise/quality/ml-model-audit.md +614 -0
  378. package/expertise/quality/performance.md +600 -0
  379. package/expertise/quality/testing-api.md +891 -0
  380. package/expertise/quality/testing-mobile.md +496 -0
  381. package/expertise/quality/testing-web.md +849 -0
  382. package/expertise/security/PROGRESS.md +54 -0
  383. package/expertise/security/agentic-identity.md +540 -0
  384. package/expertise/security/compliance-frameworks.md +601 -0
  385. package/expertise/security/data/data-encryption.md +364 -0
  386. package/expertise/security/data/data-privacy-gdpr.md +692 -0
  387. package/expertise/security/data/database-security.md +1171 -0
  388. package/expertise/security/data/index.md +22 -0
  389. package/expertise/security/data/pii-handling.md +531 -0
  390. package/expertise/security/foundations/authentication.md +1041 -0
  391. package/expertise/security/foundations/authorization.md +603 -0
  392. package/expertise/security/foundations/cryptography.md +1001 -0
  393. package/expertise/security/foundations/index.md +25 -0
  394. package/expertise/security/foundations/owasp-top-10.md +1354 -0
  395. package/expertise/security/foundations/secrets-management.md +1217 -0
  396. package/expertise/security/foundations/secure-sdlc.md +700 -0
  397. package/expertise/security/foundations/supply-chain-security.md +698 -0
  398. package/expertise/security/index.md +31 -0
  399. package/expertise/security/infrastructure/cloud-security-aws.md +1296 -0
  400. package/expertise/security/infrastructure/cloud-security-gcp.md +1376 -0
  401. package/expertise/security/infrastructure/container-security.md +721 -0
  402. package/expertise/security/infrastructure/incident-response.md +1295 -0
  403. package/expertise/security/infrastructure/index.md +24 -0
  404. package/expertise/security/infrastructure/logging-and-monitoring.md +1618 -0
  405. package/expertise/security/infrastructure/network-security.md +1337 -0
  406. package/expertise/security/mobile/index.md +23 -0
  407. package/expertise/security/mobile/mobile-android-security.md +1218 -0
  408. package/expertise/security/mobile/mobile-binary-protection.md +1229 -0
  409. package/expertise/security/mobile/mobile-data-storage.md +1265 -0
  410. package/expertise/security/mobile/mobile-ios-security.md +1401 -0
  411. package/expertise/security/mobile/mobile-network-security.md +1520 -0
  412. package/expertise/security/smart-contract-security.md +594 -0
  413. package/expertise/security/testing/index.md +22 -0
  414. package/expertise/security/testing/penetration-testing.md +1258 -0
  415. package/expertise/security/testing/security-code-review.md +1765 -0
  416. package/expertise/security/testing/threat-modeling.md +1074 -0
  417. package/expertise/security/testing/vulnerability-scanning.md +1062 -0
  418. package/expertise/security/web/api-security.md +586 -0
  419. package/expertise/security/web/cors-and-headers.md +433 -0
  420. package/expertise/security/web/csrf.md +562 -0
  421. package/expertise/security/web/file-upload.md +1477 -0
  422. package/expertise/security/web/index.md +25 -0
  423. package/expertise/security/web/injection.md +1375 -0
  424. package/expertise/security/web/session-management.md +1101 -0
  425. package/expertise/security/web/xss.md +1158 -0
  426. package/exports/README.md +17 -0
  427. package/exports/hosts/claude/.claude/agents/clarifier.md +42 -0
  428. package/exports/hosts/claude/.claude/agents/content-author.md +63 -0
  429. package/exports/hosts/claude/.claude/agents/designer.md +55 -0
  430. package/exports/hosts/claude/.claude/agents/executor.md +55 -0
  431. package/exports/hosts/claude/.claude/agents/learner.md +51 -0
  432. package/exports/hosts/claude/.claude/agents/planner.md +53 -0
  433. package/exports/hosts/claude/.claude/agents/researcher.md +43 -0
  434. package/exports/hosts/claude/.claude/agents/reviewer.md +54 -0
  435. package/exports/hosts/claude/.claude/agents/specifier.md +47 -0
  436. package/exports/hosts/claude/.claude/agents/verifier.md +71 -0
  437. package/exports/hosts/claude/.claude/commands/author.md +42 -0
  438. package/exports/hosts/claude/.claude/commands/clarify.md +38 -0
  439. package/exports/hosts/claude/.claude/commands/design-review.md +46 -0
  440. package/exports/hosts/claude/.claude/commands/design.md +44 -0
  441. package/exports/hosts/claude/.claude/commands/discover.md +37 -0
  442. package/exports/hosts/claude/.claude/commands/execute.md +48 -0
  443. package/exports/hosts/claude/.claude/commands/learn.md +38 -0
  444. package/exports/hosts/claude/.claude/commands/plan-review.md +42 -0
  445. package/exports/hosts/claude/.claude/commands/plan.md +39 -0
  446. package/exports/hosts/claude/.claude/commands/prepare-next.md +37 -0
  447. package/exports/hosts/claude/.claude/commands/review.md +40 -0
  448. package/exports/hosts/claude/.claude/commands/run-audit.md +41 -0
  449. package/exports/hosts/claude/.claude/commands/spec-challenge.md +41 -0
  450. package/exports/hosts/claude/.claude/commands/specify.md +38 -0
  451. package/exports/hosts/claude/.claude/commands/verify.md +37 -0
  452. package/exports/hosts/claude/.claude/settings.json +34 -0
  453. package/exports/hosts/claude/CLAUDE.md +19 -0
  454. package/exports/hosts/claude/export.manifest.json +38 -0
  455. package/exports/hosts/claude/host-package.json +67 -0
  456. package/exports/hosts/codex/AGENTS.md +19 -0
  457. package/exports/hosts/codex/export.manifest.json +38 -0
  458. package/exports/hosts/codex/host-package.json +41 -0
  459. package/exports/hosts/cursor/.cursor/hooks.json +16 -0
  460. package/exports/hosts/cursor/.cursor/rules/wazir-core.mdc +19 -0
  461. package/exports/hosts/cursor/export.manifest.json +38 -0
  462. package/exports/hosts/cursor/host-package.json +42 -0
  463. package/exports/hosts/gemini/GEMINI.md +19 -0
  464. package/exports/hosts/gemini/export.manifest.json +38 -0
  465. package/exports/hosts/gemini/host-package.json +41 -0
  466. package/hooks/README.md +18 -0
  467. package/hooks/definitions/loop_cap_guard.yaml +21 -0
  468. package/hooks/definitions/post_tool_capture.yaml +24 -0
  469. package/hooks/definitions/pre_compact_summary.yaml +19 -0
  470. package/hooks/definitions/pre_tool_capture_route.yaml +19 -0
  471. package/hooks/definitions/protected_path_write_guard.yaml +19 -0
  472. package/hooks/definitions/session_start.yaml +19 -0
  473. package/hooks/definitions/stop_handoff_harvest.yaml +20 -0
  474. package/hooks/loop-cap-guard +17 -0
  475. package/hooks/post-tool-lint +36 -0
  476. package/hooks/protected-path-write-guard +17 -0
  477. package/hooks/session-start +41 -0
  478. package/llms-full.txt +2355 -0
  479. package/llms.txt +43 -0
  480. package/package.json +79 -0
  481. package/roles/README.md +20 -0
  482. package/roles/clarifier.md +42 -0
  483. package/roles/content-author.md +63 -0
  484. package/roles/designer.md +55 -0
  485. package/roles/executor.md +55 -0
  486. package/roles/learner.md +51 -0
  487. package/roles/planner.md +53 -0
  488. package/roles/researcher.md +43 -0
  489. package/roles/reviewer.md +54 -0
  490. package/roles/specifier.md +47 -0
  491. package/roles/verifier.md +71 -0
  492. package/schemas/README.md +24 -0
  493. package/schemas/accepted-learning.schema.json +20 -0
  494. package/schemas/author-artifact.schema.json +156 -0
  495. package/schemas/clarification.schema.json +19 -0
  496. package/schemas/design-artifact.schema.json +80 -0
  497. package/schemas/docs-claim.schema.json +18 -0
  498. package/schemas/export-manifest.schema.json +20 -0
  499. package/schemas/hook.schema.json +67 -0
  500. package/schemas/host-export-package.schema.json +18 -0
  501. package/schemas/implementation-plan.schema.json +19 -0
  502. package/schemas/proposed-learning.schema.json +19 -0
  503. package/schemas/research.schema.json +18 -0
  504. package/schemas/review.schema.json +29 -0
  505. package/schemas/run-manifest.schema.json +18 -0
  506. package/schemas/spec-challenge.schema.json +18 -0
  507. package/schemas/spec.schema.json +20 -0
  508. package/schemas/usage.schema.json +102 -0
  509. package/schemas/verification-proof.schema.json +29 -0
  510. package/schemas/wazir-manifest.schema.json +173 -0
  511. package/skills/README.md +40 -0
  512. package/skills/brainstorming/SKILL.md +77 -0
  513. package/skills/debugging/SKILL.md +50 -0
  514. package/skills/design/SKILL.md +61 -0
  515. package/skills/dispatching-parallel-agents/SKILL.md +128 -0
  516. package/skills/executing-plans/SKILL.md +70 -0
  517. package/skills/finishing-a-development-branch/SKILL.md +169 -0
  518. package/skills/humanize/SKILL.md +123 -0
  519. package/skills/init-pipeline/SKILL.md +124 -0
  520. package/skills/prepare-next/SKILL.md +20 -0
  521. package/skills/receiving-code-review/SKILL.md +123 -0
  522. package/skills/requesting-code-review/SKILL.md +105 -0
  523. package/skills/requesting-code-review/code-reviewer.md +108 -0
  524. package/skills/run-audit/SKILL.md +197 -0
  525. package/skills/scan-project/SKILL.md +41 -0
  526. package/skills/self-audit/SKILL.md +153 -0
  527. package/skills/subagent-driven-development/SKILL.md +154 -0
  528. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
  529. package/skills/subagent-driven-development/implementer-prompt.md +102 -0
  530. package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  531. package/skills/tdd/SKILL.md +23 -0
  532. package/skills/using-git-worktrees/SKILL.md +163 -0
  533. package/skills/using-skills/SKILL.md +95 -0
  534. package/skills/verification/SKILL.md +22 -0
  535. package/skills/wazir/SKILL.md +463 -0
  536. package/skills/writing-plans/SKILL.md +30 -0
  537. package/skills/writing-skills/SKILL.md +157 -0
  538. package/skills/writing-skills/anthropic-best-practices.md +122 -0
  539. package/skills/writing-skills/persuasion-principles.md +50 -0
  540. package/templates/README.md +20 -0
  541. package/templates/artifacts/README.md +10 -0
  542. package/templates/artifacts/accepted-learning.md +19 -0
  543. package/templates/artifacts/accepted-learning.template.json +12 -0
  544. package/templates/artifacts/author.md +74 -0
  545. package/templates/artifacts/author.template.json +19 -0
  546. package/templates/artifacts/clarification.md +21 -0
  547. package/templates/artifacts/clarification.template.json +12 -0
  548. package/templates/artifacts/execute-notes.md +19 -0
  549. package/templates/artifacts/implementation-plan.md +21 -0
  550. package/templates/artifacts/implementation-plan.template.json +11 -0
  551. package/templates/artifacts/learning-proposal.md +19 -0
  552. package/templates/artifacts/next-run-handoff.md +21 -0
  553. package/templates/artifacts/plan-review.md +19 -0
  554. package/templates/artifacts/proposed-learning.template.json +12 -0
  555. package/templates/artifacts/research.md +21 -0
  556. package/templates/artifacts/research.template.json +12 -0
  557. package/templates/artifacts/review-findings.md +19 -0
  558. package/templates/artifacts/review.template.json +11 -0
  559. package/templates/artifacts/run-manifest.template.json +8 -0
  560. package/templates/artifacts/spec-challenge.md +19 -0
  561. package/templates/artifacts/spec-challenge.template.json +11 -0
  562. package/templates/artifacts/spec.md +21 -0
  563. package/templates/artifacts/spec.template.json +12 -0
  564. package/templates/artifacts/verification-proof.md +19 -0
  565. package/templates/artifacts/verification-proof.template.json +11 -0
  566. package/templates/examples/accepted-learning.example.json +14 -0
  567. package/templates/examples/author.example.json +152 -0
  568. package/templates/examples/clarification.example.json +15 -0
  569. package/templates/examples/docs-claim.example.json +8 -0
  570. package/templates/examples/export-manifest.example.json +7 -0
  571. package/templates/examples/host-export-package.example.json +11 -0
  572. package/templates/examples/implementation-plan.example.json +17 -0
  573. package/templates/examples/proposed-learning.example.json +13 -0
  574. package/templates/examples/research.example.json +15 -0
  575. package/templates/examples/research.example.md +6 -0
  576. package/templates/examples/review.example.json +17 -0
  577. package/templates/examples/run-manifest.example.json +9 -0
  578. package/templates/examples/spec-challenge.example.json +14 -0
  579. package/templates/examples/spec.example.json +21 -0
  580. package/templates/examples/verification-proof.example.json +21 -0
  581. package/templates/examples/wazir-manifest.example.yaml +65 -0
  582. package/templates/task-definition-schema.md +99 -0
  583. package/tooling/README.md +20 -0
  584. package/tooling/src/adapters/context-mode.js +50 -0
  585. package/tooling/src/capture/command.js +376 -0
  586. package/tooling/src/capture/store.js +99 -0
  587. package/tooling/src/capture/usage.js +270 -0
  588. package/tooling/src/checks/branches.js +50 -0
  589. package/tooling/src/checks/brand-truth.js +110 -0
  590. package/tooling/src/checks/changelog.js +231 -0
  591. package/tooling/src/checks/command-registry.js +36 -0
  592. package/tooling/src/checks/commits.js +102 -0
  593. package/tooling/src/checks/docs-drift.js +103 -0
  594. package/tooling/src/checks/docs-truth.js +201 -0
  595. package/tooling/src/checks/runtime-surface.js +156 -0
  596. package/tooling/src/cli.js +116 -0
  597. package/tooling/src/command-options.js +56 -0
  598. package/tooling/src/commands/validate.js +320 -0
  599. package/tooling/src/doctor/command.js +91 -0
  600. package/tooling/src/export/command.js +77 -0
  601. package/tooling/src/export/compiler.js +498 -0
  602. package/tooling/src/guards/loop-cap-guard.js +52 -0
  603. package/tooling/src/guards/protected-path-write-guard.js +67 -0
  604. package/tooling/src/index/command.js +152 -0
  605. package/tooling/src/index/storage.js +1061 -0
  606. package/tooling/src/index/summarizers.js +261 -0
  607. package/tooling/src/loaders.js +18 -0
  608. package/tooling/src/project-root.js +22 -0
  609. package/tooling/src/recall/command.js +225 -0
  610. package/tooling/src/schema-validator.js +30 -0
  611. package/tooling/src/state-root.js +40 -0
  612. package/tooling/src/status/command.js +71 -0
  613. package/wazir.manifest.yaml +135 -0
  614. package/workflows/README.md +19 -0
  615. package/workflows/author.md +42 -0
  616. package/workflows/clarify.md +38 -0
  617. package/workflows/design-review.md +46 -0
  618. package/workflows/design.md +44 -0
  619. package/workflows/discover.md +37 -0
  620. package/workflows/execute.md +48 -0
  621. package/workflows/learn.md +38 -0
  622. package/workflows/plan-review.md +42 -0
  623. package/workflows/plan.md +39 -0
  624. package/workflows/prepare-next.md +37 -0
  625. package/workflows/review.md +40 -0
  626. package/workflows/run-audit.md +41 -0
  627. package/workflows/spec-challenge.md +41 -0
  628. package/workflows/specify.md +38 -0
  629. package/workflows/verify.md +37 -0
@@ -0,0 +1,1376 @@
1
+ # GCP Cloud Security Expertise Module
2
+
3
+ > **Purpose:** Comprehensive security reference for AI agents securing Google Cloud Platform deployments.
4
+ > **Last Updated:** 2026-03-08
5
+ > **Sources:** Google Cloud documentation, CIS GCP Benchmark, Google Threat Horizons Report, Wiz research, Unit42, NCC Group, Sysdig, SentinelOne, Orca Security, Palo Alto Networks.
6
+
7
+ ---
8
+
9
+ ## 1. Threat Landscape
10
+
11
+ ### 1.1 GCP-Specific Risk Profile
12
+
13
+ Google Cloud Platform presents a distinct attack surface shaped by its resource hierarchy
14
+ (Organization > Folder > Project > Resource), IAM model, and default service account behavior.
15
+ The most common attack vectors in GCP environments include:
16
+
17
+ - **Overpermissioned service accounts** — The default Compute Engine service account
18
+ (`PROJECT_NUMBER-compute@developer.gserviceaccount.com`) is granted the Editor role,
19
+ providing write access to nearly every resource in the project. Attackers who compromise
20
+ a single VM can pivot across the entire project.
21
+ - **Public Cloud Storage buckets** — Misconfigured ACLs or IAM bindings granting
22
+ `allUsers` or `allAuthenticatedUsers` read access expose data to the internet.
23
+ - **Metadata server exposure** — Every GCE instance can reach the metadata server at
24
+ `http://metadata.google.internal/computeMetadata/v1/`. SSRF vulnerabilities allow
25
+ attackers to extract service account tokens, project metadata, and SSH keys.
26
+ - **Misconfigured firewall rules** — Overly broad ingress rules (0.0.0.0/0) on default
27
+ VPC networks expose services to the public internet.
28
+ - **Service account key leaks** — Long-lived JSON key files committed to Git repositories
29
+ or left in CI/CD logs provide persistent, unmonitored access.
30
+
31
+ ### 1.2 Real-World Incidents
32
+
33
+ **WotNot Cloud Storage Exposure (2024):** An Indian AI chatbot startup left a Google Cloud
34
+ Storage bucket publicly accessible, exposing approximately 346,000 files including scanned
35
+ passports, government IDs, medical records, and travel itineraries. Root cause: missing
36
+ access controls on GCS bucket, no organization policy enforcing uniform bucket-level access.
37
+ (Source: SentinelOne, Cybernews)
38
+
39
+ **CloudImposer Dependency Confusion (2024):** Tenable researchers discovered that Google's
40
+ own documentation for GCP services recommended using `--extra-index-url` for private Python
41
+ packages, creating a dependency confusion vulnerability. A single malicious package in
42
+ PyPI could be deployed to millions of GCP service instances. Google patched the
43
+ documentation and affected services. (Source: Dark Reading, Tenable)
44
+
45
+ **Credential-Based Attacks (2024):** Google's Threat Horizons Report identified that weak
46
+ or non-existent credentials were the most common entry point for cloud attacks in H2 2024.
47
+ Overprivileged service accounts were the primary lateral movement mechanism. Attackers
48
+ increasingly target service accounts over user accounts due to fewer MFA protections.
49
+ (Source: Google Cloud Threat Horizons, Cybersecurity Dive)
50
+
51
+ **LeakyCLI Credential Exposure (2024):** Orca Security disclosed that GCP CLI tools
52
+ (`gcloud`) could expose sensitive credentials, project names, service accounts, and
53
+ environment variables in build logs when used in CI/CD pipelines without proper log
54
+ redaction. (Source: Orca Security)
55
+
56
+ **SSRF Metadata Exploitation:** Palo Alto Unit42 documented active exploitation campaigns
57
+ targeting cloud metadata APIs via SSRF in web applications hosted on GCE. Attackers
58
+ extracted service account access tokens to move laterally within GCP projects. A $31K
59
+ bug bounty was paid for an SSRF in Google Cloud Monitoring that led to metadata
60
+ exposure. (Source: Unit42, Palo Alto Networks)
61
+
62
+ ---
63
+
64
+ ## 2. Core Security Principles
65
+
66
+ ### 2.1 Least Privilege IAM
67
+
68
+ - **Never use primitive roles** (Owner, Editor, Viewer) in production. These include
69
+ thousands of permissions across all GCP services.
70
+ - **Prefer predefined roles** scoped to specific services (e.g., `roles/storage.objectViewer`
71
+ instead of `roles/editor`).
72
+ - **Use custom roles** when predefined roles grant more permissions than needed.
73
+ - **Apply IAM Conditions** for time-based, IP-based, or resource-attribute-based access.
74
+ - **Audit regularly** with IAM Recommender, which suggests permission reductions based
75
+ on actual usage over 90 days.
76
+
77
+ ### 2.2 Service Account Security
78
+
79
+ - **One service account per workload** — Never share service accounts across applications.
80
+ - **Eliminate service account keys** — Use Workload Identity (GKE), Workload Identity
81
+ Federation (external clouds/CI-CD), attached service accounts (GCE/Cloud Run), or
82
+ service account impersonation instead.
83
+ - **Disable default service accounts** — The default Compute Engine and App Engine service
84
+ accounts have excessive permissions.
85
+ - **Disable automatic role grants** for default service accounts via organization policy
86
+ `iam.automaticIamGrantsForDefaultServiceAccounts`.
87
+ - **Set key expiry** if keys are unavoidable — enforce 90-day rotation with organization
88
+ policy `constraints/iam.serviceAccountKeyExpiryHours`.
89
+
90
+ ### 2.3 VPC Service Controls
91
+
92
+ VPC Service Controls create security perimeters around GCP resources to prevent data
93
+ exfiltration, even by users with valid credentials:
94
+
95
+ - Define service perimeters around sensitive projects containing BigQuery, Cloud Storage,
96
+ Cloud KMS, and other data services.
97
+ - Use **dry-run mode** first to analyze violation logs before enforcement.
98
+ - Configure precise **ingress/egress rules** for legitimate cross-perimeter traffic.
99
+ - Combine with IAM — VPC Service Controls do not replace least-privilege IAM.
100
+
101
+ ### 2.4 Organization Policies
102
+
103
+ Key organization policy constraints for security:
104
+
105
+ | Constraint | Purpose |
106
+ |---|---|
107
+ | `constraints/compute.requireShieldedVm` | Enforce Shielded VM on all instances |
108
+ | `constraints/compute.vmExternalIpAccess` | Restrict which VMs can have external IPs |
109
+ | `constraints/iam.disableServiceAccountKeyCreation` | Block creation of SA keys |
110
+ | `constraints/storage.uniformBucketLevelAccess` | Enforce uniform access on buckets |
111
+ | `constraints/gcp.restrictNonCmekServices` | Require CMEK for specified services |
112
+ | `constraints/compute.requireOsLogin` | Enforce OS Login for SSH access |
113
+ | `constraints/sql.restrictPublicIp` | Prevent public IPs on Cloud SQL |
114
+
115
+ ### 2.5 Encryption: CMEK vs Google-Managed
116
+
117
+ | Aspect | Google-Managed | Customer-Managed (CMEK) |
118
+ |---|---|---|
119
+ | Key control | Google manages entirely | Customer controls via Cloud KMS |
120
+ | Rotation | Automatic | Customer-defined schedule |
121
+ | Revocation | Not possible | Customer can disable/destroy key |
122
+ | Audit trail | Limited | Full Cloud Audit Logs |
123
+ | Use case | Default, low-sensitivity | Regulated data, compliance |
124
+
125
+ CMEK uses envelope encryption: data encrypted with a DEK, DEK encrypted with the KMS
126
+ key. Key and data must be in the same region.
127
+
128
+ ### 2.6 BeyondCorp Zero Trust
129
+
130
+ Google's BeyondCorp model eliminates the trusted network perimeter:
131
+
132
+ - **Access is identity-based**, not network-based. No VPN required.
133
+ - **Identity-Aware Proxy (IAP)** verifies user identity and device context before
134
+ granting access to applications.
135
+ - **Context-aware access** evaluates device security posture, IP, location, and time.
136
+ - **Principle:** "Access to services must not be determined by the network from which
137
+ you connect."
138
+
139
+ ---
140
+
141
+ ## 3. Implementation Patterns
142
+
143
+ ### 3.1 IAM Roles and Bindings
144
+
145
+ **Predefined vs Custom Roles:**
146
+
147
+ ```hcl
148
+ # INSECURE: Primitive role grants excessive permissions
149
+ resource "google_project_iam_member" "bad_binding" {
150
+ project = "my-project"
151
+ role = "roles/editor"
152
+ member = "serviceAccount:my-sa@my-project.iam.gserviceaccount.com"
153
+ }
154
+
155
+ # SECURE: Predefined role with minimal permissions
156
+ resource "google_project_iam_member" "good_binding" {
157
+ project = "my-project"
158
+ role = "roles/storage.objectViewer"
159
+ member = "serviceAccount:my-sa@my-project.iam.gserviceaccount.com"
160
+ }
161
+
162
+ # SECURE: Custom role with exact permissions needed
163
+ resource "google_project_iam_custom_role" "minimal_role" {
164
+ role_id = "customStorageReader"
165
+ title = "Custom Storage Reader"
166
+ description = "Read-only access to specific bucket objects"
167
+ permissions = [
168
+ "storage.objects.get",
169
+ "storage.objects.list",
170
+ ]
171
+ }
172
+ ```
173
+
174
+ ### 3.2 Service Account Key Management (Prefer Workload Identity)
175
+
176
+ ```hcl
177
+ # SECURE: Workload Identity for GKE — no keys needed
178
+ resource "google_service_account" "app_sa" {
179
+ account_id = "app-workload"
180
+ display_name = "Application Workload SA"
181
+ }
182
+
183
+ resource "google_service_account_iam_binding" "workload_identity" {
184
+ service_account_id = google_service_account.app_sa.name
185
+ role = "roles/iam.workloadIdentityUser"
186
+ members = [
187
+ "serviceAccount:${var.project_id}.svc.id.goog[${var.namespace}/${var.ksa_name}]",
188
+ ]
189
+ }
190
+
191
+ # SECURE: Workload Identity Federation for external CI/CD (GitHub Actions)
192
+ resource "google_iam_workload_identity_pool" "github_pool" {
193
+ workload_identity_pool_id = "github-pool"
194
+ display_name = "GitHub Actions Pool"
195
+ }
196
+
197
+ resource "google_iam_workload_identity_pool_provider" "github_provider" {
198
+ workload_identity_pool_id = google_iam_workload_identity_pool.github_pool.workload_identity_pool_id
199
+ workload_identity_pool_provider_id = "github-provider"
200
+ display_name = "GitHub Provider"
201
+
202
+ attribute_mapping = {
203
+ "google.subject" = "assertion.sub"
204
+ "attribute.repository" = "assertion.repository"
205
+ }
206
+
207
+ oidc {
208
+ issuer_uri = "https://token.actions.githubusercontent.com"
209
+ }
210
+ }
211
+ ```
212
+
213
+ ### 3.3 VPC Firewall Rules
214
+
215
+ ```hcl
216
+ # INSECURE: Allow all traffic from anywhere
217
+ resource "google_compute_firewall" "bad_rule" {
218
+ name = "allow-all"
219
+ network = "default"
220
+
221
+ allow {
222
+ protocol = "tcp"
223
+ ports = ["0-65535"]
224
+ }
225
+
226
+ source_ranges = ["0.0.0.0/0"] # DANGEROUS: open to the internet
227
+ }
228
+
229
+ # SECURE: Restrictive firewall with specific sources and ports
230
+ resource "google_compute_firewall" "allow_https" {
231
+ name = "allow-https-from-lb"
232
+ network = google_compute_network.vpc.name
233
+
234
+ allow {
235
+ protocol = "tcp"
236
+ ports = ["443"]
237
+ }
238
+
239
+ source_ranges = ["130.211.0.0/22", "35.191.0.0/16"] # GCP LB ranges only
240
+ target_tags = ["web-server"]
241
+ }
242
+
243
+ # SECURE: Deny all egress by default, then allow specific
244
+ resource "google_compute_firewall" "deny_all_egress" {
245
+ name = "deny-all-egress"
246
+ network = google_compute_network.vpc.name
247
+ direction = "EGRESS"
248
+ priority = 65534
249
+
250
+ deny {
251
+ protocol = "all"
252
+ }
253
+
254
+ destination_ranges = ["0.0.0.0/0"]
255
+ }
256
+
257
+ resource "google_compute_firewall" "allow_google_apis" {
258
+ name = "allow-google-apis-egress"
259
+ network = google_compute_network.vpc.name
260
+ direction = "EGRESS"
261
+ priority = 1000
262
+
263
+ allow {
264
+ protocol = "tcp"
265
+ ports = ["443"]
266
+ }
267
+
268
+ destination_ranges = ["199.36.153.4/30"] # Private Google Access
269
+ }
270
+ ```
271
+
272
+ ### 3.4 Private Google Access
273
+
274
+ Enable Private Google Access on subnets so VMs without external IPs can reach
275
+ Google APIs through internal routing:
276
+
277
+ ```hcl
278
+ resource "google_compute_subnetwork" "private_subnet" {
279
+ name = "private-subnet"
280
+ ip_cidr_range = "10.0.1.0/24"
281
+ region = "us-central1"
282
+ network = google_compute_network.vpc.id
283
+ private_ip_google_access = true # Enables Private Google Access
284
+ }
285
+ ```
286
+
287
+ ### 3.5 Cloud KMS Usage
288
+
289
+ ```hcl
290
+ resource "google_kms_key_ring" "keyring" {
291
+ name = "app-keyring"
292
+ location = "us-central1"
293
+ }
294
+
295
+ resource "google_kms_crypto_key" "key" {
296
+ name = "app-encryption-key"
297
+ key_ring = google_kms_key_ring.keyring.id
298
+ rotation_period = "7776000s" # 90 days
299
+
300
+ lifecycle {
301
+ prevent_destroy = true
302
+ }
303
+ }
304
+
305
+ # Grant encrypt/decrypt to specific service account only
306
+ resource "google_kms_crypto_key_iam_member" "encrypter" {
307
+ crypto_key_id = google_kms_crypto_key.key.id
308
+ role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
309
+ member = "serviceAccount:${google_service_account.app_sa.email}"
310
+ }
311
+ ```
312
+
313
+ ### 3.6 Secret Manager
314
+
315
+ ```hcl
316
+ resource "google_secret_manager_secret" "db_password" {
317
+ secret_id = "db-password"
318
+
319
+ replication {
320
+ user_managed {
321
+ replicas {
322
+ location = "us-central1"
323
+ }
324
+ }
325
+ }
326
+
327
+ # CMEK encryption
328
+ encryption {
329
+ kms_key_name = google_kms_crypto_key.key.id
330
+ }
331
+ }
332
+
333
+ # Grant access to specific SA only
334
+ resource "google_secret_manager_secret_iam_member" "accessor" {
335
+ secret_id = google_secret_manager_secret.db_password.id
336
+ role = "roles/secretmanager.secretAccessor"
337
+ member = "serviceAccount:${google_service_account.app_sa.email}"
338
+ }
339
+ ```
340
+
341
+ ### 3.7 Cloud Armor (WAF)
342
+
343
+ ```hcl
344
+ resource "google_compute_security_policy" "policy" {
345
+ name = "web-security-policy"
346
+
347
+ # Default rule: deny all
348
+ rule {
349
+ action = "deny(403)"
350
+ priority = "2147483647"
351
+ match {
352
+ versioned_expr = "SRC_IPS_V1"
353
+ config {
354
+ src_ip_ranges = ["*"]
355
+ }
356
+ }
357
+ description = "Default deny rule"
358
+ }
359
+
360
+ # Allow legitimate traffic
361
+ rule {
362
+ action = "allow"
363
+ priority = "1000"
364
+ match {
365
+ versioned_expr = "SRC_IPS_V1"
366
+ config {
367
+ src_ip_ranges = ["0.0.0.0/0"]
368
+ }
369
+ }
370
+ description = "Allow all (filtered by WAF rules below)"
371
+ }
372
+
373
+ # Block SQL injection
374
+ rule {
375
+ action = "deny(403)"
376
+ priority = "100"
377
+ match {
378
+ expr {
379
+ expression = "evaluatePreconfiguredExpr('sqli-v33-stable')"
380
+ }
381
+ }
382
+ description = "Block SQL injection"
383
+ }
384
+
385
+ # Block XSS
386
+ rule {
387
+ action = "deny(403)"
388
+ priority = "101"
389
+ match {
390
+ expr {
391
+ expression = "evaluatePreconfiguredExpr('xss-v33-stable')"
392
+ }
393
+ }
394
+ description = "Block XSS attacks"
395
+ }
396
+
397
+ # Rate limiting
398
+ rule {
399
+ action = "rate_based_ban"
400
+ priority = "200"
401
+ match {
402
+ versioned_expr = "SRC_IPS_V1"
403
+ config {
404
+ src_ip_ranges = ["*"]
405
+ }
406
+ }
407
+ rate_limit_options {
408
+ conform_action = "allow"
409
+ exceed_action = "deny(429)"
410
+ rate_limit_threshold {
411
+ count = 100
412
+ interval_sec = 60
413
+ }
414
+ ban_duration_sec = 600
415
+ }
416
+ description = "Rate limit: 100 req/min per IP"
417
+ }
418
+ }
419
+ ```
420
+
421
+ ### 3.8 Identity-Aware Proxy
422
+
423
+ ```hcl
424
+ resource "google_iap_web_iam_member" "access" {
425
+ project = var.project_id
426
+ role = "roles/iap.httpsResourceAccessor"
427
+ member = "group:developers@example.com"
428
+ }
429
+
430
+ resource "google_iap_web_backend_service_iam_member" "access" {
431
+ project = var.project_id
432
+ web_backend_service = google_compute_backend_service.app.name
433
+ role = "roles/iap.httpsResourceAccessor"
434
+ member = "group:developers@example.com"
435
+ }
436
+ ```
437
+
438
+ ### 3.9 Secure Cloud Run Configuration
439
+
440
+ ```hcl
441
+ # INSECURE: Public, no auth, default SA
442
+ resource "google_cloud_run_service" "insecure" {
443
+ name = "my-service"
444
+ location = "us-central1"
445
+
446
+ template {
447
+ spec {
448
+ containers {
449
+ image = "gcr.io/my-project/my-app:latest"
450
+ }
451
+ # Uses default compute SA with Editor role
452
+ }
453
+ }
454
+ }
455
+
456
+ resource "google_cloud_run_service_iam_member" "public" {
457
+ service = google_cloud_run_service.insecure.name
458
+ location = "us-central1"
459
+ role = "roles/run.invoker"
460
+ member = "allUsers" # DANGEROUS: anyone can invoke
461
+ }
462
+
463
+ # SECURE: Private, authenticated, dedicated SA, CMEK, VPC connector
464
+ resource "google_cloud_run_service" "secure" {
465
+ name = "my-service"
466
+ location = "us-central1"
467
+
468
+ template {
469
+ spec {
470
+ service_account_name = google_service_account.cloud_run_sa.email
471
+ containers {
472
+ image = "gcr.io/my-project/my-app:v1.2.3" # Pinned version, not :latest
473
+
474
+ env {
475
+ name = "DB_PASSWORD"
476
+ value_from {
477
+ secret_key_ref {
478
+ name = google_secret_manager_secret.db_password.secret_id
479
+ key = "latest"
480
+ }
481
+ }
482
+ }
483
+ }
484
+ }
485
+
486
+ metadata {
487
+ annotations = {
488
+ "run.googleapis.com/vpc-access-connector" = google_vpc_access_connector.connector.id
489
+ "run.googleapis.com/vpc-access-egress" = "all-traffic"
490
+ "run.googleapis.com/encryption-key" = google_kms_crypto_key.key.id
491
+ }
492
+ }
493
+ }
494
+
495
+ metadata {
496
+ annotations = {
497
+ "run.googleapis.com/ingress" = "internal-and-cloud-load-balancing"
498
+ }
499
+ }
500
+ }
501
+
502
+ # Only allow authenticated invocations from specific SA
503
+ resource "google_cloud_run_service_iam_member" "invoker" {
504
+ service = google_cloud_run_service.secure.name
505
+ location = "us-central1"
506
+ role = "roles/run.invoker"
507
+ member = "serviceAccount:${google_service_account.caller_sa.email}"
508
+ }
509
+ ```
510
+
511
+ ---
512
+
513
+ ## 4. Vulnerability Catalog
514
+
515
+ ### VULN-GCP-001: Service Account Key Leaks
516
+
517
+ **Risk:** Critical | **CIS:** 1.4
518
+ **Description:** Service account JSON key files committed to Git repos, stored in CI/CD
519
+ logs, or shared via insecure channels provide persistent, unmonitored access.
520
+ **Detection:** `gcloud iam service-accounts keys list --iam-account=SA_EMAIL` — look
521
+ for user-managed keys. Use GitHub secret scanning or TruffleHog.
522
+ **Remediation:** Delete all user-managed keys. Migrate to Workload Identity Federation.
523
+ Enforce org policy `constraints/iam.disableServiceAccountKeyCreation`.
524
+
525
+ ### VULN-GCP-002: allUsers / allAuthenticatedUsers IAM Bindings
526
+
527
+ **Risk:** Critical | **CIS:** 1.1
528
+ **Description:** IAM bindings granting `allUsers` (anonymous) or `allAuthenticatedUsers`
529
+ (any Google account) access to resources expose data publicly.
530
+ **Detection:** SCC finding `PUBLIC_BUCKET_ACL`, `PUBLIC_DATASET`.
531
+ ```bash
532
+ gcloud asset search-all-iam-policies --scope=projects/PROJECT_ID \
533
+ --query="policy:allUsers OR policy:allAuthenticatedUsers"
534
+ ```
535
+ **Remediation:** Remove public bindings. Enforce org policy
536
+ `constraints/iam.allowedPolicyMemberDomains` to restrict to your domain.
537
+
538
+ ### VULN-GCP-003: Public GCS Buckets
539
+
540
+ **Risk:** Critical | **CIS:** 5.1
541
+ **Description:** Buckets with public ACLs or IAM bindings expose all objects to
542
+ unauthenticated access. The WotNot breach (2024) exposed 346K sensitive files this way.
543
+ **Detection:** SCC finding `PUBLIC_BUCKET_ACL`.
544
+ ```bash
545
+ gsutil iam get gs://BUCKET_NAME | grep -E "allUsers|allAuthenticatedUsers"
546
+ ```
547
+ **Remediation:** Enable uniform bucket-level access. Remove public IAM bindings.
548
+ Enforce org policy `constraints/storage.uniformBucketLevelAccess`.
549
+
550
+ ### VULN-GCP-004: Default Compute Engine Service Account
551
+
552
+ **Risk:** High | **CIS:** 1.5
553
+ **Description:** The default Compute Engine SA is auto-granted Editor role at project
554
+ level. Any VM using this SA inherits excessive permissions.
555
+ **Detection:** List instances using default SA:
556
+ ```bash
557
+ gcloud compute instances list --format="table(name,serviceAccounts[].email)" \
558
+ | grep "compute@developer.gserviceaccount.com"
559
+ ```
560
+ **Remediation:** Create dedicated service accounts per workload. Disable automatic
561
+ role grants via org policy `iam.automaticIamGrantsForDefaultServiceAccounts`.
562
+
563
+ ### VULN-GCP-005: Overpermissive Firewall Rules
564
+
565
+ **Risk:** High | **CIS:** 3.6, 3.7
566
+ **Description:** Firewall rules allowing ingress from `0.0.0.0/0` on sensitive ports
567
+ (SSH/22, RDP/3389, databases) expose services to brute-force and exploitation.
568
+ **Detection:** SCC finding `OPEN_FIREWALL`, `OPEN_SSH_PORT`, `OPEN_RDP_PORT`.
569
+ ```bash
570
+ gcloud compute firewall-rules list --format="table(name,direction,sourceRanges,allowed)" \
571
+ --filter="sourceRanges=0.0.0.0/0"
572
+ ```
573
+ **Remediation:** Restrict source ranges to known IPs/CIDRs. Use IAP for SSH/RDP
574
+ instead of direct firewall exposure. Delete the `default` VPC network.
575
+
576
+ ### VULN-GCP-006: Metadata Server Exposure via SSRF
577
+
578
+ **Risk:** High
579
+ **Description:** Applications with SSRF vulnerabilities can access
580
+ `http://metadata.google.internal/computeMetadata/v1/` to extract service account
581
+ tokens, SSH keys, and project metadata. Legacy metadata endpoints (v0.1, v1beta1)
582
+ do not require the `Metadata-Flavor: Google` header.
583
+ **Detection:** Monitor for unusual metadata API calls in Cloud Audit Logs.
584
+ **Remediation:** Disable legacy metadata endpoints on all VMs. Use the v1 API
585
+ exclusively. Apply network-level SSRF protections. Minimize SA permissions on VMs.
586
+
587
+ ### VULN-GCP-007: Unencrypted Resources (Missing CMEK)
588
+
589
+ **Risk:** Medium | **CIS:** 6.2
590
+ **Description:** Resources using only Google-managed encryption cannot be independently
591
+ audited or revoked. Regulated workloads require CMEK.
592
+ **Detection:** Check for CMEK usage per service.
593
+ **Remediation:** Enable CMEK for Cloud SQL, BigQuery, GCS, GKE secrets, Pub/Sub.
594
+ Enforce org policy `constraints/gcp.restrictNonCmekServices`.
595
+
596
+ ### VULN-GCP-008: Missing Audit Logging
597
+
598
+ **Risk:** High | **CIS:** 2.1
599
+ **Description:** Data Access audit logs are disabled by default in GCP. Without them,
600
+ read operations on sensitive data are invisible to security teams.
601
+ **Detection:** Check audit log configuration:
602
+ ```bash
603
+ gcloud projects get-iam-policy PROJECT_ID --format=json | jq '.auditConfigs'
604
+ ```
605
+ **Remediation:** Enable Data Access audit logs for all services, especially
606
+ BigQuery, Cloud Storage, Cloud SQL, and IAM.
607
+
608
+ ### VULN-GCP-009: Cloud SQL with Public IP
609
+
610
+ **Risk:** High | **CIS:** 6.5
611
+ **Description:** Cloud SQL instances with public IPs are directly reachable from the
612
+ internet, subject to brute-force and exploitation of database vulnerabilities.
613
+ **Detection:** SCC finding `SQL_PUBLIC_IP`.
614
+ ```bash
615
+ gcloud sql instances list --format="table(name,ipAddresses)"
616
+ ```
617
+ **Remediation:** Use private IP only. Connect via Cloud SQL Auth Proxy.
618
+ Enforce org policy `constraints/sql.restrictPublicIp`.
619
+
620
+ ### VULN-GCP-010: Missing VPC Flow Logs
621
+
622
+ **Risk:** Medium | **CIS:** 3.8
623
+ **Description:** Without VPC flow logs, network traffic patterns cannot be analyzed
624
+ for anomalies, lateral movement, or data exfiltration.
625
+ **Detection:** Check subnet configurations for flow log enablement.
626
+ **Remediation:** Enable VPC flow logs on all subnets with appropriate sampling rate.
627
+
628
+ ### VULN-GCP-011: Unrestricted API Key Usage
629
+
630
+ **Risk:** High | **CIS:** 1.12, 1.13, 1.14
631
+ **Description:** API keys without application or API restrictions can be used by
632
+ anyone to consume quota and access enabled APIs.
633
+ **Detection:** List API keys and check restrictions:
634
+ ```bash
635
+ gcloud services api-keys list --format="table(name,restrictions)"
636
+ ```
637
+ **Remediation:** Restrict API keys to specific APIs, HTTP referrers, or IP addresses.
638
+ Prefer service accounts over API keys where possible.
639
+
640
+ ### VULN-GCP-012: GKE Cluster Without Network Policy
641
+
642
+ **Risk:** Medium | **CIS:** 7.11
643
+ **Description:** Without Kubernetes Network Policies, any pod can communicate with
644
+ any other pod in the cluster, enabling lateral movement after compromise.
645
+ **Detection:** Check if network policy is enabled on GKE clusters.
646
+ **Remediation:** Enable network policy enforcement. Deploy default-deny policies.
647
+ Use Autopilot mode for stricter defaults.
648
+
649
+ ### VULN-GCP-013: Container Images Without Binary Authorization
650
+
651
+ **Risk:** Medium
652
+ **Description:** Without Binary Authorization, any container image can be deployed
653
+ to GKE or Cloud Run, including compromised or untrusted images.
654
+ **Detection:** Check Binary Authorization policy.
655
+ **Remediation:** Enable Binary Authorization. Require attestations from trusted
656
+ build systems. Use Artifact Analysis for vulnerability scanning.
657
+
658
+ ### VULN-GCP-014: BigQuery Dataset with Public Access
659
+
660
+ **Risk:** Critical | **CIS:** 7.1
661
+ **Description:** BigQuery datasets granting `allUsers` or `allAuthenticatedUsers`
662
+ access expose potentially sensitive analytical data.
663
+ **Detection:** SCC finding `PUBLIC_DATASET`.
664
+ **Remediation:** Remove public IAM bindings. Use authorized views for controlled
665
+ data sharing. Enable column-level security for sensitive fields.
666
+
667
+ ### VULN-GCP-015: Missing Organization Policy Constraints
668
+
669
+ **Risk:** High
670
+ **Description:** Without organization policies, individual projects can create
671
+ public resources, service account keys, external IPs, and unencrypted instances.
672
+ **Detection:** Audit organization policy configuration:
673
+ ```bash
674
+ gcloud org-policies list --organization=ORG_ID
675
+ ```
676
+ **Remediation:** Implement all security-critical organization policies from Section 2.4.
677
+
678
+ ---
679
+
680
+ ## 5. Security Checklist
681
+
682
+ ### Identity and Access Management
683
+ - [ ] No primitive roles (Owner/Editor/Viewer) assigned in production projects
684
+ - [ ] Each workload uses a dedicated service account with minimal permissions
685
+ - [ ] No user-managed service account keys exist (Workload Identity used instead)
686
+ - [ ] Default service accounts are disabled or have no role grants
687
+ - [ ] `allUsers` and `allAuthenticatedUsers` bindings are absent from all resources
688
+ - [ ] IAM Recommender findings are reviewed and applied monthly
689
+ - [ ] MFA is enforced for all user accounts; hardware keys for admins
690
+ - [ ] Domain-restricted sharing is enforced via org policy
691
+ - [ ] Service account impersonation is logged and monitored
692
+
693
+ ### Network Security
694
+ - [ ] Default VPC network is deleted in all projects
695
+ - [ ] Custom VPC with private subnets is used for all workloads
696
+ - [ ] No firewall rules allow 0.0.0.0/0 ingress on SSH (22) or RDP (3389)
697
+ - [ ] Private Google Access is enabled on all subnets
698
+ - [ ] VPC Flow Logs are enabled on all subnets
699
+ - [ ] Cloud NAT is used for outbound internet access (no external IPs on VMs)
700
+ - [ ] VPC Service Controls perimeters protect sensitive data services
701
+
702
+ ### Data Protection
703
+ - [ ] CMEK is enabled for all regulated/sensitive data services
704
+ - [ ] Cloud KMS keys have rotation policies (90 days or less)
705
+ - [ ] Secrets are stored in Secret Manager (never in env vars or code)
706
+ - [ ] Cloud SQL instances use private IP only (no public IP)
707
+ - [ ] GCS buckets enforce uniform bucket-level access
708
+ - [ ] BigQuery datasets restrict access to specific principals
709
+
710
+ ### Compute and Container Security
711
+ - [ ] Shielded VMs are enforced via organization policy
712
+ - [ ] OS Login is enforced for SSH access (no project/instance SSH keys)
713
+ - [ ] GKE clusters use Workload Identity, not node SA for pod access
714
+ - [ ] GKE network policy enforcement is enabled
715
+ - [ ] Binary Authorization is enabled for GKE and Cloud Run
716
+ - [ ] Container images are scanned for vulnerabilities before deployment
717
+ - [ ] GKE nodes use auto-upgrade and auto-repair
718
+ - [ ] Legacy metadata endpoints are disabled on all compute instances
719
+
720
+ ### Logging and Monitoring
721
+ - [ ] Data Access audit logs are enabled for all services
722
+ - [ ] Admin Activity logs are forwarded to centralized SIEM
723
+ - [ ] Cloud Audit Logs have retention of at least 365 days
724
+ - [ ] SCC Premium or Enterprise is enabled at organization level
725
+ - [ ] Alert policies exist for critical SCC findings
726
+
727
+ ### Organization Governance
728
+ - [ ] Organization policies from Section 2.4 are enforced
729
+ - [ ] Security foundations blueprint is implemented
730
+ - [ ] All projects are under the organization node (no standalone projects)
731
+ - [ ] Folder structure enforces separation of environments (dev/staging/prod)
732
+
733
+ ---
734
+
735
+ ## 6. Tools and Automation
736
+
737
+ ### 6.1 Security Command Center (SCC)
738
+
739
+ GCP's native CSPM and threat detection platform. Available in Standard (free),
740
+ Premium, and Enterprise tiers.
741
+
742
+ **Key capabilities (2025-2026):**
743
+ - **Security Health Analytics** — Continuous misconfiguration detection against CIS
744
+ benchmarks and Google best practices.
745
+ - **Event Threat Detection** — Near real-time detection of active threats across
746
+ Compute Engine, GKE, BigQuery, Cloud SQL, and Cloud Run.
747
+ - **Container Threat Detection** — Runtime monitoring for GKE containers.
748
+ - **Security Graph (Issues)** — Groups findings by severity, showing attack paths
749
+ and blast radius via asset/identity/exposure connections.
750
+ - **DSPM (Data Security Posture Management)** — Discovers sensitive data across GCP,
751
+ classifies sensitivity levels, and provides default posture policies.
752
+ - **Correlated Threats Detection** — Links individual threat findings to reduce alert
753
+ fatigue using 65+ underlying threat detectors.
754
+ - **Model Armor** — Screens LLM prompts and responses for AI workloads.
755
+
756
+ **SCC Finding Categories to Monitor:**
757
+ - `PUBLIC_BUCKET_ACL`, `PUBLIC_DATASET` — Public data exposure
758
+ - `OPEN_FIREWALL`, `OPEN_SSH_PORT`, `OPEN_RDP_PORT` — Network exposure
759
+ - `SQL_PUBLIC_IP` — Database exposure
760
+ - `SA_KEY_CREATED` — Service account key creation
761
+ - `MFA_NOT_ENFORCED` — Missing multi-factor authentication
762
+ - `OVER_PRIVILEGED_ACCOUNT` — Excess permissions
763
+
764
+ ### 6.2 Open-Source Security Scanning Tools
765
+
766
+ **ScoutSuite (NCC Group):**
767
+ Multi-cloud security auditing tool. Gathers GCP configurations via API and generates
768
+ HTML reports with findings mapped to best practices.
769
+ ```bash
770
+ python scout.py gcp --user-account --report-dir ./output
771
+ ```
772
+
773
+ **Prowler for GCP:**
774
+ Open-source security assessment tool performing best-practice audits, incident
775
+ response, continuous monitoring, and forensics readiness.
776
+ ```bash
777
+ prowler gcp --project-id my-project
778
+ ```
779
+
780
+ **Checkov (Bridgecrew/Palo Alto):**
781
+ Static analysis for Terraform, CloudFormation, and Kubernetes manifests. Scans
782
+ IaC before deployment to catch misconfigurations.
783
+ ```bash
784
+ checkov -d ./terraform/ --framework terraform --check CKV_GCP*
785
+ ```
786
+
787
+ **tfsec (Aqua Security):**
788
+ Fast Terraform-specific static analysis. Now integrated into Trivy.
789
+ ```bash
790
+ tfsec ./terraform/
791
+ ```
792
+
793
+ **Terrascan:**
794
+ IaC scanner supporting Terraform, Kubernetes, Helm, and Dockerfiles with
795
+ policy-as-code using OPA/Rego.
796
+
797
+ ### 6.3 Google-Native Automation
798
+
799
+ **Cloud Asset Inventory:**
800
+ ```bash
801
+ # Export all IAM policies for analysis
802
+ gcloud asset search-all-iam-policies --scope=organizations/ORG_ID \
803
+ --query="policy:allUsers" --format=json > public_policies.json
804
+
805
+ # Find all resources of a type
806
+ gcloud asset search-all-resources --scope=projects/PROJECT_ID \
807
+ --asset-types="sqladmin.googleapis.com/Instance"
808
+ ```
809
+
810
+ **Policy Analyzer:**
811
+ ```bash
812
+ # Analyze who can access a resource
813
+ gcloud policy-intelligence query-activity \
814
+ --activity-type=serviceAccountKeyLastAuthentication \
815
+ --project=PROJECT_ID
816
+ ```
817
+
818
+ **IAM Recommender:**
819
+ ```bash
820
+ # Get IAM recommendations for a project
821
+ gcloud recommender recommendations list \
822
+ --recommender=google.iam.policy.Recommender \
823
+ --project=PROJECT_ID --location=global
824
+ ```
825
+
826
+ ### 6.4 Forseti (Deprecated)
827
+
828
+ Forseti Security was the primary open-source GCP security tool but is now archived.
829
+ Google incorporated its core capabilities into Security Command Center. Migrate
830
+ Forseti workloads to SCC Premium or open-source alternatives (ScoutSuite, Prowler).
831
+
832
+ ---
833
+
834
+ ## 7. Platform-Specific Guidance
835
+
836
+ ### 7.1 Compute Engine
837
+
838
+ - **Shielded VMs:** Enable Secure Boot, vTPM, and Integrity Monitoring to protect
839
+ against rootkits and bootkits. Enforce via org policy.
840
+ - **OS Login:** Replace SSH key metadata with OS Login for centralized, IAM-based
841
+ SSH access control with POSIX account management.
842
+ - **Metadata protection:** Disable legacy metadata endpoints. Set
843
+ `metadata.google.internal` requests to require `Metadata-Flavor: Google` header.
844
+ - **No external IPs:** Use Cloud NAT for outbound access and IAP tunnels for SSH.
845
+ - **Confidential VMs:** Use for workloads processing highly sensitive data — encrypts
846
+ data in memory using AMD SEV or Intel TDX.
847
+
848
+ ### 7.2 Google Kubernetes Engine (GKE)
849
+
850
+ - **Use Autopilot mode** for a hardened-by-default security posture (no node SSH,
851
+ enforced Workload Identity, automatic upgrades).
852
+ - **Workload Identity:** Map K8s ServiceAccounts to GCP SAs. Never mount SA keys.
853
+ - **Private clusters:** Disable public endpoint or restrict via authorized networks.
854
+ - **Network Policies:** Enable Calico/Dataplane V2 and deploy default-deny policies.
855
+ - **Binary Authorization:** Require signed attestations for all deployed images.
856
+ - **Shielded GKE Nodes:** Protect against rootkits with Secure Boot and integrity
857
+ monitoring.
858
+ - **Application-layer secret encryption:** Encrypt K8s Secrets in etcd with Cloud KMS.
859
+ - **Pod Security Standards:** Enforce restricted pod security standards to prevent
860
+ privileged containers, host networking, and host path mounts.
861
+ - **Auto-upgrade and auto-repair:** Keep nodes patched and healthy automatically.
862
+
863
+ ### 7.3 Cloud Run
864
+
865
+ - **Ingress restrictions:** Set ingress to `internal` or `internal-and-cloud-load-balancing`.
866
+ Never use `all` for internal services.
867
+ - **Dedicated service account:** Never use the default Compute Engine SA.
868
+ - **CMEK encryption:** Encrypt container images and data at rest.
869
+ - **VPC connector:** Route egress through VPC for private resource access and
870
+ network policy enforcement.
871
+ - **Min instances = 0:** Reduces attack surface when service is idle.
872
+ - **Secret Manager integration:** Mount secrets as environment variables or volumes.
873
+ Never embed secrets in container images.
874
+
875
+ ### 7.4 Cloud Functions
876
+
877
+ - **Dedicated service account:** Create a minimal-permission SA for each function.
878
+ - **VPC connector:** Connect to private resources without exposing to the internet.
879
+ - **Ingress settings:** Set to `ALLOW_INTERNAL_ONLY` for internal-only functions.
880
+ - **Secret Manager:** Use the built-in Secret Manager integration for credentials.
881
+ - **Runtime updates:** Pin runtime versions and rebuild regularly for security patches.
882
+ - **Environment variable security:** Never store secrets in plain-text env vars.
883
+ Use Secret Manager references instead.
884
+
885
+ ### 7.5 Cloud SQL
886
+
887
+ - **Private IP only:** Enforce via org policy `constraints/sql.restrictPublicIp`.
888
+ - **Cloud SQL Auth Proxy:** Use for authenticated, encrypted connections from
889
+ applications. Supports Workload Identity.
890
+ - **SSL/TLS enforcement:** Require SSL for all connections:
891
+ ```bash
892
+ gcloud sql instances patch INSTANCE_NAME --require-ssl
893
+ ```
894
+ - **CMEK encryption:** Encrypt instances with customer-managed keys.
895
+ - **Automated backups:** Enable automated backups with point-in-time recovery.
896
+ - **Database flags:** Set `log_connections`, `log_disconnections`, `log_min_duration_statement`
897
+ for audit logging (PostgreSQL). Set `general_log` and `slow_query_log` for MySQL.
898
+ - **Private service access:** Use VPC peering for private connectivity.
899
+
900
+ ### 7.6 Cloud Storage
901
+
902
+ - **Uniform bucket-level access:** Enforce via org policy to prevent ACL complexity.
903
+ - **Retention policies:** Set object retention for compliance requirements.
904
+ - **Object versioning:** Enable to protect against accidental deletion or overwrite.
905
+ - **Signed URLs:** Use for time-limited, scoped access instead of making buckets public.
906
+ - **VPC Service Controls:** Place sensitive buckets inside a service perimeter.
907
+ - **Data access logging:** Enable Data Access audit logs for all storage operations.
908
+ - **Object lifecycle management:** Automatically delete or archive stale data.
909
+
910
+ ### 7.7 BigQuery
911
+
912
+ - **Dataset-level IAM:** Grant access at dataset level, not project level.
913
+ - **Authorized views:** Share query results without exposing underlying tables.
914
+ - **Column-level security:** Use policy tags to restrict access to sensitive columns.
915
+ - **Row-level security:** Use row access policies to filter data per user.
916
+ - **CMEK encryption:** Encrypt datasets with customer-managed keys.
917
+ - **VPC Service Controls:** Prevent data exfiltration via perimeter controls.
918
+ - **Audit logging:** Enable Data Access logs to track all queries and data access.
919
+ - **Slot reservations:** Use reservations to prevent query-based denial of service.
920
+
921
+ ---
922
+
923
+ ## 8. Incident Patterns
924
+
925
+ ### 8.1 GCS Bucket Exposure Detection and Response
926
+
927
+ **Detection Signals:**
928
+ - SCC finding `PUBLIC_BUCKET_ACL` or `PUBLIC_LOG_BUCKET`
929
+ - Cloud Audit Log: `storage.setIamPolicy` with `allUsers` member
930
+ - External scanning tools report (e.g., GrayhatWarfare bucket search)
931
+
932
+ **Response Playbook:**
933
+ 1. **Contain:** Remove public IAM bindings immediately:
934
+ ```bash
935
+ gsutil iam ch -d allUsers gs://BUCKET_NAME
936
+ gsutil iam ch -d allAuthenticatedUsers gs://BUCKET_NAME
937
+ ```
938
+ 2. **Assess:** Review Data Access audit logs to identify what was accessed:
939
+ ```bash
940
+ gcloud logging read 'resource.type="gcs_bucket" AND
941
+ protoPayload.methodName="storage.objects.get" AND
942
+ protoPayload.authenticationInfo.principalEmail="anonymous"' \
943
+ --project=PROJECT_ID --limit=1000
944
+ ```
945
+ 3. **Investigate:** Determine duration of exposure, data sensitivity, and scope.
946
+ 4. **Remediate:** Enable uniform bucket-level access. Enforce org policy.
947
+ 5. **Notify:** Determine if data breach notification is required per applicable
948
+ regulations (GDPR 72-hour window, state breach notification laws).
949
+
950
+ ### 8.2 Service Account Compromise Response
951
+
952
+ **Detection Signals:**
953
+ - Unusual API calls from a service account (geographic anomaly, new APIs called)
954
+ - SCC Event Threat Detection finding: `ANOMALOUS_SERVICE_ACCOUNT_USAGE`
955
+ - Service account used from unexpected IP or network
956
+
957
+ **Response Playbook:**
958
+ 1. **Contain:** Disable the compromised service account immediately:
959
+ ```bash
960
+ gcloud iam service-accounts disable SA_EMAIL
961
+ ```
962
+ 2. **Revoke keys:** Delete all user-managed keys:
963
+ ```bash
964
+ gcloud iam service-accounts keys list --iam-account=SA_EMAIL
965
+ gcloud iam service-accounts keys delete KEY_ID --iam-account=SA_EMAIL
966
+ ```
967
+ 3. **Audit:** Review Cloud Audit Logs for all actions performed by the SA:
968
+ ```bash
969
+ gcloud logging read 'protoPayload.authenticationInfo.principalEmail="SA_EMAIL"' \
970
+ --project=PROJECT_ID --freshness=30d
971
+ ```
972
+ 4. **Assess blast radius:** Determine what resources the SA could access (use
973
+ Policy Analyzer).
974
+ 5. **Remediate:** Create a new SA with minimal permissions. Migrate workloads.
975
+ Implement Workload Identity to eliminate keys.
976
+
977
+ ### 8.3 SCC Critical Finding Alert Response
978
+
979
+ **Detection Signals:**
980
+ - SCC finding with severity CRITICAL or HIGH
981
+ - Pub/Sub notification from SCC findings export
982
+ - SIEM alert from ingested SCC data
983
+
984
+ **Response Playbook:**
985
+ 1. **Triage:** Review the SCC finding details, affected resource, and category.
986
+ 2. **Classify:** Determine if finding indicates active exploitation or
987
+ misconfiguration.
988
+ 3. **For active threats:**
989
+ - Isolate affected resources (disable SA, restrict network, stop instance)
990
+ - Engage incident response team
991
+ - Preserve evidence (snapshot disks, export logs)
992
+ 4. **For misconfigurations:**
993
+ - Remediate per the finding's recommendation
994
+ - Create org policy to prevent recurrence
995
+ - Update IaC templates to include the secure configuration
996
+ 5. **Document:** Record incident timeline, root cause, and remediation steps.
997
+
998
+ ---
999
+
1000
+ ## 9. Compliance and Standards
1001
+
1002
+ ### 9.1 CIS Google Cloud Platform Foundation Benchmark
1003
+
1004
+ The CIS GCP Benchmark (current version 3.0+) provides consensus-based security
1005
+ configuration guidelines organized into sections:
1006
+
1007
+ | Section | Coverage |
1008
+ |---|---|
1009
+ | 1. IAM | Service accounts, key management, separation of duties |
1010
+ | 2. Logging and Monitoring | Audit logs, log sinks, alert policies |
1011
+ | 3. Networking | Firewall rules, DNS, SSL policies, flow logs |
1012
+ | 4. Virtual Machines | Shielded VM, OS Login, metadata, disks |
1013
+ | 5. Storage | Bucket access, encryption, retention |
1014
+ | 6. Cloud SQL | Public IP, SSL, backups, flags |
1015
+ | 7. BigQuery | Dataset access, encryption, audit |
1016
+
1017
+ **Assessment tools:**
1018
+ - SCC Security Health Analytics (maps findings to CIS controls)
1019
+ - InSpec GCP CIS Benchmark profile (GitHub: GoogleCloudPlatform/inspec-gcp-cis-benchmark)
1020
+ - Prowler, ScoutSuite, Checkov (open-source)
1021
+ - Steampipe with GCP CIS mod
1022
+
1023
+ ### 9.2 GCP Security Foundations Blueprint
1024
+
1025
+ Google's opinionated reference architecture for secure GCP deployments:
1026
+
1027
+ - **Organization structure:** Organization > Environment Folders (bootstrap, common,
1028
+ production, non-production, development) > Projects.
1029
+ - **Networking:** Hub-and-spoke or shared VPC topology with centralized firewall
1030
+ management.
1031
+ - **Identity:** Cloud Identity with MFA, federated from corporate IdP.
1032
+ - **Logging:** Centralized log sink to BigQuery/Cloud Storage with 365-day retention.
1033
+ - **Security:** SCC Premium enabled at org level, VPC Service Controls for
1034
+ sensitive projects.
1035
+ - **IaC:** Terraform-based deployment via Cloud Build with policy-as-code gates.
1036
+
1037
+ Implementation: Terraform blueprints available at
1038
+ `github.com/terraform-google-modules/terraform-example-foundation`.
1039
+
1040
+ ### 9.3 SOC 2 on GCP
1041
+
1042
+ - **Trust Services Criteria mapping:**
1043
+ - Security (CC6): IAM, encryption, firewall rules, VPC Service Controls
1044
+ - Availability (A1): Load balancing, auto-scaling, multi-region deployment
1045
+ - Confidentiality (C1): CMEK, DLP, data classification
1046
+ - Processing Integrity (PI1): Cloud Audit Logs, change management
1047
+ - Privacy (P1): DLP, data residency, retention policies
1048
+ - **Evidence collection:** Cloud Audit Logs, SCC findings exports, IAM policy
1049
+ snapshots, Cloud Asset Inventory exports.
1050
+ - **Google's SOC 2 report:** Available via Compliance Reports Manager for
1051
+ GCP services — covers Google's infrastructure controls.
1052
+
1053
+ ### 9.4 PCI DSS on GCP
1054
+
1055
+ - **Shared responsibility:** Google is a PCI DSS Level 1 Service Provider.
1056
+ Customers are responsible for their workload configuration.
1057
+ - **Key requirements:**
1058
+ - Requirement 2: Remove default credentials, harden configs (Shielded VM,
1059
+ CIS benchmarks)
1060
+ - Requirement 3: Protect stored cardholder data (CMEK, DLP, tokenization)
1061
+ - Requirement 7: Restrict access (IAM least privilege, VPC Service Controls)
1062
+ - Requirement 8: Authentication (MFA, OS Login, IAP)
1063
+ - Requirement 10: Logging (Cloud Audit Logs, Data Access logs)
1064
+ - Requirement 11: Testing (Web Security Scanner, SCC vulnerability scanning)
1065
+ - **Sensitive Data Protection (DLP):** Use to discover, classify, and redact
1066
+ cardholder data across GCS, BigQuery, and Datastore.
1067
+
1068
+ ### 9.5 Additional Compliance Frameworks
1069
+
1070
+ - **ISO 27001/27017/27018:** GCP is certified. Map controls to IAM, encryption,
1071
+ logging, and incident response configurations.
1072
+ - **HIPAA:** Sign a BAA with Google. Use CMEK, VPC Service Controls, DLP, and
1073
+ audit logging for PHI workloads.
1074
+ - **FedRAMP High:** GCP has FedRAMP High authorization for specific regions
1075
+ and services. Use Assured Workloads for compliance guardrails.
1076
+
1077
+ ---
1078
+
1079
+ ## 10. Code Examples
1080
+
1081
+ ### 10.1 Complete Secure Project Setup (Terraform)
1082
+
1083
+ ```hcl
1084
+ # --- Provider Configuration ---
1085
+ provider "google" {
1086
+ project = var.project_id
1087
+ region = var.region
1088
+ }
1089
+
1090
+ # --- Enable Required APIs ---
1091
+ resource "google_project_service" "required_apis" {
1092
+ for_each = toset([
1093
+ "compute.googleapis.com",
1094
+ "container.googleapis.com",
1095
+ "cloudkms.googleapis.com",
1096
+ "secretmanager.googleapis.com",
1097
+ "logging.googleapis.com",
1098
+ "monitoring.googleapis.com",
1099
+ "securitycenter.googleapis.com",
1100
+ "iap.googleapis.com",
1101
+ "vpcaccess.googleapis.com",
1102
+ ])
1103
+ project = var.project_id
1104
+ service = each.value
1105
+ }
1106
+
1107
+ # --- Custom VPC (no default network) ---
1108
+ resource "google_compute_network" "vpc" {
1109
+ name = "secure-vpc"
1110
+ auto_create_subnetworks = false # No default subnets
1111
+ routing_mode = "REGIONAL"
1112
+ }
1113
+
1114
+ resource "google_compute_subnetwork" "private" {
1115
+ name = "private-subnet"
1116
+ ip_cidr_range = "10.0.0.0/24"
1117
+ region = var.region
1118
+ network = google_compute_network.vpc.id
1119
+ private_ip_google_access = true
1120
+
1121
+ log_config {
1122
+ aggregation_interval = "INTERVAL_5_SEC"
1123
+ flow_sampling = 0.5
1124
+ metadata = "INCLUDE_ALL_METADATA"
1125
+ }
1126
+ }
1127
+
1128
+ # --- Default deny-all firewall rules ---
1129
+ resource "google_compute_firewall" "deny_all_ingress" {
1130
+ name = "deny-all-ingress"
1131
+ network = google_compute_network.vpc.name
1132
+ direction = "INGRESS"
1133
+ priority = 65534
1134
+
1135
+ deny {
1136
+ protocol = "all"
1137
+ }
1138
+
1139
+ source_ranges = ["0.0.0.0/0"]
1140
+ }
1141
+
1142
+ # --- Allow only IAP for SSH ---
1143
+ resource "google_compute_firewall" "allow_iap_ssh" {
1144
+ name = "allow-iap-ssh"
1145
+ network = google_compute_network.vpc.name
1146
+ direction = "INGRESS"
1147
+ priority = 1000
1148
+
1149
+ allow {
1150
+ protocol = "tcp"
1151
+ ports = ["22"]
1152
+ }
1153
+
1154
+ source_ranges = ["35.235.240.0/20"] # IAP's IP range
1155
+ target_tags = ["allow-ssh"]
1156
+ }
1157
+
1158
+ # --- Cloud NAT for outbound access ---
1159
+ resource "google_compute_router" "router" {
1160
+ name = "nat-router"
1161
+ region = var.region
1162
+ network = google_compute_network.vpc.id
1163
+ }
1164
+
1165
+ resource "google_compute_router_nat" "nat" {
1166
+ name = "nat-gateway"
1167
+ router = google_compute_router.router.name
1168
+ region = var.region
1169
+ nat_ip_allocate_option = "AUTO_ONLY"
1170
+ source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
1171
+ }
1172
+ ```
1173
+
1174
+ ### 10.2 Enable Comprehensive Audit Logging (Terraform)
1175
+
1176
+ ```hcl
1177
+ # INSECURE: No data access audit logs (default)
1178
+ # Data read/write operations are invisible to security teams
1179
+
1180
+ # SECURE: Enable data access audit logs for all services
1181
+ resource "google_project_iam_audit_config" "all_services" {
1182
+ project = var.project_id
1183
+ service = "allServices"
1184
+
1185
+ audit_log_config {
1186
+ log_type = "ADMIN_READ"
1187
+ }
1188
+ audit_log_config {
1189
+ log_type = "DATA_READ"
1190
+ }
1191
+ audit_log_config {
1192
+ log_type = "DATA_WRITE"
1193
+ }
1194
+ }
1195
+
1196
+ # Centralized log sink to Cloud Storage for long-term retention
1197
+ resource "google_logging_project_sink" "audit_sink" {
1198
+ name = "audit-log-sink"
1199
+ destination = "storage.googleapis.com/${google_storage_bucket.audit_logs.name}"
1200
+ filter = "logName:\"logs/cloudaudit.googleapis.com\""
1201
+ unique_writer_identity = true
1202
+ }
1203
+
1204
+ resource "google_storage_bucket" "audit_logs" {
1205
+ name = "${var.project_id}-audit-logs"
1206
+ location = var.region
1207
+ force_destroy = false
1208
+
1209
+ uniform_bucket_level_access = true
1210
+
1211
+ retention_policy {
1212
+ retention_period = 31536000 # 365 days in seconds
1213
+ }
1214
+
1215
+ lifecycle_rule {
1216
+ condition {
1217
+ age = 365
1218
+ }
1219
+ action {
1220
+ type = "SetStorageClass"
1221
+ storage_class = "COLDLINE"
1222
+ }
1223
+ }
1224
+ }
1225
+ ```
1226
+
1227
+ ### 10.3 Organization Policy Enforcement (Terraform)
1228
+
1229
+ ```hcl
1230
+ # Disable service account key creation across the org
1231
+ resource "google_organization_policy" "disable_sa_keys" {
1232
+ org_id = var.org_id
1233
+ constraint = "constraints/iam.disableServiceAccountKeyCreation"
1234
+
1235
+ boolean_policy {
1236
+ enforced = true
1237
+ }
1238
+ }
1239
+
1240
+ # Restrict external IPs on VMs
1241
+ resource "google_organization_policy" "vm_external_ip" {
1242
+ org_id = var.org_id
1243
+ constraint = "constraints/compute.vmExternalIpAccess"
1244
+
1245
+ list_policy {
1246
+ deny {
1247
+ all = true
1248
+ }
1249
+ }
1250
+ }
1251
+
1252
+ # Enforce uniform bucket access
1253
+ resource "google_organization_policy" "uniform_bucket" {
1254
+ org_id = var.org_id
1255
+ constraint = "constraints/storage.uniformBucketLevelAccess"
1256
+
1257
+ boolean_policy {
1258
+ enforced = true
1259
+ }
1260
+ }
1261
+
1262
+ # Require Shielded VMs
1263
+ resource "google_organization_policy" "shielded_vm" {
1264
+ org_id = var.org_id
1265
+ constraint = "constraints/compute.requireShieldedVm"
1266
+
1267
+ boolean_policy {
1268
+ enforced = true
1269
+ }
1270
+ }
1271
+
1272
+ # Restrict Cloud SQL public IP
1273
+ resource "google_organization_policy" "sql_no_public_ip" {
1274
+ org_id = var.org_id
1275
+ constraint = "constraints/sql.restrictPublicIp"
1276
+
1277
+ boolean_policy {
1278
+ enforced = true
1279
+ }
1280
+ }
1281
+
1282
+ # Restrict domain in IAM policies
1283
+ resource "google_organization_policy" "domain_restricted" {
1284
+ org_id = var.org_id
1285
+ constraint = "constraints/iam.allowedPolicyMemberDomains"
1286
+
1287
+ list_policy {
1288
+ allow {
1289
+ values = [var.allowed_domain_id] # Your Cloud Identity customer ID
1290
+ }
1291
+ }
1292
+ }
1293
+ ```
1294
+
1295
+ ### 10.4 Secure GKE Cluster (Terraform)
1296
+
1297
+ ```hcl
1298
+ # INSECURE: Public GKE cluster with default SA
1299
+ resource "google_container_cluster" "insecure" {
1300
+ name = "insecure-cluster"
1301
+ location = var.region
1302
+
1303
+ initial_node_count = 3
1304
+ # Public endpoint, no network policy, default SA, no shielded nodes
1305
+ }
1306
+
1307
+ # SECURE: Private GKE Autopilot cluster with full hardening
1308
+ resource "google_container_cluster" "secure" {
1309
+ name = "secure-cluster"
1310
+ location = var.region
1311
+
1312
+ enable_autopilot = true
1313
+
1314
+ network = google_compute_network.vpc.name
1315
+ subnetwork = google_compute_subnetwork.private.name
1316
+
1317
+ private_cluster_config {
1318
+ enable_private_nodes = true
1319
+ enable_private_endpoint = false # Set true for fully private
1320
+ master_ipv4_cidr_block = "172.16.0.0/28"
1321
+ }
1322
+
1323
+ master_authorized_networks_config {
1324
+ cidr_blocks {
1325
+ cidr_block = var.admin_cidr
1326
+ display_name = "Admin Network"
1327
+ }
1328
+ }
1329
+
1330
+ ip_allocation_policy {
1331
+ cluster_secondary_range_name = "pods"
1332
+ services_secondary_range_name = "services"
1333
+ }
1334
+
1335
+ binary_authorization {
1336
+ evaluation_mode = "PROJECT_SINGLETON_POLICY"
1337
+ }
1338
+
1339
+ # Workload Identity
1340
+ workload_identity_config {
1341
+ workload_pool = "${var.project_id}.svc.id.goog"
1342
+ }
1343
+
1344
+ # Database encryption with CMEK
1345
+ database_encryption {
1346
+ state = "ENCRYPTED"
1347
+ key_name = google_kms_crypto_key.gke_key.id
1348
+ }
1349
+
1350
+ release_channel {
1351
+ channel = "REGULAR"
1352
+ }
1353
+ }
1354
+ ```
1355
+
1356
+ ---
1357
+
1358
+ ## References
1359
+
1360
+ - Google Cloud Security Best Practices Center: https://cloud.google.com/security/best-practices
1361
+ - CIS Google Cloud Platform Benchmark: https://www.cisecurity.org/benchmark/google_cloud_computing_platform
1362
+ - GCP Security Foundations Blueprint: https://cloud.google.com/architecture/security-foundations
1363
+ - Google Threat Horizons Report: https://cloud.google.com/security/threat-horizons
1364
+ - IAM Best Practices: https://cloud.google.com/iam/docs/using-iam-securely
1365
+ - Service Account Security: https://docs.google.com/iam/docs/best-practices-service-accounts
1366
+ - VPC Service Controls: https://cloud.google.com/vpc-service-controls/docs/overview
1367
+ - Security Command Center: https://cloud.google.com/security/products/security-command-center
1368
+ - Workload Identity Federation: https://cloud.google.com/iam/docs/workload-identity-federation
1369
+ - Cloud KMS CMEK Best Practices: https://cloud.google.com/kms/docs/cmek-best-practices
1370
+ - GKE Hardening Guide: https://cloud.google.com/kubernetes-engine/docs/how-to/hardening-your-cluster
1371
+ - SentinelOne GCP Security: https://www.sentinelone.com/cybersecurity-101/cloud-security/google-cloud-security-best-practices/
1372
+ - Wiz GCP Security: https://www.wiz.io/academy/cloud-security/google-cloud-security-best-practices
1373
+ - Sysdig GCP Best Practices: https://www.sysdig.com/learn-cloud-native/24-google-cloud-platform-gcp-security-best-practices
1374
+ - Orca Security LeakyCLI: https://orca.security/resources/blog/leakycli-aws-google-cloud-command-line-tools-can-expose-sensitive-credentials-build-logs/
1375
+ - Dark Reading CloudImposer: https://www.darkreading.com/cloud-security/cloudimposer-flaw-google-cloud-affected-millions-servers
1376
+ - Unit42 SSRF Research: https://unit42.paloaltonetworks.com/server-side-request-forgery-exposes-data-of-technology-industrial-and-media-organizations/