dbt Model Security Review: A Boundary-First Checklist
A dbt model security review asks whether analytical SQL exposes more data, authority, or detail than the decision requires. The review follows the path from source columns through staging, joins, tests, materialization, warehouse grants, documentation, exposures, CI credentials, and readers. A model can be correct and still create risk by copying raw identifiers into a broadly accessible relation or joining two safe datasets into a sensitive population. Start with purpose, necessary fields, approved audience, and consequence so the review becomes a practical boundary check.
State the model's purpose and exposure boundary
Record source classification, model classification, intended audience, retention need, and acceptable use. A revenue model may need account and period but not a contact's personal email; a support model may need a case identifier but not a full customer profile. Review joins for accidental enrichment, especially when a stable identifier makes re-identification easy. Separate developer, CI, warehouse build, analyst, and application reader permissions. Microsoft governance guidance emphasizes content ownership, governance, security, and monitoring as adoption responsibilities; map those ideas onto the dbt project so a model has an accountable business owner and a technical steward. An exposure or dashboard dependency should be part of impact analysis, not an afterthought.
| Review area | Question | Evidence |
|---|---|---|
| Purpose | What decision and audience justify this model? | Owner, use case, permitted audience, and retention. |
| Fields | Which columns are required, sensitive, derived, or unnecessary? | Classification, minimization notes, and sample output. |
| Identity | Who builds, reads, administers, and approves changes? | Warehouse grants, CI role, and access review. |
| Change impact | Which sources, models, reports, or exports depend on it? | Lineage, exposures, tests, and release notes. |
Trace sensitive fields through joins and grants
Trace the model from source to published relation. Check whether a staging model preserves raw fields unnecessarily, whether joins change cardinality or population, whether incremental logic retains old sensitive records, and whether snapshots extend retention beyond the stated purpose. Materialization matters: a view may expose source permissions; a table may create a durable copy; an incremental model may preserve records after source deletion. Warehouse grants should be explicit and environment-specific. Do not assume that a model's schema name is a security boundary. Test an analyst, a dashboard service, a CI role, and an unauthorized role against the actual warehouse. The dbt exposure configuration helps connect published model consumers to ownership and review responsibility.

