Subscribe to the Non-Human & AI Identity Journal

What breaks when third-party credentials are published in source code?

A public code leak becomes an access event when secrets remain valid after exposure. The breach risk is not limited to the repository. It extends to whatever server, cloud account, or API the secret unlocks. Teams need secret scanning, rapid revocation, and separate handling for third-party code contributions.

Why This Matters for Security Teams

Published third-party credentials turn source code into a live attack path, not just an intellectual property problem. Once a secret is committed, it can be copied, indexed, and tested against the target service long before anyone notices. That is why exposed API keys, tokens, and certificates must be treated as active access events. Current guidance from the OWASP Non-Human Identity Top 10 and NHIMG research on secret sprawl both point to the same operational reality: discovery without revocation is incomplete defence.

Security teams often underestimate the blast radius because the repository is only the disclosure point. The real exposure sits wherever the credential is accepted: SaaS APIs, cloud accounts, CI/CD runners, and partner services. NHIMG has also documented how quickly exposed credentials are abused in real environments, including a case where attackers attempted access within minutes of public exposure in the LLMjacking research. In practice, many security teams encounter compromise only after the third-party system logs show suspicious use, rather than through intentional secret hygiene.

How It Works in Practice

When a third-party credential lands in source code, the first question is not “who committed it?” but “what can this secret still do?” A practical response starts with automated secret scanning in developer workstations, pre-commit hooks, CI pipelines, and repository history. That must be paired with rapid revocation, because detection alone does not stop an attacker who already has the value. The best available pattern is short-lived, purpose-bound access instead of long-lived static credentials, as described in NHIMG’s Ultimate Guide to NHIs.

For third-party integrations, the safer model is to issue separate credentials per service, per environment, and where possible per deployment. That separation limits lateral movement when a token is exposed in one code path. It also reduces the risk of “shared secret” failure, where the same credential is reused across internal automation, vendor support tooling, and production workloads. The NIST SP 800-63 Digital Identity Guidelines reinforce the need for secure proofing and lifecycle controls, while OWASP’s NHI guidance pushes teams toward explicit ownership, rotation, and monitoring for machine identities.

  • Scan all new code, pull requests, build artifacts, and historical commits for secrets.
  • Revoke exposed third-party credentials immediately, then replace them with scoped, rotated values.
  • Use distinct secrets for each vendor, environment, and automation path.
  • Prefer dynamic or ephemeral credentials where the third party supports them.
  • Correlate repository findings with cloud and SaaS audit logs to confirm misuse.

These controls tend to break down when the third-party service lacks granular revocation, short TTLs, or usable audit logs, because teams cannot verify whether the exposed secret has actually been invalidated.

Common Variations and Edge Cases

Tighter secret handling often increases delivery friction, requiring organisations to balance developer speed against exposure reduction. That tradeoff becomes sharper in shared libraries, vendor SDKs, and build scripts where credentials are needed by many teams but owned by only one. Best practice is evolving, but there is no universal standard for how much third-party access should be embedded directly in application code versus injected at runtime.

One common edge case is a public repository that contains only a test credential. That still matters if the token points to a real tenant, a permissive sandbox, or a service account with production adjacency. Another is supply chain contribution: a contractor or upstream maintainer may add a secret accidentally, which makes code review important but not sufficient. NHIMG’s analysis of the Reviewdog GitHub Action supply chain attack shows how quickly automation can spread exposed secrets across workflows.

Teams should also expect exceptions where revocation is slow or impossible, such as legacy APIs, embedded devices, or vendor systems that still depend on static tokens. In those environments, compensating controls matter: network restrictions, IP allow-listing, stronger monitoring, and time-bound migration plans. The key lesson is that source-code exposure is not the end state. If the secret remains valid, the risk remains live.

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 OWASP Agentic AI Top 10 address the attack and risk surface, while NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP Non-Human Identity Top 10 NHI-03 Exposed secrets require rotation and lifecycle control for machine identities.
OWASP Agentic AI Top 10 Code-exposed credentials also enable agent and automation abuse when tools are reachable.
NIST CSF 2.0 PR.AC-1 Access control must cover third-party secrets that grant system entry.

Inventory third-party secrets, revoke exposed values fast, and replace static credentials with managed rotation.