Skip to content

Conversation

@PaulSD
Copy link

@PaulSD PaulSD commented Jan 25, 2026

In general, environment variables are NOT a safe way to pass sensitive values. Environment variables are often visible to all processes on the container host, and they may be written to output or logs in some cases. For security, files (either bind-mounted or copied from the host) should always be used instead of environment variables to pass sensitive values.

In general, environment variables are NOT a safe way to pass sensitive
values.  Environment variables are often visible to all processes on the
container host, and they may be written to output or logs in some cases.
For security, files (either bind-mounted or copied from the host) should
always be used instead of environment variables to pass sensitive
values.
@PaulSD
Copy link
Author

PaulSD commented Jan 26, 2026

Note that the 'openproject' Docker image also improperly uses environment variables for several sensitive values by default. However, for that image (unlike this image without this PR) it is possible to override the default behavior and pass in sensitive values using files without modifying the existing Docker image:

  • For the database password:
    Create a file containing db:5432:*:<user>:<password> (substitute actual values for <user> and <password>) and mount it at /home/app/.pgpass, then remove the password from the DATABASE_URL environment variable (but keep the username in the URL).
  • For the Rails secret_key_base value:
    (This value is critical for security in production environments, and is mentioned in the OpenProject Manual and all-in-one Docker install instructions but is missing from the Docker Compose example config and instructions.)
    Create a file containing Rails.application.config.secret_key_base = '<random value>' (substitute an actual value for <random value>) and mount it at /app/config/initializers/secret_key_base.rb.
  • For the Hocuspocus secret:
    Create a file containing OpenProject::Configuration[:collaborative_editing_hocuspocus_secret] = '<random value>' (substitute an actual value for <random value>) and mount it at /app/config/initializers/hocuspocus_secret.rb.

Copy link
Contributor

@brunopagno brunopagno left a comment

Choose a reason for hiding this comment

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

Hey, thanks a lot for the contribution. The solution looks good to me. Only two small details: I suggested a fix on the code. And we need at least to mention the env variable on the README.

Let me know if you'd like to handle that. Otherwise I can take it over.

🙇

Comment on lines +6 to +10
const SECRET = (
process.env.SECRET_FILE
? fs.readFileSync(process.env.SECRET_FILE, { encoding: 'utf8', flag: 'r' })
: process.env.SECRET
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Small fix, but since we're importin readFileSync we don't need to prefix the function call with the fs. on line 8

Suggested change
const SECRET = (
process.env.SECRET_FILE
? fs.readFileSync(process.env.SECRET_FILE, { encoding: 'utf8', flag: 'r' })
: process.env.SECRET
);
const SECRET = (
process.env.SECRET_FILE
? readFileSync(process.env.SECRET_FILE, { encoding: 'utf8', flag: 'r' })
: process.env.SECRET
);

@oliverguenther
Copy link
Member

Once that's merged, could you please add this option to the documentation at https://github.com/opf/helm-charts/blob/main/charts/openproject/README.md, so that we inform users about their choices?

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants