Skip to content

fix(security): add jq dependency and use it for safe JSON env injection#37

Open
onurege3467 wants to merge 1 commit into
Eyevinn:mainfrom
onurege3467:fix/issue-31-docker-entrypoint-jq-fallback
Open

fix(security): add jq dependency and use it for safe JSON env injection#37
onurege3467 wants to merge 1 commit into
Eyevinn:mainfrom
onurege3467:fix/issue-31-docker-entrypoint-jq-fallback

Conversation

@onurege3467

Copy link
Copy Markdown
Contributor

Closes #31

Replace the raw heredoc in docker-entrypoint.sh (which can produce
malformed JSON if env vars contain quotes, newlines, or other special
characters) with jq --arg, which properly JSON-encodes all values.

Changes:

  • Dockerfile: Add jq as an explicit Alpine package dependency so
    it is always available at runtime
  • docker-entrypoint.sh: Use jq -n --arg to generate the env-config.js
    JSON safely, instead of a raw heredoc that interpolates variables directly
    into JSON without escaping

Why this fix: The jq --arg command takes each value as a raw string
argument and handles JSON encoding internally — double quotes, backslashes,
newlines, null bytes, and all other special characters are properly escaped
in the output. The heredoc fallback (which lacked escaping for anything
beyond backslash, double-quote, and tab) is eliminated by ensuring jq is
always installed.

Verification:

  • bash -n docker-entrypoint.sh — shell syntax clean
  • jq --arg tested with quotes, newlines, empty values — all produce valid JSON
  • Only Dockerfile and entrypoint changed; no JS/TS modifications

Replace the raw heredoc in docker-entrypoint.sh (which can produce
malformed JSON if env vars contain quotes, newlines, or other special
characters) with jq --arg, which properly JSON-encodes all values.

Add jq as an explicit Dockerfile dependency so it is always available
at runtime, eliminating the jq-not-found fallback path entirely.

Closes Eyevinn#31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SECURITY][MEDIUM] docker-entrypoint.sh fallback escape_json() misses newlines — injection into env-config.js if jq unavailable

1 participant