GH-100 practice question 9 of 15

What is the first step when sensitive data is accidentally pushed to a public GitHub repository?

Full set: 65 questions
Answer options
A: Revoke any exposed credentials immediately Correct answer
B: Force push a commit removing the data
C: Open an issue to inform users
D: Delete the repository
Correct Answer:
A. Revoke any exposed credentials immediately
Explanation

When sensitive data like credentials or API keys are exposed in a public repository, they must be considered compromised immediately. The first and most critical action is to invalidate the exposed secrets. This prevents malicious actors who may have already cloned, forked, or scraped the repository from using them. Revoking the credentials at their source (e.g., the service provider) is the only way to mitigate the immediate threat and prevent unauthorized access or damage. Steps to clean the repository's history are secondary and do not address the fact that the secret has already been exposed.

Why Incorrect

B. Force push a commit removing the data: This does not remove the data from the repository's history, nor does it invalidate the secret, which is already considered compromised.
C. Open an issue to inform users: This is a communication step that should occur after the immediate threat is contained by revoking the credentials. Informing users first could accelerate misuse.
D. Delete the repository: This is a destructive action that does not invalidate the exposed credentials and fails to address the core security risk from potential clones or forks.

References

1. GitHub Docs, "Removing sensitive data from a repository." In the section "Preventing unauthorized access," the documentation explicitly states: "As soon as you commit a secret to a repository, you should consider the secret compromised." It then lists the first recommended actions as revoking the specific type of credential, such as a personal access token, SSH key, or other API keys, before proceeding to remove the file from the repository's history.

2. Microsoft Docs, "Credential scanning - Azure DevOps." In the section on "Remediation," the official guidance for handling an exposed credential is: "The first step is to immediately rotate the exposed credential. Once that's done, you can revoke the old credential." This prioritizes invalidation over any other action.

3. Carnegie Mellon University, Software Engineering Institute, "SEI CERT C++ Coding Standard," STR51-CPP. Do not leak sensitive information. While focused on C++, the principle is universal. The remediation section for information exposure incidents emphasizes immediate invalidation of compromised secrets as the primary containment step. (Refer to general incident response principles for information exposure).

Scroll to Top