| "contents": "Subscribe \u00d7 EXPEL BLOG Connect Hashicorp Vault and Google\u2019s CloudSQL databases: new plugin! Engineering \u00b7 3 MIN READ \u00b7 DAVID MONTOYA AND ISMAIL AHMAD \u00b7 AUG 31, 2022 \u00b7 TAGS: Cloud security / Tech tools We take protecting credentials seriously, and database (DB) credentials are no exception. They\u2019re juicy targets for attackers and often hold the keys to all your sensitive information. Making sure they\u2019re short-lived, rotated, scoped, auditable, and aligned with zero trust principles is central to boosting an organization\u2019s security posture. As you may know from our previous post, 5 best practices to get to production readiness with Hashicorp Vault in Kubernetes , we\u2019re long-time users of Vault, which specializes in credential management and offers a large plugin ecosystem for different databases. Sounds like a slam dunk right? Not so fast. As we began to explore using Vault to manage credentials for our Google-managed CloudSQL instances, we found ourselves stuck between two less-than-ideal out-of-the-box options, forcing us to compromise on operational complexity or, worse, security. Caught between a rock and a hard place, we dug deeper and built a new tool to meet our requirements. We think it\u2019s broadly useful for organizations using Vault and Google CloudSQL. And now, the good news: Expel is excited to open source a new Hashicorp Vault plugin. It brokers database credentials between Hashicorp Vault and Google\u2019s CloudSQL DBs and it doesn\u2019t require direct database access (via authorized networks ) or that you run Google\u2019s CloudSQL auth proxy. If you\u2019re wondering how that\u2019s possible, the plugin uses Google\u2019s best practice for authentication via IAM rather than a standard database protocol. Sound like something you could use? The plugin codebase can be found in GitHub . Why build a custom plugin? To better understand why we built this plugin, let\u2019s look at some of the challenges posed by using Vault\u2019s default database plugins to connect to CloudSQL instances. Per Google\u2019s documentation , there are two primary ways of authorizing database connections. Option 1: use CloudSQL authorized networks Google allows users to connect to CloudSQL databases using network-based authentication. To improve the security posture of your DB, Google recommends enabling SSL/TLS to add a layer of security. This requires users to manage an allowlist of IP CIDRs and SSL certificates on both the servers and clients for the databases they wish to connect to. As you can see, this gets tedious quickly. Imagine you have hundreds of CloudSQL databases\u2026 no one wants to manage that many firewall rules or certificates. Option 2: use CloudSQL Auth proxy Google\u2019s recommended approach for connecting to CloudSQL instances is to use the Auth proxy . Its benefits include: Uses IAM authorization instead of network-based access control (no more firewall rules!) Automatically wraps all DB connections with TLS 1.3 encryption regardless of the database protocol As we started exploring approaches for connecting our Vault instances to CloudSQL databases, we contemplated using the cloudsql-proxy (but shuddered at the operational complexity of running such a specialized sidecar along with our Vault servers). Developing a Hashicorp Vault plugin So, how exactly did we end up writing our own Vault plugin? As we researched options, we landed on a GitHub issue that referenced an interesting new Go connector for CloudSQL . The Google Cloud team had recently released a generalized Go library for authenticating to CloudSQL databases the same way that their auth proxy does. Being Go developers, our interest really piqued\u2013could we use this new library to get the best of both worlds (low operational complexity and security best practice)? By creating a new Vault plugin based on Google\u2019s Go connector, we were able to integrate Vault with CloudSQL databases all while taking advantage of Vault\u2019s existing capability to create and manage database credentials. The plugin simply initiates the database connection using the new Go connector for CloudSQL instances and then delegates everything else to the community-supported Vault database plugin. How to use it Ok so you\u2019ve made it this far. You understand what problem the plugin is solving and how it\u2019s solving it. Now let\u2019s talk about how you use it. A step-by-step guide to building and deploying this plugin can be found here . Conclusion Although \u201cbuilding a new way\u201d often seems daunting, our journey with Vault and CloudSQL was rewarding and we hope our plugin will be useful to others facing similar issues. As we continue our journey, watch this space for future posts describing how to employ Vault as a database credential broker for workloads and audit across the stack. Finally, have a look: we\u2019ve posted a step-by-step guide on GitHub detailing how to set this up in your environment." |