---
title: "Passwords and API keys hardcoded in DAG files | Metacenta"
description: "A password in a DAG file stays in git history after the line is deleted. How we find credential-shaped literals without ever reading the value out."
url: "https://metacenta.com/rules/dag-credential-literal"
updated: "2026-10-14"
tokens: 570
---

Orchestration & reliability · rule dag-credential-literal

# Passwords and API keys hardcoded in DAG files

A Metacenta review checks this under the rule **Credentials are not written into the DAG**. Everything below applies whether or not you ever commission one.

## What this rule checks

This rule flags a DAG file that assigns a literal of eight or more characters to a name like `password`, `api_key`, `secret` or `access_token`. Values read through `os.environ`, `Variable.get`, a Connection or a template do not count, nor do obvious placeholders.

## Why it matters

A secret in a DAG file is a secret in git history. Everyone with repository access can read it, including people who have left. Deleting the line does not end the exposure, because the old value stays in history.

## How to fix it

**Move credentials out of scheduler code, and rotate any that were committed.** Move the value to an Airflow Connection, a Variable or your secrets backend, and reference it by name. Then rotate the credential, because the old value is still in history.

Before:

```python
password = "not-a-real-password"
```

After:

```python
password = Variable.get("warehouse_password")
```

## When it is fine to leave

A test fixture or a documented dummy value isn't a leak, even when it's long enough to match. Tell us which lines those are, and the finding comes out of your report.

## What we need to check it

Every orchestration file you name to us, whether or not it defines a job. We report the file and line numbers only. The value itself is never read into the report, our database or any LLM prompt.

[Ask about a review](https://metacenta.com/enquire?src=rule-dag-credential-literal&via=md)

## Related pages

- [Airflow DAG owner: how to set it and what it does](https://metacenta.com/rules/dag-unowned)
- [Airflow DAGs with no retries](https://metacenta.com/rules/dag-no-retries)
- [Airflow DAGs with no failure alert](https://metacenta.com/rules/dag-no-failure-alert)
- [Airflow catchup: what it does and how to control it](https://metacenta.com/rules/dag-catchup-unbounded)
- [A sample review, as a client reads it](https://metacenta.com/sample)
- [All published rules](https://metacenta.com/rules)
- [How a review is assessed](https://metacenta.com/standard)
