fix: redact non-JSON connection extra to prevent credential leakage#63161
fix: redact non-JSON connection extra to prevent credential leakage#631610x0OZ wants to merge 5 commits intoapache:mainfrom
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
SameerMesiah97
left a comment
There was a problem hiding this comment.
1-2 nits. It's fine otherwise. This will mask non-sensitive extras but I believe that is better than potentially leaking secrets.
Let's wait for CI to run as well.
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_connections.py
Outdated
Show resolved
Hide resolved
|
@0x0OZ This PR has been converted to draft because it does not yet meet our Pull Request quality criteria. Issues found:
What to do next:
Converting a PR to draft is not a rejection — it is an invitation to bring the PR up to the project's standards so that maintainer review time is spent productively. If you have questions, feel free to ask on the Airflow Slack. |
157545e to
3945108
Compare
|
There was no conflict, yay! I hope now the tests will pass |
|
Maybe I should not have dared to push into something I am not familiar with |
There was a problem hiding this comment.
I don't think always redacting is a good approach.
Also the 'extra' field should always be a 'valid json', if we check at the Connection._validate_extra in the database, we will never persist a connection with a non valid json as 'extra'.
So basically this should never happen. Do you happen to have a use case where the API returns extra in plain text when the extra isn't a valid json ?
Maybe we should instead raise a ValidationError there, explicitely saying that this is not expected and that we should never encounter this code path.
I don't have a real usecase in hand for why someone would use non-valid JSON data in the extra... |
|
Maybe something like this #63883. Lets see what the CI says and we can close this one I believe. |
Description
Currently, if a Connection's extra field contains an unstructured string (e.g., a raw Bearer token), the redact_extra validator in ConnectionResponse catches the JSONDecodeError and returns the plaintext payload. This fails open, exposing legacy or misconfigured secrets via the REST API to any user with can_read on Connections.
Fix
Modified the exception handler to fail closed. If the extra payload cannot be parsed as JSON for targeted redaction, the entire string is now masked with the standard "***" sentinel.
Testing
Added parametrized test test_get_should_redact_non_json_extra to validate blanket redaction across raw tokens, query strings, and plaintext formats.
Was generative AI tooling used to co-author this PR?
-- Resolving #63160
Tool: Claude Code