Skip to main content

Triage and Remediation

Remediation

Using Console

To make a GitHub user’s email private using the GitHub web console:
  1. Sign in to GitHub
    Log into the GitHub account whose email you want to make private.
  2. Open User Settings
    • Click your profile picture (top-right corner).
    • Click “Settings” in the dropdown.
  3. Go to Email Settings
    • In the left-hand menu, click “Emails”.
  4. 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.
  5. Use GitHub-provided noreply email (recommended)
    • Still under “Emails”, note the @users.noreply.github.com address.
    • Optionally set it as your primary email if you want all GitHub operations to use this masked address where possible.
  6. Confirm profile visibility
    • Go to Settings → Profile.
    • Ensure the Email field is either empty or shows the noreply address, not your real email.
If this is for an organization policy, you cannot centrally force all members’ email addresses to be private via IAM alone; each user must perform the above steps on their own account. You can, however, document this as a security requirement and verify via profile checks or audits.
For GitHub, “making user email private” has two parts:
  1. Avoid exposing your real email in commits (git config)
  2. Use GitHub’s noreply email (per-user setting + git config)
GitHub does not currently expose the “Keep my email address private” toggle as a GitHub CLI command, but you can fully remediate exposure in Git and use gh to automate the rest.

1. Get your GitHub noreply email (with gh)

If you use email privacy, your primary public email will be something like: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:
For a single repo only:
This prevents future commits from exposing your real email.

3. Block pushes that expose real email (per‑repo policy)

You can script a guard using gh + git hooks.Create .git/hooks/pre-push:
Make it executable:
You can distribute this with:

4. (Required via Web UI once per user) Turn on email privacy and blocking

This part cannot be fully done via gh today; it’s a one‑time user action:
  1. GitHub → SettingsEmails
  2. Check “Keep my email address private”
  3. Check “Block command line pushes that expose my email”
After you do that once, the CLI + git config setup above will ensure ongoing compliance.
Summary (CLI-focused “remediation”)
  • Use gh api to discover your noreply email.
  • Use git config (scriptable and enforceable in your org) to set that as user.email.
  • Optionally add pre-push hooks (distributed via gh repo flows) to block pushes that contain real emails.
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).

1. Decide the desired state

You typically want no real email shown on the public profile. Two common options:
  1. Clear the public email (best for privacy):
    • Set email to null (or omit it) so the profile doesn’t show a public email.
  2. Replace with GitHub’s noreply email:
    • Format: <id>+<username>@users.noreply.github.com
    • This is still an email but not a real one.
If your scanner says “User Email should be Private,” either clearing it or switching to noreply will usually satisfy the requirement.

2. Get a GitHub Personal Access Token (PAT)

For each user:
  1. Go to Settings → Developer settings → Personal access tokens → Tokens (classic).
  2. Create a token with:
    • Scope: user (this is needed to update the profile).
  3. 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:
  1. Set global Git config to noreply:
  2. In GitHub UI: Settings → Emails →
    • Check “Keep my email addresses private”
    • Check “Block command line pushes that expose my email” (if available)
This must be done per user; there is no GitHub API for those checkboxes right now.
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.
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”.
or
  • Via GitHub API (as per the docs you linked), authenticated as the user, e.g.:
    • GET /user/emails to list emails and find the primary one.
    • PATCH /user/email/visibility with {"visibility": "private"} to toggle the primary email’s visibility.