You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "eitan-shalev (via GitHub)" <gi...@apache.org> on 2026/09/01 15:50:15 UTC
[I] Support masking secrets in DagRun params [airflow]
eitan-shalev opened a new issue, #72377:
URL: https://github.com/apache/airflow/issues/72377
### Description
### Description
Currently, `Param` objects in Airflow support basic JSON schema types (string, integer, boolean, etc.). However, when passing sensitive variables at runtime via a DAG run's configuration JSON, any key-value pairs assigned to `params` or `dag_run.conf` are displayed in plaintext under the **DAG Run -> Details -> `conf`** section of the Airflow Webserver UI.
While `SecretsMasker` handles task log masking brilliantly, it does not mask the initial configuration payload stored in the database and surfaced in the UI.
To resolve this, I propose introducing a specialized data type or formatting rule for sensitive parameter inputs—such as a `password` format block or a native `SecretParam` object—that triggers UI redaction.
### Use Case
You have a Dag that needs to be triggered manually, and part of the config that needs to be passed to the Dag might be sensitive, like a token or a password to prove that the user who's triggering the Dag is allowed to, even if triggered via an API proxy. While storing sensitive data usually belongs in variables or connections, there are still many scenarios where ad-hoc execution requires passing sensitive data, which should not be visible in the UI.
Because the `conf` object is fully visible in the UI to users with standard permissions, users are forced to avoid `params` entirely for anything sensitive. Providing a native way to declare a parameter as "sensitive" ensures that Airflow natively redacts the configuration field within the UI metadata tab.
### Proposed Solution
Two potential implementations could resolve this:
1. **Leverage JSON Schema Formats:** Add native support for `"format": "password"` inside a standard Param dictionary.
```python
params={
"api_token": Param(
"default_token",
type="string",
format="password" # The UI rendering should catch this format and replace the value with "***"
)
}
```
2. **Dedicated Parameter Class:** Introduce a `SecretParam` object that extends `Param` and automatically marks the key for backend and UI masking.
```python
from airflow.models.param import SecretParam
params={
"api_token": SecretParam("default_token")
}
```
When either mechanism is parsed, the Airflow Webserver UI should display `***` instead of the raw string in both the "Trigger DAG w/ config" input form and the **DAG Run Details (`conf` tab)** view.
### Use case/motivation
Allow params to be defined as sensitive/ passwords, so that when rendered in the UI, they are masked.
### Related issues
_No response_
### Are you willing to submit a 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] Support masking secrets in DagRun params [airflow]
Posted by "RehanAhmad25 (via GitHub)" <gi...@apache.org>.
RehanAhmad25 commented on issue #72377:
URL: https://github.com/apache/airflow/issues/72377#issuecomment-5569313485
Hi @eitan-shalev , PR is complete and all CI checks are passing: #72499
Covers everything discussed here: `format="password"` masked in the Trigger UI Form, Task Logs, Rendered Templates, and the DAG Run Details page/REST API across get, list, trigger, patch, and clear. Docs are up in `params.rst` too, explicitly stating what's covered and what isn't (XCom display, DB encryption at rest).
Thanks for the discussion on this, it shaped the scope a lot better than my first pass.
--
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] Support masking secrets in DagRun params [airflow]
Posted by "RehanAhmad25 (via GitHub)" <gi...@apache.org>.
RehanAhmad25 commented on issue #72377:
URL: https://github.com/apache/airflow/issues/72377#issuecomment-5535790190
Opened a PR implementing the plan we settled on: #72499
Covers all three parts:
- `format="password"` masked in Task Logs and Rendered Templates via `mask_secret()` at param resolution time
- `conf` redacted in the DAG Run Details page and REST API (including the `dag_id="~"` list and batch endpoints)
- Docs to follow, explicitly stating the boundary (no XCom masking, no encryption at rest)
@eitan-shalev, tagging you since you've been reviewing the design discussion, happy to address anything in the PR itself.
--
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] Support masking secrets in DagRun params [airflow]
Posted by "RehanAhmad25 (via GitHub)" <gi...@apache.org>.
RehanAhmad25 commented on issue #72377:
URL: https://github.com/apache/airflow/issues/72377#issuecomment-5506756841
Thanks @eitan-shalev for the fast turnaround. Went and actually traced point 1 in the docs page as well as in the source, didn't want to propose something I hadn't verified. Here's what I found, changes the plan a bit and is more precise than my first pass.
**1. Rendered Templates**
You're right, and the real mechanism is even better than what I described. The redaction that actually matters isn't server-side, it happens in the worker: `_serialize_rendered_fields()` in `task-sdk/src/airflow/sdk/execution_time/task_runner.py` calls `redact()` from `airflow.sdk._shared.secrets_masker` on every template field before it gets sent to the API server via the `SetRenderedFields` message. There's actually a comment on that function confirming this is intentional: "This ensures that the secrets those are registered via mask_secret() on workers / dag processor are properly masked on the UI."
I double checked the import path before trusting this, since `mask_secret()` needs to be writing to the same masker instance that `redact()` reads from. `airflow.sdk.log.mask_secret` (the public function from the masking docs) imports from that exact same `airflow.sdk._shared.secrets_masker` module, so they share the same cached singleton. This matters because the masker is scoped per import path: `airflow._shared.secrets_masker` (used by the airflow-core `RenderedTaskInstanceFields` model) and `airflow.sdk._shared.secrets_masker` (used by task-sdk) are actually two separate singletons even within the same process, it says so right in that module's docstring. So we need to call `mask_secret()` from the task-sdk side, not the airflow-core side, or it just won't take effect.
Concretely: `process_params()` in `task-sdk/src/airflow/sdk/definitions/param.py`, right after `params.validate()` (this is what feeds `context["params"]` in `execution_time/context.py`), for each key whose declared `Param` has `schema.format == "password"`. That runs in the worker before `_serialize_rendered_fields()` runs, so the registration is actually in place by the time it's needed.
Worth flagging while I'm in here: this only gets us Task Logs and Rendered Templates. If someone XComs `dag_run.conf['api_token']`, it'd still show up in plaintext in the XCom UI, since neither `models/xcom.py` nor the XCom API routes run anything through `redact()`. Not proposing to fix that in this PR, it's the same shape of gap as `conf` in the DAG Run API and would need its own redaction pass, just wanted to be upfront about the boundary of what this actually covers.
**2. Storage at rest**
Agreed, I'll leave Fernet encryption out of this PR and just note it as a follow-up discussion in the PR description rather than deciding it myself.
**3. Nested values**
Agreed, limiting `format="password"` to string-typed params sidesteps the whole object-secret question for v1.
Updated plan for the PR:
- `mask_secret()` call in `process_params()` for string params with `format == "password"`, covers Task Logs and Rendered Templates.
- Redaction helper for `DAGRunResponse` / `DAGRunCollectionResponse.conf` at the API layer, covers the DAG Run Details page and the REST API responses, since those aren't part of the SecretsMasker's redact-on-serialize path.
- Docs for `format="password"` in `core-concepts/params.rst`, spelling out what's covered (logs, rendered templates, DAG Run Details/API) and what isn't (XCom display, DB encryption at rest), so nobody assumes broader coverage than what's actually there.
Starting on this, will open a PR once tests are passing locally.
--
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] Support masking secrets in DagRun params [airflow]
Posted by "RehanAhmad25 (via GitHub)" <gi...@apache.org>.
RehanAhmad25 commented on issue #72377:
URL: https://github.com/apache/airflow/issues/72377#issuecomment-5511457267
Yes, exactly, and I checked to be sure rather than just agree. `Connection.password` goes through the identical path: `_mask_connection_secrets()` in `task-sdk/src/airflow/sdk/execution_time/context.py` calls `mask_secret(conn.password)` at fetch time, same as what we're planning for password-format params. Its own docstring even says what it's for: "Mask sensitive connection fields from logs." Not everywhere, from logs. There's nothing in that flow that special-cases XCom either, so `{{ conn.password }}` pushed to XCom today shows up in plaintext in the XCom UI right now, completely unrelated to this issue.
So this isn't a new limitation our change introduces, it's the same known tradeoff that already exists for every secret `mask_secret()` touches. If a task deliberately hands a secret to something outside masking's reach (XCom, a return value, a print statement targeting a channel outside logging), it'll show up there. Good to have that confirmed before I start, means I don't need to treat the XCom point as a gap in this PR, just as expected/existing behavior consistent with how Connections already work.
--
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] Support masking secrets in DagRun params [airflow]
Posted by "eitan-shalev (via GitHub)" <gi...@apache.org>.
eitan-shalev commented on issue #72377:
URL: https://github.com/apache/airflow/issues/72377#issuecomment-5506342362
Hi @RehanAhmad25 , thanks for picking this up!
1. Regarding Rendered Templates - If I'm reading the [documentation](https://airflow.apache.org/docs/apache-airflow/stable/security/secrets/mask-sensitive-values.html) correctly, then calling `mask_secret ` on the param's value, should ensure that it's masked also in the rendered template. Correct me if I'm wrong!
2. I think the _right_ thing to do is to encrypt the secret at rest as well, no doubt about it. But for a phase 1 PR, I think this could wait. Would be worth hearing from other voices in the community about it though.
3. Regarding nested values - Edge case, but I think it should be relatively easy to parse, same as parsing the list of params as a whole. So long as we limit the `format="password"` to params of type String, we avoid complex scenarios where an entire object needs to be treated as a secret.
--
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] Support masking secrets in DagRun params [airflow]
Posted by "RehanAhmad25 (via GitHub)" <gi...@apache.org>.
RehanAhmad25 commented on issue #72377:
URL: https://github.com/apache/airflow/issues/72377#issuecomment-5504179025
Hi @eitan-shalev .
Took a look at the current source before weighing in here. Scope is a bit wider than my first pass suggested, but still tractable.
`Param.schema` already accepts arbitrary JSON Schema keywords via `**kwargs` (see `task-sdk/src/airflow/sdk/definitions/param.py`), so `format="password"` works today with zero changes to the `Param` class. The "Trigger DAG w/ config" form is also already covered: `FieldPassword.tsx` renders a masked input with a show/hide toggle whenever `schema.format === "password"`, wired through `FieldSelector.tsx`. A new `SecretParam` class would mostly duplicate what this schema-based approach already gives us.
The real gap is redaction downstream of the trigger form: it's masked while typing, but nothing masks it once stored.
Proposed scope for a first PR:
- Redact `conf` in the API/UI: a helper that checks each top-level `conf` key against its declared `Param`'s schema and replaces the value with `***` when `format == "password"`. Applied to `DAGRunResponse` / `DAGRunCollectionResponse` so both the DAG Run Details page and the REST API are covered.
- Register these values with `SecretsMasker` at resolve time, so they're also redacted in task logs if a user does something like `print(dag_run.conf)`. Doing the UI masking without this would create a false sense of security.
- Document `format="password"` in `core-concepts/params.rst`, since it already works but isn't mentioned there.
Open questions before I start:
1. Rendered Templates: if a task templates this value (`{{ dag_run.conf['api_token'] }}`), it'll currently show up in plaintext in that task instance's Rendered Template tab. That's a separate rendering path from `DAGRunResponse` and I haven't dug into whether there's an existing hook to mask it there too. Worth doing in this PR, or a known follow-up?
2. Storage at rest: `dag_run.conf` is stored as plaintext JSON in the metadata DB today. Is masking in the API/UI/logs sufficient for v1, or is there appetite for Fernet-encrypting these specific values the way Connections/Variables are handled? I'd treat that as a separate, larger discussion rather than bundle it into this fix, but wanted to flag it explicitly rather than assume.
One known edge case I'm aware of and not planning to solve in v1: a `Param` can itself declare a nested object schema with its own `format` on a sub-property, which the top-level-key check above won't catch. Flagging it rather than building full recursive masking before the top-level approach is even confirmed.
Happy to pick this up if the scope above sounds right. Let me know your take on the two open questions.
--
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] Support masking secrets in DagRun params [airflow]
Posted by "eitan-shalev (via GitHub)" <gi...@apache.org>.
eitan-shalev commented on issue #72377:
URL: https://github.com/apache/airflow/issues/72377#issuecomment-5510482840
Amazing!
Just to put a finer point on something, you wrote
> If someone XComs dag_run.conf['api_token'], it'd still show up in plaintext in the XCom UI
This is exactly the same thing that would happen if they'd return `{{ conn.password }}` to xcom, right? So this is a known limitation of the system - if a user writes a task that deliberately emits a secret, then the secret will deliberately be emitted. Right?
--
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