contextlift

Security and data handling

Written for a security reviewer who has not read the source. Every claim names the function or constant that implements it, and tests/test_security_doc.py fails if any cited symbol stops existing.

Summary

QuestionAnswer
Does contextlift write to your warehouse?No. Every SQL statement runs through read_only_violation before execution across all executors.
Can predicted SQL read local files off disk?No. Filesystem reader functions are refused by name, and DuckDBExecutor enforces disabled_filesystems='LocalFileSystem' plus lock_configuration=true.
Does data leave your network?Only to the warehouse and model endpoint you configure. There is zero telemetry, analytics, or phone-home.
Does the optional LLM judge send raw result rows?No, not by default. judge.py sets allow_rows=False unless you opt in explicitly with --judge-allow-rows.
Where are artifacts stored?Locally under --workspace (with 0o600 permissions on caches and ledgers, plus --hash-only-cache to keep raw rows off disk).
What is written into Knowledge Catalog?Allowlisted hashes, timestamp, runner/model metadata, and gate outcomes only. No questions, SQL, or rows.
Does serve-mcp open a network port?No. CertifiedContextMCPServer communicates strictly over local stdio JSON-RPC 2.0.

Three data channels

  1. Your warehouse (executor.py). read_only_violation runs before every query in SQLiteExecutor, DuckDBExecutor, BigQueryExecutor, PostgresExecutor, SnowflakeExecutor, and DatabricksExecutor. It strips comments, masks string literals first (so semicolons inside quoted values do not false-trigger), and rejects anything other than a single SELECT or WITH statement, any write keyword (including inside data-changing CTEs like WITH t AS (DELETE ...)), and external escape functions (EXTERNAL_QUERY, COPY, PUT, GET, CALL, and DuckDB filesystem functions such as read_text, read_csv, read_parquet, read_blob, read_json). DuckDBExecutor additionally opens read_only=True, sets disabled_filesystems='LocalFileSystem', and locks configuration. Pass --db-role to enforce read-only role scoping (SET LOCAL ROLE on Postgres, role= on Snowflake, caller role metadata on Databricks and BigQuery).
  2. Your model service (runners/). Sends table/column descriptions, authored rules, terms, worked examples, joins, and question text (for Google Cloud Conversational Analytics, assembled by build_inline_context in runners/ca_api.py). - SSRF guard (_validate_base_url in runners/openai_compat.py): blocks cloud metadata (169.254.0.0/16, metadata.google.internal), IPv6 link-local (fe80::/10), 0.0.0.0, and non-loopback RFC1918 private IPs by default while allowing loopback (localhost, 127.0.0.1, ::1) for local Ollama/vLLM. Pass --allow-private-endpoint only for trusted internal VPC proxies. - Command runners (backends.py): --backend command / --runner command splits argv with shlex.split and invokes subprocess.run(..., shell=False) (never shell=True). - LLM judge (judge.py): defaults to allow_rows=False (sending only SQL, row counts, and column types/names). Raw sample rows are sent only with --judge-allow-rows.
  3. Explicit export (contextlift share). Allowlist-first export in share.py followed by Unicode NFC case-folded leak scanning (find_leaks) that refuses the export if any customer identifier appears.

Spend controls and confirmation gates

Knowledge Catalog provenance allowlist (provenance.py)

When running contextlift catalog-push, the provenance aspect is readable by any catalogViewer and by agents through MCP. Every field written by Provenance today:

arm_control_hash, arm_treatment_hash, gates, k_repeats, measured_at, model_alias, overview_hash, queries_hash, round_id, runner, served_state.

Three controls bound that payload:

Workspace hygiene, PII redaction, and secret scanning

Limits. What this does not do

IAM, per command (Google Cloud)

Derived from the client calls each command makes. Not yet verified against a live estate for every row: rows marked verified ran on a real project; rows marked derived come from code inspection. Run contextlift doctor --explain to decode live refusals (including VPC Service Controls perimeter blocks).

CommandRequired rolesStatus
demo, doctorNoneverified
gate, score, round on bq://roles/bigquery.jobUser (billing), roles/bigquery.dataViewer (datasets)verified
logroles/bigquery.resourceViewerverified
round (ca-api)roles/geminidataanalytics.dataAgentUser + BigQuery roles aboveverified
catalog-pull, catalog-listroles/dataplex.catalogViewerverified
catalog-push, catalog-rollbackroles/dataplex.catalogEditor, roles/dataplex.aspectTypeOwner (once)derived
sentinelcatalog-push + ca-api rolesderived
eval-roomroles/bigquery.dataEditor on the evaluation project onlyderived