Chapter 23 · Encryption, CMEK, Network Access, Private Connectivity, and Data Governance

Build a Security / Governance Control Matrix Mapping Threats and Compliance Requirements to Firestore / Google Cloud Controls

Turn governance requirements into testable controls with owners, evidence, failure modes, recovery procedures, and mode-specific Firestore/Google Cloud implementation choices.

Advanced · 160–220 minutescontrol matrix · threat model · evidence · ownership · auditNode 22+ · Firebase CLI 15.30.0 · Firestore emulator 127.0.0.1:8080Mandatory governance lab local/no-cost · CMEK/VPC/managed evidence optional cloud-onlyLast reviewed: 17 September 2026

1. AtlasMart problem: a list of security products is not a governance architecture

AtlasMart’s audit package says “TLS, CMEK, VPC, IAM, Rules, backups, logs.” It looks impressive but does not say which threat each control addresses, who owns it, what evidence proves it works, how failure is detected, or what recovery action exists. This lesson turns the previous four lessons into a control matrix that can be reviewed and tested.

Learning outcomes
  • Map threats/requirements to preventive, detective, and recovery controls.
  • Assign owners and evidence sources rather than relying on configuration screenshots.
  • Separate client, backend, database, key, network, logging, backup, and lifecycle trust boundaries.
  • Model Standard/Enterprise/Native/MongoDB compatibility differences explicitly.
  • Run a deterministic governance regression test in CI.
Execution and safety note

Use the Emulator Suite, a Firebase demo project, or an isolated test project for destructive, security-sensitive, billing-sensitive, migration, backup/restore, or write-heavy exercises unless the lesson explicitly marks managed verification as required. Treat shown output as expected evidence unless it is explicitly identified as captured output, and re-check current Firebase/Google Cloud edition, mode, quota, pricing, and security documentation before production execution.

Chapter 23 reproducibility baseline · reviewed 17 September 2026

AtlasMart keeps project ID demo-atlasmart-firestore, Standard-edition Native mode, database (default), Node.js 22+, Firebase CLI 15.30.0, Firebase Admin Node SDK 14.4.0, Firestore emulator 127.0.0.1:8080, Auth emulator 127.0.0.1:9099, and Emulator UI 127.0.0.1:4000. Mandatory work is deterministic and local. Cloud KMS/CMEK, VPC Service Controls, Private Google Access, regional endpoints, Cloud Audit Logs, managed backup/export evidence, and real residency validation require a real Google Cloud project and are optional controlled verification steps. The emulator does not emulate KMS key availability, Google network routing, service perimeters, regional processing guarantees, or managed audit logs. The control matrix is a technical artifact. Regulatory applicability and sufficiency must be validated by the organization responsible for legal/compliance decisions.

Term Meaning in this chapter
Client SDK Mobile/web Firestore path normally authorized with Firebase Authentication and Security Rules; App Check can reduce abuse but does not replace authorization.
Server/Admin SDK Trusted workload path authenticated with Google credentials/IAM; it bypasses Firestore Security Rules and therefore requires application-layer authorization.
Standard / Enterprise Firestore editions with different query/index/pricing capabilities. Governance controls must be checked against the actual edition and interface.
Native Core / Pipeline Enterprise Native can expose familiar Core operations and advanced Pipeline operations. Network/encryption controls protect the database resource; query semantics still differ.
MongoDB compatibility Enterprise mode exposing a MongoDB-compatible protocol and firestore.goog endpoint. It is not MongoDB server software and has distinct private-connectivity instructions.
CMEK Customer-managed encryption key in Cloud KMS used by Firestore for server-side encryption at rest. It is not client-side encryption.
VPC Service Controls A Google Cloud data-exfiltration control that places supported managed services/resources behind a service perimeter. It complements rather than replaces IAM/Rules.

2. Control matrix anatomy

Each row needs at least: requirement/threat, protected asset, preventive control, detective evidence, recovery/response, owner, scope/mode, test cadence, and known residual risk. Avoid binary “compliant/not compliant” labels in engineering configuration; record measurable control facts.

Threat / requirement Prevent Detect / evidence Recover / respond
Unauthorized mobile read Firebase Auth + Security Rules + constrained queries Rules tests, denial logs, App Check signals Rules rollback, token/user response
Compromised backend identity Least-privilege IAM + app authorization + perimeter where justified Audit logs, IAM diff, anomaly alerts Disable identity, rotate credentials, review accessed scope
KMS key unavailable Key policy/rotation gates, service-agent permission KMS/Firestore alerts, active key versions Re-enable/restore permission, invoke DR if necessary
Data exfiltration path VPC SC + restricted/private API path + egress controls Perimeter violations, firewall/DNS policy checks Block path, revoke principal, incident investigation
Logical corruption Change control, least privilege Integrity checks, application metrics PITR/backup/clone restore drill
PII leakage in logs Structured redaction CI log-content tests, DLP/security review as applicable Delete/expire affected logs per policy, rotate secrets if leaked
Deletion request incomplete Data inventory + idempotent deletion workflow Per-scope deletion evidence Resume failed scopes, reconcile deferred copies

3. Mode/edition columns prevent false equivalence

A governance row must say whether it applies to Standard Native, Enterprise Native Core/Pipeline, MongoDB compatibility, mobile/web client path, or trusted server path. For example, Firestore Security Rules govern supported Firebase client interfaces but Admin/server paths rely on IAM/application authorization. MongoDB compatibility uses a different protocol/connection model and dedicated Private Google Access guidance. Regional endpoints are available to server client libraries, not mobile/web.

