Skip to content

feat: support configurable quote character for dotenv export - #389

Open
mateuscmtropical wants to merge 1 commit into
Infisical:mainfrom
mateuscmtropical:feature/export-quote-char
Open

feat: support configurable quote character for dotenv export#389
mateuscmtropical wants to merge 1 commit into
Infisical:mainfrom
mateuscmtropical:feature/export-quote-char

Conversation

@mateuscmtropical

Copy link
Copy Markdown

Description 📣

Implements #1103 (possibility to export env-s with different quote character).

infisical export always wrapped values in single quotes. Single quoted dotenv values have no escape sequences, so a multiline value (e.g. a PEM private key) can't be represented with a real newline — you'd have to post-process the file afterward.

  • adds --dotenv-quote-char (default ', existing output unchanged), accepting ' or "
  • double-quote mode lets the existing multiline encoding decode back into a real newline on read
  • only affects the dotenv/dotenv-export formats; json/csv/yaml/dotenv-eval are unaffected
  • validated immediately after flag parsing, before any network call or the --template path

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

Ran go test ./packages/cmd/... -vet=off (all passing).

Verified against the real dotenv npm package (not just Go tests) that double-quoted output round-trips correctly for values with trailing backslashes, embedded quotes, backslash+quote combinations, and multiline private keys:

infisical export --env=dev --dotenv-quote-char='"' > .env

`infisical export` always wrapped values in single quotes. Single quoted
dotenv values have no escape sequences, so a multiline value (e.g. a PEM
private key) can't be represented with a real newline.

Adds --dotenv-quote-char (default: '), letting the value be wrapped in
double quotes instead, which lets the existing multiline encoding decode
back into a real newline on read. Only affects the dotenv/dotenv-export
formats; validated up front, before any network call.

Closes Infisical/infisical#1103
@mateuscmtropical
mateuscmtropical marked this pull request as ready for review September 4, 2026 23:52
@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a configurable single- or double-quote wrapper for dotenv and dotenv-export output while preserving the existing single-quote default.

  • Registers and validates the new --dotenv-quote-char flag before secret retrieval.
  • Routes the selected wrapper through the dotenv formatters.
  • Adds formatter and validation coverage for quotes, backslashes, multiline values, and unaffected formats.
  • Double-quote mode creates a command-injection path when dotenv-export output is consumed by a shell.

Confidence Score: 3/5

The PR is not safe to merge until double-quote mode stops making secret contents executable when dotenv-export output is sourced.

The new mode emits arbitrary secret values verbatim inside shell double quotes, where command substitutions and quote boundaries remain active; this creates a concrete command-execution path for a documented shell-oriented format.

Files Needing Attention: packages/cmd/export.go

Security Review

Double-quoted dotenv-export output writes arbitrary secret values into shell assignments without escaping shell expansions or delimiters. Sourcing output containing command substitutions, backticks, or injected quote boundaries can execute secret-controlled commands.

Important Files Changed

Filename Overview
packages/cmd/export.go Adds configurable dotenv quoting, but applies verbatim double-quoted values to shell-oriented dotenv-export output, enabling shell interpretation.
packages/cmd/export_test.go Adds broad unit coverage for formatting and validation, although it does not test shell consumption of double-quoted dotenv-export output.

Reviews (1): Last reviewed commit: "feat: support configurable quote charact..." | Re-trigger Greptile

Comment thread packages/cmd/export.go
// something parsers only do for double quoted values. That is the whole reason
// to pick it over the single quote default.
func quoteDotEnvValue(env models.SingleEnvironmentVariable, quoteChar string) string {
return quoteChar + escapeNewLinesIfRequired(env) + quoteChar

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Double Quotes Enable Injection

When dotenv-export uses the new double-quote mode, secret contents remain active shell syntax. A value such as $(command) is emitted as export KEY="$(command)", so sourcing the generated shell-environment output executes the command. Embedded double quotes can also end the assignment and inject more shell syntax. Keep dotenv-export shell-safe regardless of the selected quote character, or reject double-quote mode for this format.

How this was verified: Arbitrary secret values flow directly into a double-quoted export assignment without escaping command substitutions, backticks, dollar signs, or double quotes.

Knowledge Base Used: Secret workflows

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.

1 participant