Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To make a GitHub user’s email private using the GitHub web console:
-
Sign in to GitHub
Log into the GitHub account whose email you want to make private. -
Open User Settings
- Click your profile picture (top-right corner).
- Click “Settings” in the dropdown.
-
Go to Email Settings
- In the left-hand menu, click “Emails”.
-
Hide your email address from public profile
Under “Primary email address” / “Email privacy”:- Check “Keep my email addresses private”.
- If available, also check “Block command line pushes that expose my email” to prevent your real email from appearing in commits.
-
Use GitHub-provided noreply email (recommended)
- Still under “Emails”, note the
@users.noreply.github.comaddress. - Optionally set it as your primary email if you want all GitHub operations to use this masked address where possible.
- Still under “Emails”, note the
-
Confirm profile visibility
- Go to Settings → Profile.
- Ensure the Email field is either empty or shows the noreply address, not your real email.
Using CLI
Using CLI
For GitHub, “making user email private” has two parts:
1. Get your GitHub noreply email (with
If you use email privacy, your primary public email will be something like:
For a single repo only:This prevents future commits from exposing your real email.
Make it executable:You can distribute this with:
Summary (CLI-focused “remediation”)
- Avoid exposing your real email in commits (git config)
- Use GitHub’s noreply email (per-user setting + git config)
gh to automate the rest.1. Get your GitHub noreply email (with gh)
12345678+username@users.noreply.github.comIf that doesn’t return the noreply, list all emails and pick the noreply one:2. Set noreply email as your global Git identity
Replace<NOREPLY_EMAIL> with the value from above:3. Block pushes that expose real email (per‑repo policy)
You can script a guard usinggh + git hooks.Create .git/hooks/pre-push:4. (Required via Web UI once per user) Turn on email privacy and blocking
This part cannot be fully done viagh today; it’s a one‑time user action:- GitHub → Settings → Emails
- Check “Keep my email address private”
- Check “Block command line pushes that expose my email”
Summary (CLI-focused “remediation”)
- Use
gh apito discover your noreply email. - Use
git config(scriptable and enforceable in your org) to set that asuser.email. - Optionally add
pre-pushhooks (distributed viagh repoflows) to block pushes that contain real emails.
Using Python
Using Python
Below are concrete steps and a Python example to remediate “User Email should be Private” for GitHub by removing (or replacing) the public email via the GitHub API.Important limitation:
GitHub does not let an org admin change a member’s profile email. Each user must do this themself using their own personal access token (PAT). The script below is meant to be run per user (or with that user’s token).
If you tell me how your scanner checks this (e.g., via GitHub API or UI), I can adjust the payload/logic to match that exact rule.
GitHub does not let an org admin change a member’s profile email. Each user must do this themself using their own personal access token (PAT). The script below is meant to be run per user (or with that user’s token).
1. Decide the desired state
You typically want no real email shown on the public profile. Two common options:-
Clear the public email (best for privacy):
- Set
emailtonull(or omit it) so the profile doesn’t show a public email.
- Set
-
Replace with GitHub’s noreply email:
- Format:
<id>+<username>@users.noreply.github.com - This is still an email but not a real one.
- Format:
2. Get a GitHub Personal Access Token (PAT)
For each user:- Go to Settings → Developer settings → Personal access tokens → Tokens (classic).
- Create a token with:
- Scope:
user(this is needed to update the profile).
- Scope:
- Copy the token (you’ll use it in the script as
GITHUB_TOKEN).
3. Python code to clear or replace public email
Option A: Clear public email
Option B: Set to GitHub noreply email
4. (Optional) Enforce noreply in Git commits
Even if the profile email is private, commits can still leak real emails. Each user should:- Set global Git config to noreply:
- In GitHub UI: Settings → Emails →
- Check “Keep my email addresses private”
- Check “Block command line pushes that expose my email” (if available)
If you tell me how your scanner checks this (e.g., via GitHub API or UI), I can adjust the payload/logic to match that exact rule.
Using Terraform
Using Terraform
Terraform cannot remediate this finding: the GitHub provider does not expose any resource or argument to manage a user’s primary email or its visibility setting.You must change this at the account level, either:
- Via GitHub UI:
Profile → Settings → Emails → set your primary email to “Keep my email addresses private”.
- Via GitHub API (as per the docs you linked), authenticated as the user, e.g.:
GET /user/emailsto list emails and find the primary one.PATCH /user/email/visibilitywith{"visibility": "private"}to toggle the primary email’s visibility.