Check the project itself for leakage. Secrets should not appear in profiles, macros, logs, compiled SQL, artifacts, or pull-request examples. CI should authenticate through a scoped identity and build against representative fixtures where production data is unnecessary. A model security review also includes packages, macros, seeds, UDFs, external tables, and documentation examples. If the project serves a dashboard, use the analytics documentation guide to ensure field meaning, audience, and limitations are published with the asset. Documentation that explains a field is not a permission control, but missing documentation makes a permission mistake harder to detect.
Turn security assumptions into dbt checks
Data tests in dbt are SQL assertions that return failing rows; the official documentation lists reusable checks such as unique, not null, accepted values, and relationships, while also supporting custom assertions. Use them for security-relevant assumptions as well as data correctness. Test that a protected model does not contain forbidden fields, that classification columns are populated, that tenant or account keys are present, that joins preserve intended boundaries, and that row counts or exposure segments stay within expected ranges. A passing null test does not prove that access is correct, so combine model tests with warehouse permission tests and a release review. Store failure rows where responders can inspect them without broadly exposing the sensitive data being tested.
| Assumption | dbt or warehouse check | Release response |
|---|---|---|
| Protected field absent | Compile or query for prohibited columns and patterns. | Block build and remove or mask the field. |
| Tenant boundary holds | Test relationships, key presence, and cross-tenant joins. | Block publication and investigate population change. |
| Classification is complete | Assert accepted values and non-null policy metadata. | Quarantine model until owner resolves meaning. |
| Audience is limited | Run grants and row/column access tests as test roles. | Revoke broad access and document exception. |
Review release evidence with the data steward
A useful approval bundle includes model purpose, changed columns and joins, classification, materialization, grants, tests and failure handling, affected exposures, sample output, rollback or backfill plan, and named approvers. Review representative rows rather than only compiled SQL; a join can look reasonable while changing the population dramatically. Compare row counts, sensitive-field counts, null rates, and access behavior with the prior release. For an incremental model, decide whether historical rows need rewriting and whether a backfill could reveal protected data to a wider role. If the model is used in warehouse modeling decisions, include the warehouse owner in the review because physical design and grants can change exposure.
After release, monitor what the review cannot know in advance. Track access patterns, failed permission checks, unusual row or column growth, test failures, package changes, stale classifications, and model usage by audience. Review incidents with both analytics engineering and the business owner. If a field is never used, remove it; if a new use appears, update purpose and access before treating it as an informal exception. A security review should reduce unnecessary surface area over time, not merely approve more models. Retire tables, grants, exposures, and documentation when the model no longer supports a consequential decision.
Walk one model from source field to reader
A useful review is a short walkthrough rather than a large questionnaire. Choose one model with a sensitive or high-value output. Start at the source and list each field that enters staging, each join that changes the population, each macro or package that adds logic, the materialized relation, grants, tests, documentation, and downstream exposures. Ask a reader with the intended role to query the model and a reader without the role to attempt the same query. Compare the visible result, error message, and audit event. This catches the difference between a documented policy and an enforced policy.
Then change one assumption in a safe environment: remove a classification value, duplicate a key, add a prohibited field, or alter a tenant relationship. Confirm that the relevant test or release check fails with an actionable message. Inspect whether failures are stored in a location that itself widens exposure. Finally, record the approved boundary and the next review trigger, such as a new source, package, materialization, audience, or retention requirement. A repeated walkthrough builds a security muscle that scales better than an approval performed only by the original model author.
Related Edilec reading: data quality cost and scaling, data lineage architecture, and executive dashboard controls help connect model security to broader governance.
Source context: dbt data tests shows reusable assertions and failing-row inspection; dbt model contracts define expected columns and data types; dbt grants documents environment-specific privileges and revocation; and Snowflake access control provides a concrete role and object boundary to test.
Key takeaways
- Review purpose, population, fields, joins, materialization, grants, tests, and downstream use together.
- Minimize sensitive columns before publication; a correct model can still be overexposed.
- Use dbt data tests for semantic and boundary assumptions, then verify real warehouse access separately.
- Treat incremental models, snapshots, packages, macros, and CI artifacts as part of the security surface.
- Approve with evidence and revisit permissions, usage, and classifications after release.
Frequently asked questions
Can dbt tests prove a model is secure?
They can prove selected data and boundary assumptions, but not the entire access path. Pair tests for fields, keys, populations, and relationships with warehouse grants, role-based queries, CI identity review, and monitoring. Security is a property of the route from source to audience.
Is a view safer than a table?
Not automatically. A view can inherit broad source permissions and execute sensitive logic for every reader, while a table creates durable copies and retention obligations. Choose materialization with access, performance, freshness, audit, and deletion behavior in mind, then test the actual warehouse policy.
Who should approve a model security review?
The analytics engineer owns implementation evidence, the warehouse or platform owner validates technical controls, and a business or data steward accepts purpose and audience. Add privacy or security review for sensitive classifications or material risk.
Choose one model that contains a sensitive identifier or joins across trust zones. Record its approved audience, source columns, join keys, materialization, grants, packages, exposures, and deletion behavior. Compare a normal build with a branch that adds one field or changes one join. The reviewer should see which tests fail, which grants change, whether the output becomes a durable copy, and which steward must approve the altered purpose. This turns the review into a repeatable release decision rather than a search for suspicious SQL.
dbt Model Security Review: A Decision You Can Operate
A passing dbt build proves only the checks that were written. A defensible security review follows the data from source field to transformed relation, warehouse permission, documentation page, exposure, and eventual retirement. Pair schema, contract, uniqueness, and relationship tests with identity and access tests, then record the purpose and audience that make those controls meaningful.
Walk through a customer-support model that joins tickets, account attributes, and agent notes. Start by writing the approved use: supervisors need queue age and assignment load, not full contact details or private note text. Review the source columns, join keys, incremental filter, snapshot retention, packages, compiled SQL, and warehouse relation. Then test three roles against the real warehouse: the CI identity should build but not read published customer detail; the dashboard role should see the minimized fields; and an analyst without the approved purpose should receive a controlled denial. Add a model contract for the published columns and data types, a test that protected fields are absent, a relationship test for account boundaries, and a grant check in both development and production. Capture the failing rows and permission errors in a restricted location. The review is complete only when the evidence shows both that the model expresses the intended population and that the warehouse enforces the intended audience.
Revisit the review when materialization, joins, retention, or consumers change. The safest model is the one whose necessary fields, allowed readers, and correction path remain explainable as the analytical question evolves.