Skip to content
All field notes

FIELD NOTES / THE GUIDE

How to Share .env Files Securely with Your Development Team

Most teams share API keys over Slack or email. Here's why that's a security risk, and how modern dev teams handle it properly.

Faris Chtatou

Senior Software & Cloud Engineer

Secure .env sharing: insecure Slack messages vs encrypted secret manager with access control

Every developer knows the drill. You join a new project, clone the repo, and see a .env.example file staring back at you. Then comes the Slack message: "hey, can someone send me the actual .env?"

That message is a security incident waiting to happen.

Why Sharing .env Files Over Slack Is a Problem

The .env file is where your application's most sensitive data lives: database passwords, API keys, OAuth secrets, payment provider credentials. These are the literal keys to your infrastructure.

When developers share these over Slack, email, or shared documents:

  • The secret leaves a permanent trail. Slack message history persists indefinitely. Email attachments get forwarded. Anyone with access to those channels can read your production credentials.
  • There is no audit trail. You have no idea who has a copy of what secret, or when it was last rotated.
  • Revocation is nearly impossible. When a developer leaves, do you know which secrets they received in DMs? Rotating every key is the only safe option, and it is expensive.
  • Accidents happen. Copy-paste errors, sending to the wrong person, posting in a public channel. It is not a question of if, but when.

What Your .env File Actually Contains

Let's be concrete about what we're protecting:

# Database: full read/write access to production data
DATABASE_URL=postgresql://user:password@prod-db.company.com/myapp

# Payment processing: someone with this can charge customers
STRIPE_SECRET_KEY=sk_live_51Hx...

# Cloud storage: grants access to all your user files
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

# Authentication: can create tokens on behalf of any user
CLERK_SECRET_KEY=sk_live_...

A single .env file shared in a Slack DM gives an attacker, or a disgruntled ex-employee, full access to your production system.

Evaluate the Alternatives You Already Have

Shared Google Doc or Notion page: Document permissions can restrict access, but credentials still live in a general-purpose document that readers can copy. Review sharing settings, account security, and how you will rotate copied credentials when access changes.

Password managers: An existing password manager may already fit your workflow. 1Password has an official CLI that can load secrets into environment variables when running a command or script. Evaluate its access setup, environment organization, and automation against your team's needs before adopting another tool.

Committing a .env file to a private repo: This is the worst option. Even if the repo is private today, it might not be tomorrow. Git history is permanent. Even after you delete the file, the secret remains in git log.

The Right Approach: A Dedicated Secret Manager

The correct solution is to store secrets in a dedicated system that:

  1. Encrypts sensitive values at rest and explains where decryption happens. Encryption alone does not prevent the vendor from accessing plaintext.
  2. Provides the access boundaries you need: verify whether permissions apply to organizations, projects, or individual environments.
  3. Documents its change and access records: check which actions are logged and whether previous values are retained.
  4. Blocks future retrieval after access removal: credentials already copied still need revocation or rotation at the issuing service.
  5. Organises by environment: separate configuration namespaces do not necessarily imply separate permissions.

Tools like AWS Secrets Manager and HashiCorp Vault solve this at the infrastructure level. For development teams that need something simpler, without the ops overhead of Vault, tools like Keyrua focus on team configuration sharing. Keyrua supports project assignments for accepted organization members, with admin and editor roles across a project's environments. Organization admins inherit access to every project; other organization members need an explicit assignment for each project. Its change history records secret writes, without previous values or read events. Review the security and access model and web quickstart before deciding whether it fits.

A Practical Migration Path

If you are currently sharing secrets in Slack, here is how to move to a proper solution:

Step 1: Audit your current secrets. List every service your application connects to and every credential it uses. This is your rotation checklist.

Step 2: Rotate everything. Before migrating, rotate all secrets. Assume your previous sharing method was compromised. This is the clean break you need.

Step 3: Set up your secret manager. Import your rotated secrets organised by environment. Configure access control: who needs what.

Step 4: Update your onboarding docs. New developers should never need to ask for credentials via Slack again. Access is granted through the platform.

Step 5: Add pre-commit hooks. Use tools like git-secrets or trufflehog to prevent accidental commits of secrets to your repository:

# Scan your repo for exposed secrets
trufflehog git file://. --since-commit HEAD --only-verified

The Onboarding Dividend

There is a surprising side effect of doing this correctly: onboarding becomes dramatically faster.

Instead of spending a developer's first day hunting for credentials across Slack history and asking colleagues, they get access to the secret manager and everything they need is immediately available, scoped to exactly what they should have.

Measure that benefit in your own team: time the next developer setup, confirm that they can retrieve the correct configuration, and check whether they repeat the workflow without help. An observed result is more useful than a generic onboarding-time promise.

Summary

Sharing .env files over Slack or email is not just a bad habit. It is a liability. Every shared credential is an uncontrolled copy of your production access with no expiry, no audit trail, and no revocation mechanism.

The fix is straightforward: use a dedicated secret management tool that encrypts at rest, controls access by role, and documents what its change history actually records.

Your future self, and your next security audit, will thank you.

LESS FRICTION. MORE TIME TO BUILD.

Put it into practice.

Give your next project a shared starting point. Try Keyrua with a dummy .env file.

With your permission, we use PostHog to measure visits and actions on our public website and sign-in/sign-up pages, including page exits, approved campaign tags, demo use, and account creation. We don’t record sessions, form inputs, or secret values. Your choice lasts 180 days. Read our privacy policy.