Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - substitutes DSN exposure with DBMS respective error messages #4508

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

edonsec
Copy link

@edonsec edonsec commented Feb 27, 2025

This PR aims to address some security concerns raised within #4504.

@weiznich weiznich requested a review from a team February 28, 2025 08:02
Copy link
Member

@weiznich weiznich left a comment

Choose a reason for hiding this comment

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

Thanks for submitting. The changes to the example project look good to me. I would like to keep the error in diesel_cli as it is, as there is really not much possibility to leak anything there, given that the URL is often provided explicitly and the application is designed to be run during development.

Edit: If you pull in the latest master branch, the CI error should also be fixed.

@@ -7,7 +7,7 @@ use crate::infer_schema_internals::TableName;
pub enum Error {
#[error("Initializing `.env` file failed: {0}")]
DotenvError(#[from] dotenvy::Error),
#[error("Could not connect to database via `{url}`: {error}")]
#[error("Could not connect to database: {error}")]
Copy link
Member

Choose a reason for hiding this comment

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

Given that this is a CLI application that expects the URL as explicit argument there is really not much what could be leaked here. So that change should be reverted.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for reviewing and fixing the CI error, I have now merged the latest master.

I was curious about this one - but is there a value in exposing this? There would still be concerns if the cli command was say implemented in a CI/CD pipeline and using the environmental DATABASE_URL, where it could also leak the credentials in certain cases.

Copy link
Member

Choose a reason for hiding this comment

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

Yes there is value in exposing this. The URL can come from different input sources, like a .env file, an environment variable or a command line flag. That means it's not always 100% clear which URL is used. By explicitly printing out the URL, users can easily notice if the wrong URL is used.

And yes it could be exposed in CI situations, but again that environment already has access to this kind of information anyways.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for reviewing weiznich. I have reverted the change to this file and its subsequent test.

I do strongly advise this be reconsidered for a future release. The DSN being exposed is a far bigger risk than a developer being unable to identify which DSN is in effect.

Perhaps some alternative approaches to consider:

  • Sanitizing the DSN to redact the password component
  • Having an additional argument in the CLI tool for exposing debug information to limit this behaviour by default.

Happy to prepare additional PR requests for either of the above if desired.

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