You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "w0ut0 (via GitHub)" <gi...@apache.org> on 2024/03/14 10:55:49 UTC

[I] Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable [airflow]

w0ut0 opened a new issue, #38144:
URL: https://github.com/apache/airflow/issues/38144

   ### Apache Airflow Provider(s)
   
   microsoft-azure
   
   ### Versions of Apache Airflow Providers
   
   ```
   apache-airflow-providers-microsoft-azure==9.0.0
   ```
   
   ### Apache Airflow version
   
   apache-airflow==2.8.1
   
   ### Operating System
   
   Ubuntu 22.04.3 LTS
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### Deployment details
   
   _No response_
   
   ### What happened
   
   I set the connection as follows:
   ```
   export AIRFLOW_CONN_AZURE_DEFAULT='azure://<sp-appid>:<sp-secret>?tenantId=<my-tenant>&subscriptionId=<my-subscription>'
   ```
   
   As `sp-secret` is a password, I would assume it is masked from task logs. However, this is not the case.
   
   I see 2 possible reasons:
   - There is no concept of hostname (so no `@fqdn`), which the masking feature might filter on?
   - There are special characters in the password field. In my case, the following characters are used: `UPPERCASE, lowercase, ~ - _`
   
   
   ### What you think should happen instead
   
   The log should render:
   ```
   AIRFLOW_CONN_AZURE_DEFAULT=azure://<sp-appid>:***?tenantId=<my-tenant>&subscriptionId=<my-subscription>'
   ```
   just like it does with for example postgresql connection.
   
   ### How to reproduce
   
   Add the connection (does not even need to make sense) as environment variables:
   ```
   export AIRFLOW_CONN_AZURE_DEFAULT='azure://<sp-appid>:<sp-secret>?tenantId=<my-tenant>&subscriptionId=<my-subscription>'
   ```
   
   Create simple DAG to print environment variables
   
   ### Anything else
   
   I have tried adding a fake hostname `x` by modifying the string to
   ```
   export AIRFLOW_CONN_AZURE_DEFAULT='azure://<sp-appid>:<sp-secret>@x?tenantId=<my-tenant>&subscriptionId=<my-subscription>'
   ```
   This still prints the secret unmasked.
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable [airflow]

Posted by "w0ut0 (via GitHub)" <gi...@apache.org>.
w0ut0 commented on issue #38144:
URL: https://github.com/apache/airflow/issues/38144#issuecomment-2117214103

   @potiuk, I have had the ability to test this on Airflow 2.9.1, unfortunately, my secret is still not masked. I have 2 connection strings that are unmasked:
   ```
   AIRFLOW_CONN_AZURE=azure://<AAD_CLIENT_ID>:UNMASKED_PASSWORD?tenantId=<AAD_TENANT_ID>&subscriptionId=<SUBSCRIPTION_ID>
   
   AIRFLOW_CONN_DATABRICKS=databricks://<AAD_CLIENT_ID>:UNMASKED_PASSWORD@<workspace_url>.azuredatabricks.net?azure_tenant_id=<AAD_TENANT_ID>
   ```
   
   Let me change some (normal) characters in the password:
   
   `pO51Q~MLdXXu-H_sOMNECHANGECHARSldk`
   
   It shows up unmasked when doing eg. `printenv`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #38144:
URL: https://github.com/apache/airflow/issues/38144#issuecomment-1998580642

   Looks like duplicate fixed in 2.8.2  @zwelgbeer - > Please upgrade your airflow to latest version and report back. Good idea is to upgrade to 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #38144:
URL: https://github.com/apache/airflow/issues/38144#issuecomment-2476157665

   Sure


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable [airflow]

Posted by "w0ut0 (via GitHub)" <gi...@apache.org>.
w0ut0 commented on issue #38144:
URL: https://github.com/apache/airflow/issues/38144#issuecomment-1997336619

   Probably same issue as https://github.com/apache/airflow/issues/36688, I'll try to see if that fix solves this issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable [airflow]

