Join our Newsletter — 33% off our NHI Course
Home› FAQ› AI Security› Why do secrets in an AI context window…
AI Security

Why do secrets in an AI context window become more dangerous when Markdown is enabled?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated October 22, 2026 Domain: AI Security

Because the model can turn a secret into a link or image URL, and the browser will often resolve that URL automatically. That means an API key, token, or confidential snippet can leave the product boundary during rendering even when the model never executes a tool. The risk is outbound transmission, not model reasoning.

Why Markdown turns secret leakage into an outbound-rendering problem

Markdown changes the failure mode because it gives the model a syntax that can be rendered into active browser elements, not just plain text. When a secret is interpolated into a link or image field, the client may resolve that destination automatically, so the data can leave the product boundary during display. The dangerous part is not model execution, but browser-side fetch behaviour.

That means the same secret fragment is far more hazardous in a Markdown-enabled context than in a plain-text context. A harmless-looking token can become a network request, which creates a leak path even if no tool call is made and no explicit exfiltration step exists in the model workflow.

How the leak happens during rendering

In practice, the issue is usually not that the model “understands” the secret. The issue is that rendered Markdown can transform text into a clickable or fetchable object. If the output contains a secret or API key inside a URL, image source, or other browser-resolved location, the browser may request that resource as soon as the message is rendered.

This creates a control gap between generation and display. Teams often focus on prompt injection, tool abuse, or model misuse, but the rendering layer can still transmit sensitive material outward before any application-level guardrail has a chance to intervene.

Markdown also makes accidental leakage easier to miss in review. A string that looks like an inert snippet can be converted into a live reference after formatting, so security checks must examine the post-rendered output, not only the raw model response.

Why this matters for AI secrets handling

Secrets in AI systems are already high-value because they often unlock APIs, storage, internal services, or downstream automation. If those same secrets are allowed into a context window that may later be rendered as Markdown, the product must treat the output path as a potential exfiltration channel, not merely a presentation feature. For practical secrets handling guidance, see the Secrets Management Guide.

That risk is especially important when secrets appear in logs, debug traces, pasted tickets, or retrieved context. Once the model sees them, formatting logic, previews, sanitizers, and rich-text renderers all become part of the attack surface. A safe design assumes that any secret copied into generated text may be transformed into something the browser can act on.

When teams manage non-human identities or long-lived credentials, the blast radius can be larger than a single message. The safest posture is to assume that anything renderable should be treated as potentially transmissible unless the UI strictly neutralises links, images, and other active Markdown constructs.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 sets the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-02 — Secret LeakageMarkdown can turn secrets into browser-resolved URLs, exposing secret leakage risk.
NHI-07 — Long-Lived SecretsSecrets in AI contexts are especially dangerous when they are reusable and can be rendered outward.
NHI-10 — Human Use of NHIPeople pasting secrets into AI prompts creates a human-mediated exposure path that the UI can amplify.
Recommendation — Escape or block active Markdown around secrets before rendering user-controlled content. Prefer short-lived credentials and rotate any secret exposed in AI workflows promptly. Restrict humans from pasting live credentials into AI prompts and replace them with safer references.
NIST SP 800-53 Rev 5SC-28 — Protection of Information at RestSensitive content in AI workflows needs protection when stored or processed before rendering.
AU-9 — Protection of Audit InformationRendered secrets can surface in logs and traces, so audit data needs protection from disclosure.
Recommendation — Protect sensitive prompt and response data so secrets are not exposed during handling. Prevent sensitive prompt and response data from being exposed in logs and telemetry.

Practitioner Guidance

What to verify: Check the rendered output path, not just the model output. If Markdown is enabled, confirm that secrets are neutralised before formatting, and that link and image resolution cannot occur from untrusted content.

Decision rule: If a field may contain credentials, tokens, or confidential snippets, render it as inert text or escape Markdown entirely. If rich formatting is required, apply a sanitizer that blocks browser-resolved URLs and strips active elements from sensitive content.

Common mistake: Treating “the model did not call a tool” as proof of safety. In this case, the browser is the transmission mechanism, so the control must cover presentation, sanitization, and preview rendering.

Practitioner takeaway: The key judgement is to treat Markdown rendering as a data-exfiltration surface whenever secrets can enter the context window, because the leak can happen even when the model itself never takes an external action.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 22, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org