Repository navigation
fix: Keep Secrets-Manager users and bootstrap credentials away from SQL templates (#254) - #260
Merged
Merged
Conversation
- Fake Secrets Manager (GetSecretValue, AWS JSON 1.1) reached through AWS_ENDPOINT_URL_SECRETS_MANAGER / AWS_ENDPOINT_URL - Basic auth against a fetched user; templates must not read the user table or list the bootstrap DuckDB secret - An apostrophe in secret-key must not break startup; secret-key and secret-id must not appear in the debug log - Regression guard: remote-config credentials reach templates only as the redacted zz_flapi_s3 secret
…rets-Manager auth (#254) - The fake Secrets Manager verifies the AWS SigV4 signature against the secret key it knows, so tests assert which credentials signed the call, for which region, and that no session token was sent - Endpoint precedence: AWS_ENDPOINT_URL_SECRETS_MANAGER over AWS_ENDPOINT_URL; AWS_IGNORE_CONFIGURED_ENDPOINT_URLS=true uses neither - A running server at debug level logs neither key, also with an apostrophe - Roles from the secret give 403/200; a PBKDF2 password verifies - One secret shared by two endpoints and the top-level auth: one fetch - Custom init: still authenticates, its secret is not visible to templates - The schema API does not list the user table - No keys configured: the SDK credential chain (environment) signs
…t overrides (#254) - A key the DuckDB secret lacks read back as the string "NULL": every request carried X-Amz-Security-Token: NULL and AWS rejected it, and an omitted region became the region "NULL". Missing keys are now empty - Region: the configured one, else AWS_REGION, else AWS_DEFAULT_REGION, else a startup error naming the key - AWS_ENDPOINT_URL_SECRETS_MANAGER, else AWS_ENDPOINT_URL, becomes the client's endpointOverride unless AWS_IGNORE_CONFIGURED_ENDPOINT_URLS is true; the SDK for C++ does not read them itself - The client no longer probes instance metadata for a region
…ate database (#254) - secret-id/secret-key go straight to the AWS SDK; with neither, the SDK's default credential chain. No DuckDB secret and no SQL, so a key with an apostrophe works and httpfs is not needed - A legacy init: runs in a private DuckDB (persistent secrets off); the main database's secret of that name is a deprecated fallback with a warning - The fetched user list is parsed once into memory, keyed by secret-name, instead of a table every SQL template and the schema API could read; secret-table is accepted and ignored with a warning - Each secret is fetched once, however many endpoints share it; the top-level auth: now parses from-aws-secretmanager too - Aws::InitAPI runs once per process - Init SQL is never logged: the Init: debug line is gone, and executeInitStatement errors name the statement position and a redacted DuckDB error instead of the statement - secret-id and secret-key must be set together - OpenPrivateDuckDb generalises the bootstrap DuckDB opener
…oint, rotation (#254) - Authentication guide: the {"auth":[{username,password,roles}]} secret format, credential precedence, endpoint override variables, fetch-once and restart-to-rotate - CONFIG_REFERENCE 7.5: secret-table ignored, init legacy, region fallback; 2.4: persistent DuckDB secrets are visible to templates unless duckdb.allow_persistent_secrets is false - security.md: where the users and credentials live, logging redaction - flapi-auth skill teaches the new behaviour; secret-table is a forbidden term unless described as having no effect - CHANGELOG Unreleased: Security and Fixed entries, behaviour changes
- Old auth_<name> / secret-table tables on a file db_path are dropped - Only AWS_ENDPOINT_URL_SECRETS_MANAGER redirects; plain http off loopback is refused; an active override is warned about - An unknown user takes as long as a wrong password - Two blocks sharing a secret-name must agree - AWS error messages are logged short with key ids masked - A bearer block with a leftover from-aws-secretmanager does not fetch - The region can come from the AWS profile - Connection init literals are not returned by the project config APIs - SQL error redaction: PEG tokens, prose apostrophes, DSNs, URLs - Guards: top-level-only inheritance, malformed secret, init without a secret, clean exit after SIGTERM, legacy CREDENTIAL_CHAIN init
- Drop auth_<name> and secret-table tables older versions left in the main database (a file db_path kept them readable), with a warning - Only AWS_ENDPOINT_URL_SECRETS_MANAGER overrides the endpoint; plain http off loopback is refused unless FLAPI_ALLOW_INSECURE_SECRETS_ENDPOINT is set; an active override is logged as a warning - redactSqlErrorMessage takes the statement and replaces its literals, quoted identifiers and dollar bodies wherever the error repeats them, the token after "at or near", connection-string secrets and URL credentials; apostrophes in the message are no longer literals - Connection init is returned with its literals redacted by /config, /api/v1/_config/project and flapi_get_project_config - An unknown username is checked against a dummy hash shaped like the stored ones (inline users too); plaintext and MD5 compare in constant time over SHA-256 digests - Blocks sharing a secret-name must agree on region, credentials and init; only enabled basic blocks fetch - Region falls back to the AWS profile's region - AWS error messages are logged short, key ids and long runs masked - A legacy init that uses CREDENTIAL_CHAIN loads the aws extension - authenticateAwsSecrets catches exceptions again (401, not a throw) - AuthSignature keeps digests of secret-key and init, not the key
- Only AWS_ENDPOINT_URL_SECRETS_MANAGER overrides the endpoint; plain http needs loopback or FLAPI_ALLOW_INSECURE_SECRETS_ENDPOINT; both env vars in the reference tables - Old auth tables are dropped at startup: rotate passwords if a file db_path was in use - Region from the AWS profile; basic-only; blocks sharing a secret must agree; init has no side effects on the main database - security.md: the default chain reads ~/.aws/config, credential_process included; timing, redaction and upgrade notes - CHANGELOG: malformed secret, init without a secret, SDK chain, basic only, project-config init redaction, username timing
jrosskopf
force-pushed
the
fix/gh-254-bootstrap-secrets
branch
from
November 24, 2026 14:15
a72a77a to
24e76f8
Compare
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
auth.from-aws-secretmanagerexposed the fetched user list (passwords, roles) as a main-DB table that any template couldSELECT. Its bootstrap S3 secret sat induckdb_secrets(), and the init SQL holding the AWS key was built unescaped and logged. Changes:secret-id/secret-keyuse a simple provider; with neither, the SDK default chain. No DuckDB secret and no SQL. A legacy custominit:runs in a private DuckDB, with a deprecated main-DB fallback.auth_<name>tables left in a persistentdb_pathare dropped at startup with a warning."NULL", so real AWS rejected the request. The region now comes from config, thenAWS_REGION/AWS_DEFAULT_REGION, then the SDK profile.AWS_ENDPOINT_URL_SECRETS_MANAGER. The genericAWS_ENDPOINT_URL, often MinIO, is ignored.http://is refused unless loopback orFLAPI_ALLOW_INSECURE_SECRETS_ENDPOINT=1, and a WARNING says the endpoint decides who can log in./api/v1/_config/projectreturns connectioninitwith literals redacted.type: basic.db_path.Red / green
test_auth_secretsmanager.pywith a fake Secrets Manager that verifies SigV4 (checked against AWS'sget-vanillavector).NULLtoken)./peek-usersreturnsPWCANARY123,duckdb_secrets()listsflapi_users, the init SQL is logged).CREDENTIAL_CHAIN, which needs theawsextension), twice.flapi_testspassed (1015 before the review round). Auth, config-service and remote-template integration files pass (list in the session notes).check_skills --static-onlypasses.flapi_testswas cut off by host memory pressure, unrelated to this PR. CI is the gate for those.Follow-ups
DatabaseManager::executeQuerydoes not bind a{"1":..}positional map (getTableColumns). To be checked separately.Closes #254
🤖 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.