Posted by "nailo2c (via GitHub)" <gi...@apache.org>.
nailo2c commented on issue #38144:
URL: https://github.com/apache/airflow/issues/38144#issuecomment-2888531750

   Hi @w0ut0, does this issue still occur? I tried reproducing it with this DAG on Airflow 3.1.0 and couldn’t, so I suspect it’s been fixed.
   
   ```python
   from datetime import timedelta
   import pendulum
   from airflow.decorators import dag
   from airflow.operators.bash import BashOperator
   from airflow.hooks.base import BaseHook
   
   @dag(
       dag_id="shell_test_all_providers",
       description="Test secret masking for Postgres, MySQL, Azure, Databricks",
       start_date=pendulum.datetime(2025, 1, 1),
       schedule=None,
       catchup=False,
       tags=["test"],
       default_args={
           "retries": 0,
           "retry_delay": timedelta(minutes=5),
       },
   )
   def shell_test_all_providers():
       pg_uri    = BaseHook.get_connection("DATAWAREHOUSE").get_uri()
       mysql_uri = BaseHook.get_connection("MYSQL_CONN").get_uri()
       azure_uri = BaseHook.get_connection("AZURE_CONN").get_uri()
       dbrk_uri  = BaseHook.get_connection("DATABRICKS_CONN").get_uri()
   
       mask_test = BashOperator(
           task_id="masking_demo_all",
           bash_command=(
               'echo "Postgres:     $PG_URI"\n'
               'echo "MySQL:        $MYSQL_URI"\n'
               'echo "Azure:        $AZURE_URI"\n'
               'echo "Databricks:   $DATABRICKS_URI"'
           ),
           env={
               "PG_URI": pg_uri,
               "MYSQL_URI": mysql_uri,
               "AZURE_URI": azure_uri,
               "DATABRICKS_URI": dbrk_uri,
           },
       )
   
       return mask_test
   
   shell_test_all_providers()
   ```
   
   ![Image](https://github.com/user-attachments/assets/9082c0de-882f-415e-a216-d0134691b8fc)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable [airflow]

Posted by "zwelgbeer (via GitHub)" <gi...@apache.org>.
zwelgbeer commented on issue #38144:
URL: https://github.com/apache/airflow/issues/38144#issuecomment-1997186252

   Please fix this issue


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk closed issue #38144: Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable
URL: https://github.com/apache/airflow/issues/38144


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable [airflow]

Posted by "geovalexis (via GitHub)" <gi...@apache.org>.
geovalexis commented on issue #38144:
URL: https://github.com/apache/airflow/issues/38144#issuecomment-3525124522

   Not able to reproduce with `apache-airflow==2.9.1` and `apache-airflow-providers-microsoft-azure==9.0.0`. I've tested URIs and JSON versions, and in both cases the client secret is being masked correctly.
   
   What I did notice though is that if you run a `env` or `set` command within the bash operator, some secrets get exposed through the logs. Should this be of concern?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on issue #38144:
URL: https://github.com/apache/airflow/issues/38144#issuecomment-1997169225

   Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable [airflow]

Posted by "sonalshreya (via GitHub)" <gi...@apache.org>.
sonalshreya commented on issue #38144:
URL: https://github.com/apache/airflow/issues/38144#issuecomment-2475358661

   Hi @potiuk i would like to contribute in this issue and it is also marked as good first issue , so can I work on it?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Microsoft Azure Connection: Service principal secret does not get masked when providing connection via URI environment variable [airflow]

Posted by "aaron-y-chen (via GitHub)" <gi...@apache.org>.
aaron-y-chen commented on issue #38144:
URL: https://github.com/apache/airflow/issues/38144#issuecomment-6004671278

   Hi @w0ut0, just a quick check: does this issue still exist? Otherwise I think this issue could be closed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org