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. 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 --judge-allow-rows is passed.
Can a repo's contextlift.yaml run shell commands?No, not by default. runner.command and clarifier_cmd from config files are refused without --trust-config, and subprocess environments strip secrets unless forwarded with --pass-env.
Does serve-mcp open a network port?No. CertifiedContextMCPServer communicates strictly over local stdio JSON-RPC 2.0 with a 10 MiB payload ceiling.

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, and rejects non-SELECT statements, write keywords (including data-changing CTEs like WITH t AS (DELETE ...)), and exfiltration functions (EXTERNAL_QUERY, COPY, PUT, GET, CALL, Postgres query_to_xml/pg_ls_dir/pg_settings/SHOW ALL, Snowflake @stage/get_presigned_url, Databricks java_method/secret/text./binaryfile./ai_*, and DuckDB read_text/read_csv/read_parquet/read_blob/read_json). DuckDBExecutor connects read_only=True, sets disabled_filesystems='LocalFileSystem', and locks configuration. --db-role is enforced on Postgres (SET LOCAL ROLE) and Snowflake (role=) and fails closed on BigQuery and Databricks.
  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 HTTP 3xx redirects, cloud metadata (169.254.0.0/16, metadata.google.internal), IPv6 link-local (fe80::/10), 0.0.0.0, non-canonical IP literals, and non-loopback RFC1918 private IPs (including DNS-resolved private IPs) by default while allowing loopback (localhost, 127.0.0.1, ::1). Pass --allow-private-endpoint only for trusted internal VPC proxies. - Command runners (runners/command.py, backends.py): split argv with shlex.split, execute with shell=False, scrub API/cloud/signing env secrets via safe_subprocess_env() unless explicitly listed in --pass-env, and refuse commands loaded from contextlift.yaml unless --trust-config is passed. - LLM judge (judge.py): defaults to allow_rows=False; 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 survives.

Spend controls, attestations, and workspace hygiene

Limits. What this does not do

Appendix: Google Cloud Dataplex provenance and IAM

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.

IAM, per command (Google Cloud)

Derived from client calls. 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