[Bug] Docker entrypoint auth bootstrap is unsafe for mounted and upgraded configs
Problem
The Docker entrypoint bootstraps authentication with grep/sed against
conf/rest-server.properties. That works for the shipped defaults it was
written for, but not for mounted configs, upgraded volumes, or any value whose
encoding differs between shell and HugeConfig.
Concrete cases, most of them raised during review of #3119:
- Gremlin and REST can end up on different auth providers. The check is a
presence-only
grepforauth.authenticator, so a config that already has the REST property but not the Gremlin side is treated as fully configured. - A pre-existing authenticated volume can fail its first startup after
upgrade. A legacy volume can carry
docker/init_completewhile the bootstrap state the entrypoint now expects is absent. PASSWORDis observable. It is currently handed to Java as a command-line argument, which puts it inpsoutput for every process in the container.sedrewriting does not implement the Java properties grammar. Escaped keys,:and whitespace separators, continuations, and duplicate logical definitions are all read differently byHugeConfigthan by the entrypoint. Concretely,set_propdetects onlykey=, so a mounted config using:gets a second logical definition appended andHugeConfigthen rejects the file as a list. This affectsbackendandpd.peersas well asinit_store.enabled, so the fix should cover all of them together.PASSWORDsilently does nothing when init-store is skipped.init-storereads it from stdin, and the disabled path returns before that, so the admin is created on the PD startup path fromauth.admin_pa— public defaultpa. #3119 documents this and warns at runtime; it does not fix it.
The first case, as it stands on master 98477f0f5: the entrypoint no longer
greps for auth.authenticator itself, it calls bin/enable-auth.sh whenever
PASSWORD is set, and that script gates only on whether conf-bak/ exists.
On a config it did not write, it appends a second definition to both files,
and the two parsers disagree about which one wins.
Proposal
Move property reading and writing off grep/sed and onto the same
Commons Configuration path HugeConfig uses, so both sides agree on encoding,
and let the entrypoint delegate auth classification to it.
Rough shape:
- a small
ConfigToolCLI for typed get/set against a properties file, preserving comments, file mode, and inode for mounted configs; - entrypoint uses it instead of
grep/sed, and stops passing secrets as process arguments; - auth bootstrap becomes explicit about mounted, upgraded, and custom authenticator cases rather than inferring from one key's presence;
- a shell test suite covering the entrypoint contract, wired into
docker-build-ci.yml.
Scope
In scope: docker-entrypoint.sh, the new config CLI and its wrapper, the
entrypoint test suite, and the workflow path filters that run it.
Out of scope: the init_store.enabled option and its gate (#3118 / #3119),
Helm chart structure, and GraphManager behavior.
Context
This work originally shared a branch with #3119. That made a ~2,900-line diff covering two unrelated ideas, so it was split out to keep each reviewable on its own. #3119 now carries only the option, the gate, the env mapping, and the init-flag guard.
Visual summary
Hi! bitflicker64 suggested this one in #3188 as still unclaimed — I'd like to take it. Could a maintainer assign it to me? My plan is to reproduce the breakage with a mounted rest-server.properties and an upgraded config (the concrete cases listed in the issue), make the entrypoint's auth bootstrap idempotent and non-destructive (match exact keys, quote values, avoid rewriting user-provided files in place), and add CI coverage for mounted-config and upgrade paths. Thanks!
Go ahead, it is yours as far as I am concerned. I opened this one but I am not a committer here, so I cannot set the assignee; a maintainer will have to do that.
Worth knowing before you start: #3119 landed after this was filed and fixed a
good part of it. On master 98477f0f5:
- The
:and whitespace separator case is done.set_prophandles both separators now and collapses duplicate definitions, and CI covers it indocker/test/test-docker-entrypoint.sh. PASSWORDreachesinit-storeon stdin, not as a process argument.PASSWORDno longer no-ops when init-store is disabled, andenable-auth.shruns outside the init-flag guard, so the upgraded-volume case is covered.
What is still open:
- The Gremlin/REST split, though the mechanism moved. See the diagram I just
added to the description:
enable-auth.shappends a second definition to a config it did not write, commons-configuration2 2.8.0 takes the first of the duplicate pair and snakeyaml 2.2 takes the last, so the two sides land on different authenticators with no error from either. - Escaped keys and continuation lines still confuse
set_prop. A mountedauth\.admin_pa=paplus the appendedauth.admin_pa=<password>is two definitions of one key, andgetStringreturnspa, so the env var is silently dropped. Apd.peersvalue continued onto a second line leaves the continuation behind as a stray property. set_propinterpolates the value into thesedcommand, so when the key already exists the password ends up in sed's argv and is visible inps. The shipped conf hasauth.admin_pacommented out, so a default first boot takes the append branch and is clean; a mounted or persisted conf hits it.
Your plan lines up with the parts that are left. I would reproduce against master first so you are not fixing the ones that are already gone.
@imbajin — @bitflicker64 has confirmed this issue is mine to work on (see above), but as he's not a committer he can't set the assignee field. Could you please assign this to me? FYI, my plan is to reproduce the remaining cases against current master first (per the updated description diagram): the Gremlin/REST authenticator split via the commons-configuration2 first-definition vs snakeyaml last-definition mismatch, then the escaped-key/continuation handling in set_prop, and the password-in-sed-argv visibility when the key already exists.
@imbajin — @bitflicker64 has confirmed this issue is mine to work on (see above), but as he's not a committer he can't set the assignee field.
Feel free to continue working on it; you don’t need to be assigned to an issue, to be honest
Opened PR #3192 with the fixes for the parts still open on master:
- Gremlin/REST authenticator split — enable-auth.sh appends are now guarded per file (only an absent or commented-out definition triggers an append), re-runs are idempotent, and the entrypoint aligns both sides first: a yaml authenticator is propagated into rest-server.properties and vice versa, so the default StandardAuthenticator can no longer split the pair. Genuine mismatches get a loud WARN instead of silent divergence.
- Escaped keys and continuations — property rewriting moved to props.awk, which implements the java.util.Properties line grammar (escapes, ':'/whitespace separators, continuations, first-definition-wins duplicates) and rewrites the first definition in place, so mounted configs like one carrying
auth\.admin_pa=pano longer grow duplicate definitions that HugeConfig resolves topa. - PASSWORD in
ps— the value no longer interpolates into a sed command line; it travels via environment variable into awk, so argv stays clean.
Both test suites pass locally (the extended unit suite and the full entrypoint harness, including the complex-secret round-trips). @bitflicker64 your updated diagram and 'what is still open' list were exactly the roadmap — I followed the reproduce-on-master-first advice and skipped what #3119 already fixed. @imbajin could you take a look when you get a chance?
@imbajin @bitflicker64 #3133 has no assignee while #3192 (the fix for it) is 37 days old and actively reviewed here. Could one of you assign #3133 to me, so it is clear the work is taken? Happy to also fold in whatever you want from the tracker on that issue.
15. @imbajin @bitflicker64 #3133 has no assignee while #3192 (the fix for it) is 37 days old and actively reviewed here. Could one of you assign #3133 to me, so it is clear the work is taken? Happy to also fold in whatever you want from the tracker on that issue.
Don't worry about assigning; as you can see, other issues and PRs have no one assigned, which is the norm.