-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Airflow does not mask secrets in Database URI's when secret has a special character. #36688
Comments
@Rurushu13 |
@dirrao There it is
|
I was able to replicate this, seems like a valid bug. Looking into it. 🤔 |
is this happening on the airflow main branch? |
@dirrao yes, the main branch also has this issue. |
I think it is by design that we have to percent encode the passwords containing special characters. The postgres documentation also has a mention of it: https://www.postgresql.org/docs/11/libpq-connect.html#id-1.7.3.8.3.6 I think what you need to do here is define the env variables post encoding, maybe that should solve the issue. cc @uranusjr, I think you can have some valuable suggestions here |
@amoghrajesh while that might be, but the issue is that the password when encoded is not getting redacted (Because our redactor today explicitly redacts exact matches only). I do not believe they're asking that it not be encoded, but that on encoding it continue to get redacted like a alphanumeric password would and that's what the PR I've raised does. |
I think @aritra24 is right - this is not about URL passwords (where the password should - indeed - be URL, encoded) - but if there is a password in connection, that does not get masked when we print a URL form of the connnection, then the quoted version should be masked. While we cannot prevent all the ways how password can be mangled and transformed (say you add space and Base64 such password for example), some common usages (like URL encoding) that are likely to appear in our logs should be masked as welll. If I read this one properly, the connection password is stored "as is" while we are quoting it i the output when printing it as "url" so we should mask it there. |
Connection uri's get connection uses quote to change the password and certain other fields to escape special chars due to this, when the connection object is passed through the masker this changed string is skipped.
* Secret masker ignores passwords with special chars #36688 Connection uri's get connection uses quote to change the password and certain other fields to escape special chars due to this, when the connection object is passed through the masker this changed string is skipped. * Added a test for the logging change
Thank you for your hard work everyone 🤗 |
* Secret masker ignores passwords with special chars #36688 Connection uri's get connection uses quote to change the password and certain other fields to escape special chars due to this, when the connection object is passed through the masker this changed string is skipped. * Added a test for the logging change (cherry picked from commit e853849)
* Secret masker ignores passwords with special chars #36688 Connection uri's get connection uses quote to change the password and certain other fields to escape special chars due to this, when the connection object is passed through the masker this changed string is skipped. * Added a test for the logging change (cherry picked from commit e853849)
* Secret masker ignores passwords with special chars #36688 Connection uri's get connection uses quote to change the password and certain other fields to escape special chars due to this, when the connection object is passed through the masker this changed string is skipped. * Added a test for the logging change (cherry picked from commit e853849)
Apache Airflow version
Other Airflow 2 version (please specify below)
If "Other Airflow 2 version" selected, which one?
2.5.1
What happened?
While we were trying to use a BashOperator that would take our Database URI as an Env variable, we noticed that one of our connection URI's password aren't correctly being masked. The difference we found out between two passwords are, one of them have no special character whereas the other one has exclamation points. The original unmasked passphrase is
!Weird!Password^123$
and the masked passphrase isTotallyAlphanumericPassword123
In order to confirm that this was indeed the issue, we tried removing any special characters from the password of the errenous one, and it was indeed the issue. Password ended up being masked.
What you think should happen instead?
The password should be masked even if it has a special character in it.
How to reproduce
!
) inenv
parameter usingBaseHook.get_connection("Database").get_uri()
Operating System
Ventura 13.5
Versions of Apache Airflow Providers
No response
Deployment
Virtualenv installation
Deployment details
No response
Anything else?
It occurs every-time.
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: