Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Connection String
Cyber Security

Connection String

← Back to Glossary
By NHI Mgmt Group Updated October 31, 2026 Domain: Cyber Security

A connection string is a structured text value that tells an application how to reach a database or other data source. It often includes the host, database name, authentication method, and sometimes credentials. If stored in code or logs, it can expose both access details and the target system itself.

What a connection string is doing

A connection string is not just a convenience label, it is the configuration that tells software where to connect and how to authenticate. It often sits at the boundary between application code and data access, so mistakes in how it is built, stored or shared can turn a simple configuration value into an exposure point.

Because it can include both location details and access material, a connection string should be treated as sensitive operational data. In practice, it functions as a compact control plane for database access, which is why leakage, hardcoding or reuse can create immediate security consequences.

What typically appears in a connection string

The exact fields vary by database, driver and deployment pattern, but most connection strings express the same basic intent: reachability plus trust. They usually identify the endpoint, the database or service name, and some method of proving the application is allowed to connect.

In some environments that proof is embedded directly in the string, while in others the string points to a separate secret, token or integrated authentication method. That variation matters because the risk is not only in the text itself, but in what the text reveals about the system and what it enables if copied elsewhere.

For application teams, the important distinction is between a connection string as a routing/configuration value and a connection string that also carries reusable credentials. The second case has much higher exposure because compromise of the string can become compromise of the underlying data path.

Why connection strings become security-sensitive

Connection strings become sensitive when they are stored in source code, committed to repositories, printed in logs, exposed in error messages, or copied into tickets and reports. At that point they can disclose both the target system and the means to reach it, which helps attackers find valuable data stores and understand how the application is wired.

A practical example of this risk is Red Hat Consulting GitLab breach 2025, where customer reports exposed tokens, keys and database connection strings. The lesson is that a connection string is often more than metadata, because it can reveal enough context to accelerate follow-on abuse or targeted reconnaissance.

Where database access depends on static secrets embedded in text, the string itself may become a long-lived credential carrier. That is why many organisations prefer patterns that separate application code from secret material, reduce reuse, and narrow the blast radius if a string is discovered.

How teams should think about handling it

Connection strings should be treated as deploy-time secrets or secret-adjacent configuration, not as harmless text. The safest operational pattern is to keep them out of code, keep them out of logs, and store them in controlled configuration or secret management mechanisms with tight access boundaries.

That concern is especially clear in database-centric guidance such as the Database Credential and Access Security Guide, which covers connection strings alongside service accounts, dynamic database credentials and access governance. It is also reflected in the Database platform tokens guidance for leak response, where rotation and audit review become part of the response when database access material is exposed.

When a connection string must exist, the practical objective is to make it useful to the application while making it unhelpful to everyone else. That usually means constraining who can read it, limiting how long it remains valid, and ensuring that any exposure can be revoked quickly without breaking the whole service.

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 surface, NIST SP 800-53 Rev 5 sets the technical controls, and ISO/IEC 27001:2022 defines the regulatory obligations.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementConnection strings may carry reusable credentials that need controlled lifecycle management.
AC-6 — Least PrivilegeDatabase connection details should not grant broader access than the application needs.
AU-9 — Protection of Audit InformationConnection strings can appear in logs and reports, so log protection matters directly.
Recommendation — Protect embedded credentials with controlled issuance, rotation, and revocation practices. Limit database access paths to the minimum permissions required by the workload. Prevent sensitive connection details from being written to or exposed through audit records.
ISO/IEC 27001:2022A.5.15 — Access controlConnection strings govern access to protected data sources and must be access-controlled.
Recommendation — Restrict who can view, distribute, and modify connection configuration values.
OWASP Non-Human Identity Top 10NHI-02 — Secret LeakageConnection strings often contain secrets or secret-like access material and can leak through code or logs.
Recommendation — Keep connection strings out of source control, logs, and other unintended disclosure paths.

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 31, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org