governance/control-matrix.yaml
controls:  - id: ENC-01    threat: data-at-rest-key-ownership    modes: [standard-native, enterprise-native, mongodb-compat]    control: CMEK-if-approved    owner: security-platform    evidence: database-encryption-metadata + kms-audit    failure_test: local-key-unavailable-simulation    residual: authorized-read-still-plaintext-to-caller  - id: NET-02    threat: managed-service-data-exfiltration    modes: [trusted-backend]    control: VPC-Service-Controls + restricted-api-path    owner: cloud-platform    evidence: perimeter-policy + violation-log    residual: compromised-allowed-workload  - id: PRIV-04    threat: subject-data-persists-after-delete    modes: [all]    control: deletion-scope-inventory    owner: privacy-platform    evidence: deletion-state + downstream-job-results    residual: policy-approved-retained-backups

4. Evidence beats screenshots

Prefer machine-readable evidence that can be diffed and tested: database metadata, KMS key/active-version metadata, IAM policy snapshots, Rules test reports, index definitions, backup schedules, Cloud Storage lifecycle policy, service-perimeter configuration, log-sink/redaction tests, and deletion workflow state. A screenshot can supplement a review but is weak as the only control evidence because it is hard to reproduce and may omit context.

5. Safe failure injection library

Control Local simulation Optional real-project test
CMEK availability Guard file causes deterministic FAILED_PRECONDITION Disposable database/key only; never production key destruction
VPC/perimeter Policy evaluator rejects unapproved source/destination Dry-run perimeter + known test principal
Rules Emulator rules-unit tests Bounded production smoke test
PII logs CI scans emitted structured logs for forbidden fields/patterns Cloud Logging query on synthetic markers
Deletion completeness Synthetic multi-store scope registry Dedicated test subject across approved downstream systems
Recovery Two emulator namespaces + canonical hashes Isolated backup/PITR clone drill

6. Mandatory CI lab: fail when governance drifts

validate-governance.mjs
import fs from "node:fs";const matrix = JSON.parse(fs.readFileSync("governance/control-matrix.json","utf8"));const required = ["owner","evidence","test","modes","residualRisk"];const errors = [];for (const c of matrix.controls) {  for (const k of required) if (!c[k] || (Array.isArray(c[k]) && !c[k].length)) errors.push(`${c.id}:missing:${k}`);  if (c.claim === "network-replaces-iam") errors.push(`${c.id}:unsafe-claim`);  if (c.claim === "cmek-is-client-encryption") errors.push(`${c.id}:unsafe-claim`);}if (errors.length) { console.error(errors.join("\n")); process.exit(1); }console.log(`GOVERNANCE_MATRIX_OK controls=${matrix.controls.length}`);

Now inject a regression: remove owner from the deletion control, or set claim to network-replaces-iam. CI must fail. Repair the matrix and verify green state. The mechanism is the important part: governance changes become reviewable code rather than institutional memory.

7. AtlasMart control review checklist

  • Every protected dataset has an owner, location, classification, retention class, and deletion path.
  • Client and server authorization paths are separately modeled.
  • CMEK, if used, has service-agent IAM, rotation evidence, availability alerts, and a break-glass runbook.
  • Network controls have explicit ingress/egress paths and do not weaken IAM/application authorization.
  • Backup/restore/export/analytics copies appear in the data inventory.
  • Logs redact tokens/secrets/PII according to policy before emission.
  • Every critical control has a safe test and a known limitation of emulator/local simulation.
  • Mode/edition/API/launch-stage dependencies are stated.

Production judgment

A mature Firestore governance architecture is layered: authentication, authorization, key ownership, network egress control, location, logging, recovery, retention, and deletion each address different failure modes. More controls can also create new dependencies and operational failure modes. Add a control when it addresses a documented threat/requirement and you can operate, observe, and recover it.

8. Bridge to Chapter 24

Chapter 23 made controls explicit. Chapter 24 makes their operational health observable with Query Explain, Query Insights, Key Visualizer, metrics, logs, and troubleshooting. Governance without observability becomes stale; observability without governance becomes a pile of signals with no decision owner.

Knowledge check

  1. What extra fields should a control matrix have beyond “control enabled”?
  2. Why is edition/mode/interface scope required?
  3. What is a good local test for CMEK failure?
  4. Why are screenshots weak as sole control evidence?
  5. What should happen when a control introduces a new availability dependency?
Review the answers

1. Threat/requirement, asset, owner, evidence, test, response/recovery, cadence, scope, residual risk.

2. Firestore authorization, endpoints, query behavior, and network paths differ across interfaces.

3. Deterministically fail database operations behind a simulated key-availability guard; reserve real KMS failure for disposable controlled drills.

4. They are hard to reproduce/diff and may omit configuration context.

5. Add SLO/monitoring, safe failure test, break-glass owner, and recovery runbook.

Summary and next step

This lesson established the working contract for Build a Security/Governance Control Matrix Mapping Threats and Compliance Requirements to Firestore/Google Cloud Controls. Keep its edition/mode assumptions, trust boundary, verification evidence, and operational constraints explicit when reusing the pattern.

Next, continue to Query Explain: Plan/Execution Metrics, Index Entries Scanned, Documents Scanned, and Cost Diagnosis.

Authoritative references

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only Ethereum or ERC-20 compatible assets to this address.