ShareSafeNote

Sharing code and config files without leaking secrets

5 min read · updated October 4, 2026

Sharing code is everyday work: a snippet for a colleague, a config file for a client's IT team, a stack trace for a vendor's support desk. The code itself is rarely the problem. What travels with it is: a password in a connection string, a token in a .env file, an authorization header in a copied request. Once those land in a pastebin, a chat channel or a screenshot, they are very hard to take back. This guide shows how to share code and configuration without leaking the secrets inside them.

Know where secrets hide

Secrets rarely sit in a file called "secrets". Before you share, check the usual hiding places:

  • .env files and config files such as appsettings.json, config.yaml or settings.py;
  • database URLs and connection strings that embed a username and password;
  • Docker Compose files, CI pipeline definitions and infrastructure templates;
  • private keys and certificates (.pem, .key, id_rsa) and cloud credential files in your home directory;
  • logs and stack traces that print request headers, cookies or full URLs with tokens;
  • commands copied from browser developer tools: "copy as cURL" usually includes your session cookies and authorization headers;
  • encoded values: base64 is an encoding, not encryption.

Redact before you paste

Replace every secret value with an obvious placeholder and keep everything else. The recipient still sees the structure, the variable names and the non-sensitive settings, which is usually all they need to help. A redacted file might look like this:

APP_ENV=staging
DATABASE_HOST=db.internal.example
DATABASE_USER=app_user
DATABASE_PASSWORD=YOUR_DB_PASSWORD
PAYMENT_API_KEY=YOUR_API_KEY
SMTP_PASSWORD=REDACTED
LOG_LEVEL=debug

  • Search for words like key, secret, token, password, pwd, auth and bearer, and for long random-looking strings.
  • Read long lines to the end; secrets often sit past the edge of the screen.
  • Check comments too. "Old password was…" is a classic.
  • If the recipient needs to know which key you mean, show the last four characters at most.
  • Use placeholders that are obviously fake. A realistic fake key can be mistaken for a real one, and the other way around.

Pastebins, gists and chat history are not private

Many paste sites make pastes public by default, and public pages can be crawled and indexed by search engines. They are also a known place to go looking for leaked keys. On several code-hosting platforms, a "secret" or "unlisted" snippet is simply not listed: anyone with the URL can open it, and URLs travel through browser history, bookmarks and forwarded messages.

Chat and email have a different problem: memory. Workspace chat history is often kept indefinitely, searchable by everyone in the channel, synced to phones and included in exports. Deleting a message later does not reach copies already made. Pasting a file into an online formatter, validator or assistant also sends it to a third party, so redact first there too.

Redacted code can go through your usual channels. The secret values themselves should travel separately, in a one-time encrypted note, as described in our guide on sharing passwords securely.

Screenshots and screen sharing show more than you think

A terminal screenshot can capture environment variables you printed a minute ago, a token typed on the command line, your user and host names, and whatever else is in the scrollback. Images end up in tickets and documentation, and many tools make the text in them searchable.

  • Clear the terminal or open a fresh one before reproducing the problem.
  • Crop to the lines that matter, then review the image at full size before sending it.
  • Prefer pasted text to images: text is easier to redact and to check.

Screen sharing has the same issue at a larger scale. Everyone in the call sees everything: notifications, other tabs, the .env file open in your editor's sidebar. If the meeting is recorded, that recording may be kept for a long time.

Walk through code live without sharing your screen

For a code review, a debugging session or a walkthrough in real time, a live code session is a narrower alternative to screen sharing. On ShareSafeNote, the host types or pastes code and viewers see it appear as it is typed, with syntax highlighting. The session is end-to-end encrypted with a key that sits in the link's fragment; the server only relays ciphertext, keeps content in memory and never on disk, and closes the session after at most six hours, or after two hours of inactivity.

The main benefit is scope: viewers see only the code you put in the session, not your desktop, your notifications or your other windows. Keep the limits in mind too. Viewers watch, they don't edit, so this is not a collaborative editor. Anyone with the link can see what you type, so share it only with the intended people and redact what you paste in.

Scan for secrets before they reach the repository

The most reliable way to avoid leaking a secret through code is to stop it before the commit. Pre-commit secret scanners run as a git hook, inspect your staged changes for patterns that look like credentials (known key formats, private key headers, long high-entropy strings) and block the commit if they find one.

  • Install a scanner as a pre-commit hook on every developer machine.
  • Run the same scan in CI on every push or pull request, as a second net.
  • When you adopt a scanner, scan the full history once, not only new changes.
  • Handle false positives with an allowlist rather than by disabling the scanner.
  • Keep .env and key files in .gitignore, and commit a .env.example with placeholders.
A net, not a guarantee: scanners catch common formats, not everything. A custom internal token can look like ordinary text. Keep reviewing your diffs before you push. If a secret does slip through, rotate it first and clean the history second, as explained in our guide on sharing API keys and credentials.

Most leaks are not sophisticated: they come from a file shared in a hurry. Make redaction a habit, keep secret values apart from code, and when you need to show code to someone live, start an encrypted live session instead of sharing your whole screen.

Share your next secret the safe way

Encrypted in your browser, read once, then gone. No account needed.

Create a secure note