A Drupal inference workstation is any machine or server process where editors, developers, or automated jobs call a large language model from inside Drupal — whether through an AI module, a custom integration, or a coding assistant working on the codebase itself. Separating production secrets from prompts means making sure API keys, database passwords, and app credentials never travel into a prompt, a model's context window, or a commit, where they can leak back out through logs, generated code, or a model's own output.
The risk is not hypothetical. Drupal's own contributed modules store AI provider keys in ways the project's documentation rates as less than ideal, and independent research on AI coding assistants has measured real secret leakage at scale. The sections below cover where Drupal keeps these credentials today, why environment variables are not the final answer, and what a site maintainer can actually change.
Table of Contents
- Where does Drupal store AI provider API keys today?
- Why environment variables aren't the finish line
- How do AI coding assistants actually leak credentials?
- What actually separates a secret from a prompt
- A quick framework for prioritizing fixes
- Frequently Asked Questions
Where does Drupal store AI provider API keys today?
Most Drupal sites that connect to an AI provider — for content generation, moderation, or an editorial assistant — store that provider's API key using the contributed Key module. The Key module's project page documents three storage tiers: Configuration (saved with the site's exported config), File (a file on the server's filesystem), and Environment variable (read from the server process at runtime). The module's own documentation ranks an external key-management system, such as a vault service, above all three, treating in-database or in-config storage as the weaker options. That ranking matters because of how the `drupal_cms_ai` recipe behaves out of the box.
A Drupal.org issue reports that the recipe stores third-party AI provider keys directly in exported configuration by default — meaning the key sits in plaintext inside a config export that is often committed to a code repository alongside everything else. The issue proposes pairing the Key module with the Easy Encryption key provider so the key is no longer readable as plain text in that export. The amazee.io AI provider module shows the same pattern from a different angle. Its advanced configuration documentation describes storing the LLM API key and a database password through the Key module in Drupal config, and documents wrapping both with Easy Encryption — but it is explicit that even encrypted, the encryption key itself still lives on the server. The module's own recommendation for the strongest setup it supports is an environment variable, not config storage of any kind.
Why environment variables aren't the finish line
Environment variables are the most common credential storage method recommended across Drupal's ecosystem, and they are a real improvement over plaintext config — they keep secrets out of version control and config exports. But Drupal.org's official security guide is direct about their limit: any code running in the same server process can read them. On a shared hosting environment, or on a workstation running an AI coding assistant with shell access, that is a meaningfully different threat model than a credential locked behind a dedicated secrets service.
For a Drupal site running AI integrations, this means the choice of storage tier should track what else runs on that server. A single-tenant production server with tightly scoped processes is a reasonable place for environment-variable storage. A development or inference workstation where a coding assistant, build scripts, and test suites all share the same shell session is not — anything with process-level access can, in principle, read what the environment variable exposes.
- Configuration storage: readable from any exported config, including a git history.
- File storage: readable by anything with filesystem access to that path.
- Environment variable: readable by any process sharing that server or session.
- External key-management / vault service: the tier the Key module's own documentation rates strongest, because the credential is never resident in Drupal's config, filesystem, or process environment at rest.
How do AI coding assistants actually leak credentials?
The leakage risk is not limited to where Drupal stores a key — it extends to what a coding assistant does with code that contains one. A 2023 academic study built a tool it called a "Hard-coded Credential Revealer" and used black-box prompting to extract 2,702 hard-coded credentials from GitHub Copilot and 129 from Amazon CodeWhisperer. At least 3.6% to 5.4% of what it extracted were real secret strings still present on GitHub at the time, though the researchers did not verify whether those specific credentials remained active. That pattern shows up in broader usage data too.
GitGuardian's research found that repositories with Copilot enabled leaked secrets — API keys, passwords, tokens — at 6.4%, versus 4.6% for repositories without it, a roughly 40% relative increase. Out of 20,000 sampled Copilot-access repositories, more than 1,200 contained at least one exposed secret. The pattern is not unique to one assistant or one vendor. The OECD's AI Incidents Monitor logged an entry in 2026 stating that in 2025, AI-assisted coding tools — specifically Claude Code — were associated with a rate of secret leaks in public GitHub commits roughly double that of human-only development. For a Drupal shop running AI-assisted development alongside AI-integrated content workflows, the exposure compounds: a secret that leaks from a committed config file and a secret that leaks through assistant-generated code are the same failure mode wearing two different disguises.
What actually separates a secret from a prompt
The practical fix is to make sure a credential never becomes part of the text a model reads or writes, regardless of which Drupal tier stores it at rest. A few concrete habits cover most of the exposure: This last point lines up with how the industry has started formalizing the risk.
OWASP's Top 10 for LLM Applications 2025 ranks "Sensitive Information Disclosure" as LLM02, up from LLM06 in the 2024 edition — a jump that reflects how often credentials, personal data, and proprietary information end up exposed through model outputs, training memorization, or prompt and context leakage. OWASP's recommendation is to remove or mask sensitive data before it ever reaches a third-party LLM, which for a Drupal site means auditing what a content-generation or coding-assistant prompt actually contains before it's sent.
- Keep provider keys out of any file a coding assistant is asked to read, summarize, or refactor — including exported configuration, `.env` files in a repo working tree, and committed fixtures.
- Treat an environment variable as a development convenience, not a production control, on any workstation where an AI assistant has shell or file access alongside the Drupal codebase.
- Where the Key module supports it, pair Configuration or File storage with Easy Encryption rather than leaving a key as plain text, and move toward an external vault for any key that must survive a config export.
- Audit exported configuration before it reaches a repository an assistant can read — the `drupal_cms_ai` issue exists precisely because that export is where keys first became visible.
- Scope what reaches the model in the first place: a request to generate or review code rarely needs the literal key value present in context, only a reference to where it's stored.
A quick framework for prioritizing fixes
Not every Drupal install needs a vault service overnight. The ranking from the Key module's documentation and the leakage research above suggest a practical order of operations:.
- First, get any plaintext key out of exported configuration — this is the cheapest fix and closes the gap the `drupal_cms_ae` issue describes.
- Second, move from File storage to Environment variable storage for any key still exposed on disk in a way a repository or backup might capture.
- Third, wrap stored keys with Easy Encryption wherever the Key module and the AI provider module both support it, accepting that the encryption key itself still needs protecting.
- Fourth, for any workstation where an AI coding assistant has broad shell or file access, isolate that assistant's environment from the one holding production credentials, rather than relying on the assistant to avoid reading them.
- Last, for keys that matter enough to justify the operational overhead, move to an external key-management or vault service — the tier every source above treats as the actual ceiling, not environment variables.
Frequently Asked Questions
Does encrypting a key in Drupal config make it safe to commit?
No. The amazee.io documentation notes that even with Easy Encryption applied, the encryption key itself still resides on the server, so the underlying risk moves rather than disappears.
Is an environment variable good enough for a production Drupal site's AI keys?
It is common practice, but Drupal.org's security guide warns that any code running in the same server process can read it, which is a different exposure than a dedicated vault service provides.
Are secret leaks from AI coding assistants a documented trend or a one-off?
Both GitGuardian's analysis and the OECD's AI Incidents Monitor report elevated leak rates tied to AI-assisted coding tools, across different tools and years.




