GH-100 practice question 11 of 15

You discover that a secret (e.g., a token or password) was accidentally committed to a GitHub repository. What is the first step you should take to mitigate the risk?

Full set: 65 questions
Answer options
A: Contact GitHub Support to remove the secret from all forks and clones of the repository.
B: Revoke and/or rotate the secret to render it unusable, then assess whether history rewriting is necessary. Correct answer
C: Rewrite the repository history using git filter-repo or BFG Repo-Cleaner to remove the secret from all commits.
D: Delete the repository and create a new one to ensure the secret is no longer accessible.
Correct Answer:
B. Revoke and/or rotate the secret to render it unusable, then assess whether history rewriting is necessary.
Explanation

The immediate priority upon discovering an exposed secret is to invalidate it, thereby preventing any potential misuse. Revoking the token or rotating the password renders the compromised credential useless, which is the most critical first step in mitigating the security risk. Once the immediate threat is neutralized by invalidating the secret, you can then proceed with the secondary, but still important, task of removing the sensitive data from the repository's history. This two-step approach ensures that even if someone has already accessed the secret, it can no longer be used for unauthorized access.

Why Incorrect

A. Contacting GitHub Support is not the first action; you must first invalidate the secret yourself to immediately cut off access.
C. Rewriting history is a cleanup step. It does not invalidate the secret, which could have already been copied from clones or forks.
D. Deleting the repository is an extreme and disruptive measure that does not remove the secret from existing forks or local clones.

References

1. GitHub Docs, "Removing sensitive data from a repository." This official documentation explicitly states the first step after a secret is committed: "As soon as you commit a secret to a repository, you should consider the secret compromised. You should invalidate the secret...". The document then lists subsequent steps, including removing the file from history. This confirms that invalidation is the primary and initial action. (See the section: "Preventing unauthorized access").

2. GitHub Docs, "About secret scanning." This document outlines how GitHub helps detect secrets and emphasizes the importance of remediation. It states: "If a secret is detected... GitHub notifies the service provider who issued the secret. The service provider validates the credential and then decides whether they should revoke the secret, issue a new secret, or contact you directly." This process underscores that the first action is always to invalidate the credential. (See the section: "What happens when a new secret is detected?").

Scroll to Top