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
| Question | Answer |
|---|---|
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
- Your warehouse (
executor.py).read_only_violationruns before every query inSQLiteExecutor,DuckDBExecutor,BigQueryExecutor,PostgresExecutor,SnowflakeExecutor, andDatabricksExecutor. It strips comments, masks string literals first, and rejects non-SELECT statements, write keywords (including data-changing CTEs likeWITH t AS (DELETE ...)), and exfiltration functions (EXTERNAL_QUERY,COPY,PUT,GET,CALL, Postgresquery_to_xml/pg_ls_dir/pg_settings/SHOW ALL, Snowflake@stage/get_presigned_url, Databricksjava_method/secret/text./binaryfile./ai_*, and DuckDBread_text/read_csv/read_parquet/read_blob/read_json).DuckDBExecutorconnectsread_only=True, setsdisabled_filesystems='LocalFileSystem', and locks configuration.--db-roleis enforced on Postgres (SET LOCAL ROLE) and Snowflake (role=) and fails closed on BigQuery and Databricks. - Your model service (
runners/). Sends table/column descriptions, authored rules, terms, worked examples, joins, and question text (for Google Cloud Conversational Analytics, assembled bybuild_inline_contextinrunners/ca_api.py). - SSRF guard (_validate_base_urlinrunners/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-endpointonly for trusted internal VPC proxies. - Command runners (runners/command.py,backends.py): split argv withshlex.split, execute withshell=False, scrub API/cloud/signing env secrets viasafe_subprocess_env()unless explicitly listed in--pass-env, and refuse commands loaded fromcontextlift.yamlunless--trust-configis passed. - LLM judge (judge.py): defaults toallow_rows=False; raw sample rows are sent only with--judge-allow-rows. - Explicit export (
contextlift share). Allowlist-first export inshare.pyfollowed by Unicode NFC case-folded leak scanning (find_leaks) that refuses the export if any customer identifier survives.
Spend controls, attestations, and workspace hygiene
- Forbidden projects:
CONTEXTLIFT_FORBIDDEN_PROJECTS(checked byrefuse_forbidden_projectinbackends.py) blocks billing against matching project prefixes before any call runs. - Interactive confirmation:
confirm_paidandconfirm_holdout_read(confirm.py) prompt viaask_ttydirectly on/dev/ttyso piped stdin cannot approve paid runs or second holdout reads. Zero, negative,NaN, and infinite--budgetvalues are refused. Non-interactive CI can useCONTEXTLIFT_APPROVAL_SECRET(HMAC-SHA256) orCONTEXTLIFT_APPROVAL_EXPECTED+CONTEXTLIFT_APPROVAL_TOKEN. - Fail-closed attestations (
attest.py,mcp_server.py,compiler.py):attestation.jsonprovides deterministic hash chaining and symmetric HMAC-SHA256 integrity seals (not asymmetric PKI). Verification fails closed when a key is configured for an unsigned file or missing for a signed file; certification (certified: true) requires a verified HMAC signature, unmodifiedspec/,REAL GAIN, and passingpolicy:. - Workspace hygiene:
protect_runs_from_git(workspace.py) writes*toruns/.gitignore; fresh workspaces receiveWORKSPACE_GITIGNORE, andgit_exposure_warningwarns when an existing repo.gitignoreleavesindex.jsonorcontextlift.jsonexposed. Caches and the atomicfcntl.flockholdout_ledger.jsonare written0o600;--hash-only-cachehashes both SQL keys and result rows. - PII redaction, CSV safety, secret scan, static HTML:
ingest-failuresand Steward preview rendering scrub emails, SSNs, phones, Luhn-valid cards, JWTs, and bearer/API tokens; CSV exports apply NFKC-awarecsv_safe_cell;contextlift scan(secret_scan.py, using NUL-delimitedgit ls-files -z) scans with built-in secret patterns by default even without a custom pattern file;verdict.html(bundle.py) contains zero<script>tags and zero inline event handlers (onclick,javascript:,onerror,onload); Steward--import-decisionsrefuses rows whosegold_sqlSHA-256 changed since approval.
Limits. What this does not do
- It does not sandbox the model service. Table names, column descriptions, rules, and questions reach the model endpoint you configure; evaluating an agent requires talking to it.
- It does not encrypt the workspace at rest. It applies
0o600permissions and offers--hash-only-cache, relying on your OS disk encryption beyond that. /dev/ttydoes not stop a local process that can allocate a PTY. It stops piped stdin and non-PTY subshells, but a local agent allowed to spawn a PTY can writeRUN. Enforce hard limits with--budget,CONTEXTLIFT_APPROVAL_SECRET, and cloud billing quotas.--yesis a real bypass. It requires a positive finite--budgetand is recorded aswaivedwith argv in the manifest, and it remains a bypass unlessCONTEXTLIFT_APPROVAL_SECRETis configured.- The read-only rail is a text check, not a database privilege. Pair
read_only_violationwith a least-privilege read-only--db-roleand database user. - Beta cloud connectors (
PostgresExecutor,SnowflakeExecutor,DatabricksExecutor). Verified offline with fail-closed SQL rails and mocked drivers; pair with a read-only database role in production. - No third-party audit. Nobody outside this project has completed an independent formal security audit.
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.
ALLOWED_KEYSallows exactly19keys and drops anything else, including reserved future keystable_lift_pp,table_ci_low_pp,table_ci_high_pp,regressions,recall_misses,terms_hash,question_set_hash, andschema_hash.MAX_STRINGis80characters;check_payloadrecursively refuses oversized values rather than truncating.
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).
| Command | Required roles | Status |
|---|---|---|
demo, doctor | None | verified |
gate, score, round on bq:// | roles/bigquery.jobUser (billing), roles/bigquery.dataViewer (datasets) | verified |
log | roles/bigquery.resourceViewer | verified |
round (ca-api) | roles/geminidataanalytics.dataAgentUser + BigQuery roles above | verified |
catalog-pull, catalog-list | roles/dataplex.catalogViewer | verified |
catalog-push, catalog-rollback | roles/dataplex.catalogEditor, roles/dataplex.aspectTypeOwner (once) | derived |
sentinel | catalog-push + ca-api roles | derived |
eval-room | roles/bigquery.dataEditor on the evaluation project only | derived |