Store Sensitive Data on GitHub

Published
Length
3 min read

Luis Felipe Dias

All posts

To store sensitive data on github safely, use encrypted action secrets instead of plain text files. You must never commit raw passwords or API keys into your source code history. Teams often set up repo secrets to hold database logins and cloud keys for automated builds. Still, broad role settings let any team member with write permissions trigger workflows using those keys. How to store sensitive data on github using native secrets GitHub offers a built-in secret store for repos, deployment

Single Sign-On (SSO) + GitHub Actions Security: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

To store sensitive data on github safely, use encrypted action secrets instead of plain text files. You must never commit raw passwords or API keys into your source code history. Teams often set up repo secrets to hold database logins and cloud keys for automated builds. Still, broad role settings let any team member with write permissions trigger workflows using those keys.

How to store sensitive data on github using native secrets

GitHub offers a built-in secret store for repos, deployment stages, and whole teams. You enter a key value in the web settings, and the platform encrypts it right away. Once saved, no user can read the raw text back from the web page. The platform decrypts the value only when an authorized build job runs on a worker machine.

The build runner loads the decrypted secret into memory as a temporary variable. Your build scripts can then read that variable to log in to external databases or cloud services. GitHub also scans build logs and masks known secret strings with asterisks. This basic setup keeps plain text passwords out of your git commit history.

Where native secret storage falls short in practice

Native secret storage solves the problem of keeping static keys out of source files. Still, it leaves a large security gap when builds or engineers run live commands. Repo permissions only check who can start a job or edit a workflow file. They do not inspect what the secret does once the job logs in to a database.

Any developer who can push code to a branch can edit the workflow steps. That person can write a script that prints the secret variable in base64 format to bypass log masking. Even without bad intent, a build script uses a shared key with broad database permissions. One faulty query in a script can drop a table or read customer emails and card numbers.

Single Sign-On (SSO) + GitHub Actions Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why static repository keys create audit blind spots

When a build job or local script uses a shared key, your database sees only one generic user. You lose track of which team member ran a specific query or changed a record. Rotating these keys takes manual work across many repos and team settings. If a key leaks, you must update every project that uses it one by one.

Secrets stored in git platforms also do not control data returned by a query. If a test job queries a live table, the result can expose phone numbers or national IDs. Securing the key at rest is only the first step in protecting production data. Teams also need controls that govern individual commands and mask sensitive fields in results.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can I commit encrypted files directly into a git repository?

Yes, you can encrypt files with a separate tool before you commit them to git. You still need a safe place to store the decryption key outside the repo code.

What happens if I push a password to a public branch by mistake?

You must treat that password as leaked right away and revoke it in your target system. Removing the file in a new commit does not erase it from past git history.

Who can edit encrypted secrets in a shared repository?

Users with admin roles on a repo can add, change, or delete repo secrets. Users with write roles can often run workflows that read those secrets during a build.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.