Chapter 22 · Security, Privacy, Row/Column Policies, Masking, and Least-Privilege Analytics

Secure Views/Semantic Layer Policies vs Physical Data Access and Avoiding Bypass Paths

Test effective access rather than intended dashboard policy: trace secure views to physical tables, detect direct raw/staging bypass paths, repair grants, and verify that the policy boundary survives alternate query routes.

Intermediate → Advanced145–180 minutesSecure-view bypass-path labRaw direct access ALLOW → DENYLast reviewed: September 2026

Learning outcomes

01

Distinguish policy intent in BI/semantic layers from effective access to underlying physical data.

02

Enumerate bypass paths through raw, staging, direct tables, exports, and delegated service identities.

03

Test allow/deny behavior with real named identities instead of trusting role diagrams.

04

Repair an over-broad physical grant without breaking certified consumer access.

05

Adopt defense-in-depth policy placement and evidence for future impact analysis.

Continuity and explicit security-layer addition

Chapter 22 begins from Chapter 21's certified warehouse/domain truth: 10 current paid lines, 8 orders, 12 units, 820 USD gross revenue, 495 USD cost, and 325 USD gross profit. The canonical fact grain remains one current paid order line. The governed metrics and conformed dimensions are not redefined. This chapter adds identity, authorization, privacy, copy-control, and audit mechanisms around those same assets. A security control that changes revenue merely because a different user queried it is a modeling bug unless the metric contract explicitly defines a security-scoped population.

Lab contract and limits

Runtime executed for this chapter: Python 3.13.5 and SQLite 3.46.1. Environment: local/in-process, synthetic, no-cost. Storage: one disposable SQLite file plus JSON evidence. Security engine: SQLite does not provide a warehouse-style role/RLS/CLS subsystem, so the lab implements a deterministic policy evaluator and secure-view simulation while keeping the policy semantics vendor-neutral; PostgreSQL/cloud-warehouse row policies are referenced only as product-specific examples. Token key: supplied at runtime through ATLASMART_TOKEN_KEY; no production secret is embedded in SQL or source. Time/currency: existing UTC and USD metric semantics remain unchanged. Privacy: all names/emails are synthetic. The erasure workflow is a technical teaching model, not legal advice or a universal retention rule.

1. The problem: a secure view is only as strong as the paths around it

AtlasMart's marketing view masks email and filters non-consented customers. Yet the initial marketing role can query prod.raw_customer directly. A bypass path is any alternate route that reaches more sensitive data than the intended policy surface permits. It can be a lower-level table, a staging schema, object storage, a notebook credential, a service account, a cached extract, or an old export.

The correct unit of analysis is therefore effective privilege over the full data path—not the dashboard screenshot.

2. Trace the policy path end to end

Threat path
CRM source  -> landing/raw customer copy [direct PII]  -> governed dim_customer [direct + pseudonymous fields]  -> secure_customer_view [consent row filter + masked columns]  -> semantic metric/data product  -> BI query/exportBYPASS TESTS  analyst -> raw_customer ?  analyst -> dim_customer SELECT_PII ?  BI exporter -> raw_customer ?  ETL service -> BI export ?  dev identity -> prod restricted object ?  restore -> erased subject PII ?

3. Controlled failure and repair

Effective privilege before/after
INITIAL FINDINGSshared credential: shared_analyst -> FAILmarketing_analyst SELECT prod.secure_customer_view -> ALLOWmarketing_analyst SELECT prod.raw_customer        -> ALLOW  <-- bypassservice svc_etl_prod INSERT prod.raw_customer     -> ALLOWservice svc_etl_prod ADMIN prod.security_catalog  -> DENYdev.dana SELECT_PII prod.dim_customer             -> DENY (environment isolation)AFTER REPAIRshared active credentials -> 0analytical raw-table bypass paths -> 0marketing_analyst SELECT prod.raw_customer -> DENYseparation-of-duties conflicts -> 0

Notice that the secure-view test succeeds both before and after repair. The difference is the lower-level grant. This is why a test suite must include negative tests against known sensitive resources.

4. Secure views and semantic policies still add value

A secure view can centralize a stable row/column contract and make ordinary analytical access safer. A semantic layer can add metric-aware policy and prevent dashboard-local logic. But neither is a universal security boundary when the same identity holds lower-level privileges. The warehouse/object-store identity layer must make those bypasses unavailable or explicitly justified.

5. Exports are new copies with their own boundary

Once a BI process writes a CSV, spreadsheet, extract, cache, or downstream table, live warehouse policy may no longer control it. The lab therefore represents prod.bi_export_masked in a copy registry and gives export write permission to a dedicated service identity, not to the ETL writer. Production designs should add destination permissions, retention, encryption, sharing restrictions, auditing, and revocation appropriate to the platform.

6. Raw and staging access deserve explicit tests

Teams often protect presentation marts while leaving landing/staging broadly readable “for debugging.” That defeats column masking and purpose limitation. Debug access should be time-bound, case-bound, and auditable where possible. The lab's bypass_findings() scans analytical/export roles for direct raw SELECT. A real environment should enumerate inherited roles, object-store permissions, temporary credentials, notebook/service-account delegation, and schema ownership.

Executed bypass scan idea
for role in ('marketing_analyst','finance_analyst','operations_analyst','bi_exporter'):    row=c.execute("SELECT effect FROM permission WHERE role=? AND resource='prod.raw_customer' AND action='SELECT'",(role,)).fetchone()    if row and row[0]=='ALLOW':        findings.append({'role':role,'resource':'prod.raw_customer'})

7. What about privileged administrators?

Masking often does not protect against highly privileged database owners or security administrators, depending on the engine. Do not promise that “masked” means nobody can recover the clear value. Separate security administration from routine data access where feasible, log privileged access, and document break-glass procedures. The local policy intentionally lets sara.security administer the security catalog without automatically granting PII reads.

8. Verification checklist

  1. Prove marketing can query the secure view.
  2. Demonstrate the initial raw bypass.
  3. Remove the raw grant.
  4. Prove secure-view access remains available.
  5. Prove direct raw access is now denied.
  6. Prove ETL cannot publish BI export and BI exporter cannot gain raw PII through an inherited role.
  7. Record every allow/deny result in the audit trail.

9. Production judgment

Put primary enforcement at a boundary consumers cannot bypass, then layer semantic/BI policy for usability and context. Test effective access after role/group changes, migrations, copied datasets, emergency grants, and new export pipelines. Security regressions are compatibility regressions: a deployment that preserves query results but opens a raw path is not a successful migration.

10. Bridge to Lesson 5

Lesson 5 combines identity, policy, privacy, copies, and restore behavior into a warehouse threat model and an operator acceptance report. The goal is not a one-time checklist; it is evidence that the deployed paths match the intended trust boundaries.

Knowledge check

Acceptance questions

  1. Why is a secure view not sufficient if raw is readable?
  2. Why is a BI export a new security object?
  3. Why must negative access tests use named identities?
  4. What should happen after a new emergency grant?
Review the answers

1. The user can avoid the view and retrieve more sensitive data directly.

2. It becomes a separate copy outside live query policy.

3. Effective permissions depend on actual group/role/environment context.

4. Re-run effective privilege/bypass tests and revoke or time-bound the grant.

Authoritative references

11. Lab cleanup/reset

Delete atlasmart_ch22_lab (or your configured disposable lab directory) and rerun ch22_lab.py with a synthetic ATLASMART_TOKEN_KEY. The lab modifies no repository, cloud, or production resource.

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.