Skip to content

Harden BookStack DB_PASSWORD escaping in .env template#273

Merged
akuzminsky merged 3 commits into
mainfrom
harden-bookstack-db-password-escaping
Jun 11, 2026
Merged

Harden BookStack DB_PASSWORD escaping in .env template#273
akuzminsky merged 3 commits into
mainfrom
harden-bookstack-db-password-escaping

Conversation

@akuzminsky

Copy link
Copy Markdown
Member

Summary

Hardens the DB_PASSWORD line in the BookStack .env template across the global modules and the development + sandbox environments.

BookStack is a Laravel app, so its .env is parsed by vlucas/phpdotenv v5, not a shell. Inside a double-quoted value that parser treats exactly three characters specially:

  • \ — starts an escape sequence
  • $ — triggers variable interpolation
  • " — closes the string

Everything else (spaces, #, ', &, /, …) is literal. A backslash may only precede " \ $ f n r t v; anything else is a hard parse error that prevents BookStack from booting. The existing gsub(/[\\$"]/) already escapes precisely the right set, so this change is purely defensive:

  • Add .to_s so a nil/non-string Hiera lookup can't blow up template rendering.
  • Add a comment documenting why only \ $ " are escaped.

No behavioral change for any real string password.

Changes

  • modules/profile/templates/bookstack/env.erb
  • environments/development/modules/profile/templates/bookstack/env.erb
  • environments/sandbox/modules/profile/templates/bookstack/env.erb

🤖 Generated with Claude Code

akuzminsky and others added 3 commits June 11, 2026 12:53
Guard the gsub against a nil/non-string Hiera lookup with .to_s, and
document why only \ $ " are escaped: those are the only characters
phpdotenv (BookStack/Laravel's .env parser) treats specially inside a
double-quoted value. Applied across global modules plus the development
and sandbox environments.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The run_composer exec can exceed Puppet's default 300s timeout when
fetching BookStack's dependencies; bump it to 600s across global modules
and the development and sandbox environments.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@akuzminsky akuzminsky merged commit 8900ac7 into main Jun 11, 2026
2 checks passed
@akuzminsky akuzminsky deleted the harden-bookstack-db-password-escaping branch June 11, 2026 20:00
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.

2 participants