Repository navigation
feat: Restrict DuckDB external access for remote configs (#253) - #261
Merged
Merged
Conversation
- New test/integration/test_external_access.py: a local server with `duckdb-hardening.external-access: restricted` must refuse /etc/passwd, an http URL, another bucket, ATTACH outside the allowed dirs, LOAD of a non-preloaded extension and INSTALL from a foreign repository, while the own CSV, a DuckLake cache refresh and an MCP tools/call keep working - A remote (s3://) config with no block defaults to restricted; with `external-access: full` local files are readable again - `allowed-directories` opens exactly the listed prefix - Local configs without the block keep full access (no-regression guard) - Startup logs `external access: restricted` / `external access: full` - Failure messages separate "SERVER DID NOT START" from "NOT REFUSED"
- Match a refusal on the log lines of that request only (request_id from the 500 body)
- Give the module fixture its own FakeS3 subclass and honeypot; FakeS3 records per class
- Pin the policy line exactly once
- Add traversal (.., %2e%2e) and prefix-boundary escapes, the configuration lock
(secret_directory, enable_external_access, allowed_directories, http_proxy), COPY TO
outside, glob('/etc/*'), INSTALL FROM core / LOAD refused by flAPI, a CREATE SECRET
ENDPOINT redirect, reload of a remote endpoint, cache gc/compact, template.path in
another bucket and a restricted packed bundle reading embed://
- A DuckDB error spans lines and the request_id lands on the record's last line: group the log into records before matching - ATTACH (TYPE sqlite) outside the allowed directories and ATTACH (TYPE postgres) to a honeypot must be refused
- New top-level duckdb-hardening block: external-access auto|full|restricted, allowed-directories, allowed-paths; auto = restricted for a remote config - DatabaseManager::applyExternalAccessPolicy runs last in startup: preloads httpfs, ducklake, azure and init-loaded extensions, turns autoinstall off, sets allowed_directories/allowed_paths, enable_external_access=false, then lock_configuration with allowed_configs = what flAPI SETs per connection - Templates may not INSTALL/LOAD or CREATE/DROP SECRET while restricted (refused at render, before DuckDB sees them): a temporary secret is instance-wide and redirected every read of the allowed bucket, flAPI's own config reads included - LoadOrInstallExtension and query errors explain a refusal by the hardening - The policy is logged once: external access: restricted (...) / full (...)
#253) - CONFIG_REFERENCE 2.4.1: keys, what restricted does in order, the policy line, limits - security.md and DESIGN_DECISIONS 14: why it runs last, preloads, locks the configuration, refuses INSTALL/LOAD and secret DDL, and why allowed directories are writable (known limit) and the extension directory is not allowed - cloud-storage guide, flapi-setup and flapi-deploy skills, CHANGELOG Unreleased with an upgrade note for remote configs that read other buckets or local paths
- node["allowed-directories"] / node["allowed-paths"] literally, so the readers are greppable and check_skills sees the keys
…ow list (#253) - RefusedTemplateStatement: LOAD/INSTALL/FORCE INSTALL/UPDATE EXTENSIONS/secret DDL, keywords as identifiers pass, unparsable SQL with LOAD fails closed - duckdb-hardening parsing: defaults, absolute entries, URLs kept, bad mode/key - ComputeExternalAccessAllowList: config dir, templates, DuckLake data path, embed:// only in a bundle, never the extension directory
- DatabaseManager::ComputeExternalAccessPreload, unchanged behaviour, so a unit test can check what is preloaded
- Statements outside a template allowlist refused by flAPI: EXPLAIN ANALYZE of INSTALL/LOAD/CREATE SECRET/DROP SECRET, PREPARE of secret DDL, PRAGMA and IMPORT/EXPORT DATABASE, ATTACH/DETACH, COPY FROM DATABASE, SET/RESET GLOBAL and a bare SET of a global-default setting; what templates use keeps running - The IMPORT DATABASE chain: COPY a schema.sql into an allowed dir, import it - HTTPS under restricted with a CA bundle outside the allowed dirs (local TLS server) - A persistent secret in duckdb.secret_directory serving reads under restricted - flapi cache refresh (one-shot) applies the policy to a remote config - C++: LoadOrInstallExtension decides per connection; preload covers aws for credential_chain and azure in connection properties; CA bundle and file:// in the allow list
…#253) - Every rendered template is parsed and each statement must be of an allowed type, recursing into EXPLAIN and PREPARE: EXPLAIN ANALYZE CREATE/DROP SECRET and INSTALL walked past the keyword-gated denylist. PRAGMA (IMPORT DATABASE runs a planted schema.sql), EXPORT, ATTACH/DETACH, COPY FROM DATABASE, secret DDL, extension statements and SET/RESET GLOBAL (or a bare SET resolving to global) are refused; approved SQL is remembered (bounded) so a stable template is parsed once - Load persistent secrets before external access goes off; allow the CA bundle httpfs uses (system bundles, SSL_CERT_FILE, ca_cert_file) so https works - Preload aws for from-aws-secretmanager or credential_chain; azure detection matches main() (connection properties, metadata path) - LoadOrInstallExtension asks the connection whether external access is on, so an unrestricted DuckDB (the bootstrap) gets DuckDB's own answer; hints name the defaults duckdb.default-extensions replaces - Allow the DuckLake data path stored in the catalog; strip file:// from entries - flapi cache refresh configures cloud credentials and applies the policy - A policy failure shuts the database down and logs once, redacted
…imits (#253) - CONFIG_REFERENCE 2.4.1: the allowlist, persistent secrets, CA bundles, the one-shot, default-extensions replacing the defaults, extensions only templates use - Limits: flapi.yaml and the CA bundle are writable when allowed, redirects are not re-checked, includes outside the prefix fail on a hot reload - security.md, DESIGN_DECISIONS 14, CHANGELOG and the flapi-setup skill follow
…#253) - After #254, Secrets Manager auth never uses the main DuckDB: the AWS SDK fetches the users and a legacy init runs in a private DuckDB, so preloading aws and the init's extensions into the main database only downloaded extensions templates never needed - Connection inits with CREDENTIAL_CHAIN still preload aws
, #253) - With log-http-requests on and restricted, a template's HTTP read is logged, and CALL disable_logging() and SET redact_http_logs are refused by the locked configuration - OBSERVABILITY.md and the observability spec say so
…restricted (#253) - Red: the init's private DuckDB has full file and network access under restricted
…ricted (#253) - An endpoint YAML's auth.from-aws-secretmanager.init ran with full file and network access after the policy; for a remote config that YAML is in the untrusted bucket. Under restricted its private DuckDB now has external access off and a locked config - flapi cache refresh redacts URLs in a failed policy's error, as the server does - CONFIG_REFERENCE no longer says aws is preloaded for Secrets-Manager auth
jrosskopf
force-pushed
the
feat/gh-253-external-access
branch
from
November 24, 2026 18:04
eb79a68 to
6c2fbd0
Compare
jrosskopf
marked this pull request as ready for review
November 24, 2026 18:04
Contributor
Author
|
Rebased onto main with #254 (#260) and #252 (#258). Cross-PR changes:
🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New top-level block:
When restricted,
DatabaseManager::applyExternalAccessPolicy()runs at the end of startup and:allowed_directories/allowed_paths(config prefix, template path, DuckLake data-path,embed://when bundled, the user's lists);enable_external_access=false;lock_configuration=truewithallowed_configslimited to what flAPI SETs per session.flAPI also refuses INSTALL/LOAD/secret DDL in templates while restricted. A template's
CREATE SECRET (ENDPOINT …, SCOPE 's3://mybucket/')redirected both data reads and flAPI's own template reads to a host of the template's choosing; that is verified on main with a honeypot. Local configs keep full access by default, so they see no change.Draft: merges after #256, #258 and the #254 PR, then gets a cross-PR review against them.
Red / green
/etc/passwd, URLs, other buckets,..traversal,mybucket-evil, ATTACH, COPY TO, LOAD/INSTALL, SET bypasses, the CREATE SECRET redirect, missing policy line).test_external_access.py35 passed; C++[external_access]9 cases.test_remote_templates_s3(12) andtest_remote_templates(37)check_skills --static-onlyKnown limits (documented in security.md / DESIGN_DECISIONS §14)
flapi.yamlchooses the mode. There is no floor the config cannot lower yet (follow-up).init,duckdb:settings and a Secrets-Managerinitrun unrestricted at startup.Closes #253
🤖 Generated with Claude Code
https://claude.ai/code/session_018txuxF9jXyiKakpUoXrKBi
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.