A JDBC connection string is how a Java application finds and opens a database. It names the driver, the host, the port and the database, and very often carries the user name and password too, either in the URL or in properties appended to it. Anyone who reads one that includes credentials can connect to the database directly from their own machine, as long as the server is reachable from the internet or from a network they can get into. That means reading, changing or deleting data, which is why this type is rated critical. Change the database password first, then investigate who connected.
Check your GitHub account for leaked secrets — free
- Provider
- Other
- Severity
- Critical
- Impact
- Payments and customer data
- Checked live by LeakWatch
- No
What a JDBC connection string looks like
A JDBC URL starts with jdbc:, then the name of the database driver, then ://, then the host and the rest. The exact layout depends on the driver, and some drivers use a subprotocol with extra segments:
jdbc:<driver>://<host>:<port>/<database>?user=<name>&password=XXXXXXXX
Credentials can appear in three places: in the query string (user= and password=), in the authority part (user:password@host), or not in the URL at all, with the user and password set in separate properties such as spring.datasource.username and spring.datasource.password. In that last case the URL alone is harmless and the password is a separate secret in the same file. The file names to search are application.properties, application.yml, persistence.xml, hibernate.cfg.xml, context.xml for Tomcat, and .env files read by build tools. Some cloud databases use a URL that already embeds a temporary token, which expires on its own but should still be treated as exposed until you check.
How JDBC connection strings get leaked
- Spring Boot configuration.
application.propertiesorapplication.ymlcommitted with the real datasource URL, user and password instead of placeholders. - ORM and servlet descriptors. Hibernate, JPA and Tomcat files that hold the URL inline, often copied from a working server.
- Docker and CI files. A compose file, Kubernetes manifest or pipeline definition that passes the URL as an environment variable written in clear text.
- Test fixtures. An integration test pointing at a shared staging or even production database, with the credentials left in the test resources.
- Logs and stack traces. A connection error printed with the full URL, then pasted into a ticket, a forum or a public issue.
- Build artifacts. A JAR or WAR checked in or published with its configuration inside.
What to do in the first hour
- Find out which database and which account. Read the host, port, database and user in the string. If only part of it leaked, find the matching entry in your configuration to see the rest.
- Change the password of that database user on the database server, or create a new user with the same rights and disable the old one. Doing this before anything else cuts off any session started with the leaked value for new connections.
- Deploy the new credentials to the application and its secret store, then check the application can still open connections.
- Close existing sessions. A password change does not always close connections that are already open. Use the server’s session list to terminate sessions opened by the old account that you do not recognize.
- Review the logs. Look at the database’s connection and authentication log, and at your cloud provider’s network and access logs, for logins from unknown addresses since the exposure. Look for large reads, new users, changed grants and dropped tables.
- Reduce exposure. If the database accepted connections from anywhere, restrict it to the addresses that need it. Give the application a user that has only the permissions it uses, not an administrator.
- Check what else the data holds. If the database stored personal or payment data, decide whether you must notify anyone, and rotate any secrets that were stored in its tables.
- Clean up the code. Remove the value from the repository and read secrets from the environment or a secret manager. See I accidentally pushed an API key to GitHub.
Not sure what else leaked from the same repository? Run a free scan.
Revoke it at your database provider
A JDBC string has no single vendor: it is a way to reach a database that you or a provider run. To invalidate it, change the password of the database user, or delete that user, on the database server itself, or in the console of your managed database service. See the documentation of your database for the exact statement or page. A person has not confirmed any menu wording for this guide, so look for the section where database users and passwords are managed, and follow your provider’s documentation. Remember that every application using the same user must receive the new password.
How LeakWatch detects it
The rule is called JDBC Connection String. It looks for the word jdbc:, then one or more lowercase letters or colons (the driver and subprotocol), then ://, then a run of letters, digits and the characters . - _ : ; = / @ ? , &. A string with an uppercase driver name, or one that stops right after ://, is not reported as a full match. The rule does not parse the URL and does not check that it contains a password, so a string with no credentials can still be reported, and a password written in a separate property is not seen. The severity is critical. This type is not checked live: LeakWatch never opens a connection to the host named in the string.
LeakWatch detects this format but does not check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.
FAQ
My connection string has no password in it. Do I need to act?
Check the same file for a separate password property. If there is none and the database refuses connections from the internet, the risk is low, but the host and database names still help an attacker, so restrict network access anyway.
Is a private database safe if its address is not public?
Not necessarily. A private address only protects you while the attacker cannot reach that network. Compromised laptops, VPN accounts or another leaked credential can bridge that gap, so change the password anyway.
Do I need to rewrite the git history?
Rotating the password is what makes the leaked value useless. Cleaning the history is good practice, but it does not undo copies that others already hold.