Repository navigation
feat(minimal): support *_FILE variables for Docker/Kubernetes secrets - #179
Merged
Merged
Conversation
SimpleRisk 20261020-001 Release
Adds file_env to the minimal entrypoint so credentials (DB setup/app passwords, CSRF secret, mail and admin credentials) can be read from a file such as /run/secrets/<name> instead of the environment. Setting both VAR and VAR_FILE, or pointing at an unreadable file, is fatal. Refs #83 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…, SQL, PHP and sed Credential values were interpolated into a bash -c string (mysql setup/delete), a double-quoted PHP string (csrf-secret.php) and unescaped PHP single-quoted strings (config.php); sed_escape also broke on newlines. _FILE secrets from a secret manager commonly contain these characters. - run mysql via an argv array with the password in MYSQL_PWD, SQL on stdin, string values single-quoted and identifiers quoted with proper escaping - write csrf-secret.php and config.php defines as escaped PHP single-quoted strings - rewrite sed_escape with parameter expansion so newlines survive - pass the app DB password to apply_mail_setting via MYSQL_PWD, not argv - add test_escaping.sh and run it in container-validation Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… connection
apply_mail_setting passed --ssl-mode=DISABLED, so MySQL 8's caching_sha2_password
refused the app user's first login ("Authentication requires secure connection")
and every mail setting was skipped with only a warning. Use the client default
(PREFERRED), and escape values with sql_str_escape. Add a regression check.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts: # .github/workflows/container-validation.yml
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
Targets
testing(the RC branch; promotion tomasteris a separate step). Merged up to date withtestingafter #178 (APACHE_MAX_REQUEST_WORKERS); the only conflict was the workflow's test-step list, where all steps are kept.Addresses #83. Adds
file_envto thesimplerisk-minimalentrypoint: for each supported variable,VAR_FILE=/run/secrets/<name>loads the value from that file (trailing newline stripped), following the convention used by the official MySQL/MariaDB/WordPress images.DB_SETUP_USER/PASS,SIMPLERISK_DB_HOSTNAME/PORT/USERNAME/PASSWORD/DATABASE,SIMPLERISK_CSRF_SECRET,MAIL_USERNAME/PASSWORD,ADMIN_USERNAME/PASSWORDVARandVAR_FILE, or an unreadable_FILEpath, exits with a clear error_FILE-only setup still triggers config provisioning_FILEvars are unset after loading; README gets a "Secrets" section with a compose exampleHardening included (credential values with metacharacters)
Secrets from a secret manager commonly contain
",',\,$, backticks,&,|and newlines. Several existing sinks mishandled those, so they are fixed here:bash -cstring -> now an argv array (mysql_setup), password viaMYSQL_PWD, SQL on stdin with escaped string literals/identifiers.csrf-secret.phpwrote the secret into a double-quoted PHP string -> now an escaped single-quoted string. (A secret that relied on$/escape interpolation previously broke; it is now taken literally.)sed_escapebroke on newlines, andconfig.phpdefines did not escape'/\->config_definePHP-escapes then sed-escapes;sed_escapeuses parameter expansion.apply_mail_settingpassed the DB password on the command line (visible inps) ->MYSQL_PWD, and values are escaped withsql_str_escape.apply_mail_settingforced--ssl-mode=DISABLED, socaching_sha2_passwordrefused the app user's first login ("Authentication requires secure connection"). Reproduced on the published20261020-001image with plain passwords. It now uses the client default (PREFERRED, TLS when the server offers it).Verification
Built the image from this branch and ran it against
mysql:8.0with secrets mounted as files, using hostile values (e.g. app passworda"b$(touch /tmp/PWNED)c'd\e&f|g;h, DB usersr"user):DB_SETUP=automatic: schema loaded, app user created, 155 tables, admin user created fromADMIN_PASSWORD_FILE, HTTPS returns 200config.phpandcsrf-secret.phpevaluate in PHP back to the exact secret values; the app user logs in to MySQL with the hostile password/tmp/PWNED*absent in app and MySQL containers)DB_SETUP=deleteremoves the database and user; a hostile DB name (db"x'y) and user (u'"x) are created exactly_FILEvariables in its environment20261020-001now stores all four settings; with hostile secret files the storedphpmailer_password/phpmailer_usernamematch the files byte for byte (hex compared)test_file_env.sh,test_escaping.shand Add APACHE_MAX_REQUEST_WORKERS to simplerisk-minimal #178'stest_set_apache_workers.shpass in an image built from the merged tree (bash 5.2 / GNU sed); all run incontainer-validation; end-to-end scenarios re-run on the merged imageKnown limitations / out of scope
config.php(and the CSRF secret incsrf-secret.php); this keeps secrets out of the container environment and compose files, not off the container's disk.simpleriskimage is unchanged (it generates its own DB passwords).mysqlimage's own entrypoint cannot take a root password containing'or\; unrelated to this change.🤖 Generated with Claude Code