Repository navigation
fix(security): keep the MID password out of argv in get_mid_url.sh - #2
Merged
Merged
Conversation
The script promised credentials never reach argv, but offered --password, which puts the password in ps(1) output and shell history. --password is now refused with a pointer to MID_INSTANCE_PASSWORD (environment first, then the env file). Same script, same review: - escape \ and " for curl's --config syntax and refuse line breaks, so a password cannot break the quoting or inject config lines - strip one pair of surrounding quotes instead of every quote; accept `export KEY=`; drop a trailing comment on unquoted values - fail with a message when an option has no value - a non-JSON response (hibernating PDI, login page) gives a clear error, not a traceback; null property values are tolerated - restrict the instance-supplied buildstamp to [A-Za-z0-9._-] before it becomes a URL tests/get_mid_url_test.sh covers all of these with a stubbed curl. Co-Authored-By: Claude <noreply@anthropic.com>
…ehaviour Co-Authored-By: Claude <noreply@anthropic.com>
Read-only token; checkout pinned to v7.0.1 by SHA. Co-Authored-By: Claude <noreply@anthropic.com>
Review follow-up. Reading the environment first, per key, let values mix: with MID_INSTANCE_URL exported and --env-file pointing at another instance's file, that file's credentials went to the exported host. A stale exported password also beat an edited file. All three settings now come from one source: the --env-file if given, else the environment if any of them is set, else .env. Env-file values are literal again, as docker run --env-file reads them (only `export ` and one pair of matching surrounding quotes are removed), so a password containing " #" is no longer cut short. Oddly shaped JSON gets the clear error instead of a traceback, and a rejected buildstamp is printed with %q. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
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.
Fixes the high finding from the 2026-10-17 repo review, plus the medium and low findings in the same script.
Findings
scripts/get_mid_url.shtook--passwordon argv, which contradicts the script's own "never in argv" promise. The password shows up inps(1)and in shell history.--passwordand--password=…are refused. The password comes only fromMID_INSTANCE_PASSWORD, set in an env file or in the environment.--configline broke on passwords containing"or\. A newline in a password could inject extra config lines.\and"are escaped for curl's config syntax. Line breaks in credentials are refused.export KEY=lines.exportis accepted. Otherwise values are read literally, the same waydocker run --env-filereads them.--xneeds a value".[A-Za-z0-9._-]. A rejected value is printed with%q.--recipedownloads and unpacks the recipe.Behaviour change:
MID_INSTANCE_URL,MID_INSTANCE_USERNAMEandMID_INSTANCE_PASSWORDnow come from one source:--env-file, if one is given;.env.The settings are never mixed across sources. Before, the script read only the env file. README, CHANGELOG and CLAUDE.md are updated.
Verification
tests/get_mid_url_test.sh: 28 cases, with a stubbedcurlthat records the--configtext sent on stdin. They pass on macOS/bin/bash3.2 and on bash 5.2 with GNU sed.curl, using fake values, against a local server that decodes the Basic auth header.--env-file, so values from two sources could mix. That is fixed in 8cb5019 and re-reviewed..github/workflows/ci.yml) runs shellcheck and the tests. It uses a read-only token, and checkout is pinned by SHA.asset/,Dockerfile*,META-INF,mid.env) are untouched.Not verified
curl.The upstream vendor findings (
asset/download.shunquoted wget, the signature substring match, the MD5 of the env) are not addressed here, because those files are vendor-signed.