Join our Newsletter — 33% off our NHI Course
Home› FAQ› AI Security› What should security teams do first when an…
AI Security

What should security teams do first when an AI app exposes chat history and API keys in a public database?

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

The first step is to assume the exposed database may contain more than chat logs and treat it as a credential incident. Security teams should isolate the system, revoke affected API keys, search for additional secrets, and verify whether the database was reachable through simple scanning. Rapid containment matters because exposed data can enable follow on access even before full impact is known.

Why this is a credential incident, not just a data leak

When chat history and API keys appear in a public database, the exposure should be treated as live access material first and a data disclosure second. The practical issue is not only who can read the records, but whether the keys can authenticate to downstream systems before you have fully mapped the blast radius. That is why the first response is containment, revocation, and secret discovery rather than a narrow records review.

A useful working assumption is that any database exposed to simple scanning may have already been indexed or copied. That shifts the response from “is the data sensitive?” to “what else can these secrets reach, and what must be invalidated now?” Publicly exposed databases often contain more than the obvious rows, so teams should search for adjacent secrets, embedded tokens, and linked credentials as part of the same incident window.

One useful reference point is that 80% of identity breaches involved compromised non-human identities such as service accounts and API keys, which matches the operational reality of exposed application secrets. For broader context on secret sprawl and credential exposure patterns, see Ultimate Guide to NHIs and Guide to the Secret Sprawl Challenge.

Containment, revocation, and exposure verification

The first defensive move is to isolate the exposed environment and invalidate any keys that could have been used from the public database. If the database itself was reachable without authentication, teams should also assume queryable metadata, backups, and linked storage may be in scope until proven otherwise. That means containment has to be immediate, even before a full forensic picture is available.

Verification should focus on two questions: what secrets were present, and whether the database was trivially discoverable from the internet. If the answer to either is yes, the incident is already in the “follow-on access possible” category. For incident response practice, this is where standard coordination and triage discipline matter, so teams can align containment with evidence preservation and downstream notification decisions. See also FIRST and OWASP Web Security Testing Guide for structured validation of exposed web assets and access paths.

Because the database holds both conversations and keys, you should not assume the visible records tell the full story. The right operational posture is to treat the exposure as a potential key compromise event, search for reuse across environments, and check whether any keys grant write access, admin access, or third-party API reach. In one NHIMG case study, exposed databases revealed far more than chat content, which is exactly why the response should start with secret containment, not content triage alone.

What practitioners should prioritise after the first hour

What to verify: confirm whether any exposed key is still valid, whether it has been reused elsewhere, and whether the database was accessible through obvious internet scanning. If the answer is uncertain, treat the key as compromised and revoke it anyway; delaying revocation to preserve convenience is usually the wrong trade-off here.

  • Rotate or revoke every key found in the exposed store, then check for near-identical copies in code, config, and CI/CD variables.
  • Search for logs, exports, and backups that may contain the same material.
  • Confirm whether any key has privileged downstream reach, especially write, delete, or billing-adjacent permissions.

What practitioners underestimate: the exposure window is often shorter than the investigation window. In published incident research, exposed credentials can be attempted quickly, so the team’s first success criterion is not perfect attribution, it is removing the attacker’s usable path before it is exercised. For a breach pattern that closely matches this scenario, review DeepSeek breach and LLMjacking: How Attackers Hijack AI Using Compromised NHIs.

Practitioner takeaway: the correct first move is to assume the exposed database contains active access material, not just leaked content, and to remove that access path before you spend time proving how widely the data spread.

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 and MITRE ATT&CK address the attack and risk surface, while CIS Controls v8 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-01 — Secret Management and Exposure PreventionExposed API keys and public database secrets are core NHI secret-sprawl risks.
NHI-03 — Rotation and RevocationThe question’s first step is immediate key invalidation after exposure.
NHI-07 — Discovery and InventoryTeams must search for additional secrets after finding one exposed database.
Recommendation — Revoke exposed keys and eliminate secret storage in public or reusable locations. Rotate compromised keys immediately and verify dependent systems still function. Inventory adjacent secrets, tokens, and credentials across code, config, and backups.
CIS Controls v86 — Access Control ManagementCompromised API keys require rapid removal of exposed access paths.
8 — Audit Log ManagementTeams need logs to scope use of the exposed database and keys.
16 — Application Software SecurityA public database exposing app secrets is an application-security failure mode.
Recommendation — Revoke exposed access paths and confirm least-privilege permissions on surviving accounts. Preserve and review logs to determine whether exposed credentials were used. Validate application storage paths so secrets are never written to exposed data stores.
MITRE ATT&CKT1552 — Unsecured CredentialsPublicly exposed API keys are classic unsecured credential exposure.
T1078 — Valid AccountsStolen API keys can be used as valid accounts for follow-on access.
Recommendation — Hunt for exposed credentials and remove any that can still authenticate. Assume exposed keys may enable valid-account abuse and monitor downstream usage.
NIST CSF 2.0RS.MA — MitigationThe response requires immediate containment and credential mitigation.
DE.CM — Continuous MonitoringTeams must verify whether the database was reachable and whether keys were used.
Recommendation — Contain the exposure quickly and remove the attacker’s usable access. Monitor for scanning, access attempts, and reuse of exposed secrets.

Deepen Your Knowledge

Sign up to our weekly newsletter — get 33% off our NHI Foundation Level Course

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