Description:

This check verifies that a GitLab project has Secret Detection configured in its CI/CD pipeline. Secret Detection automatically scans commits and repository history for accidentally committed sensitive data, such as API keys, passwords, tokens, and other credentials, before they can be exposed or exploited.


Rationale:

Developers occasionally commit secrets to a repository by mistake, whether through hardcoded credentials, configuration files, or copy-pasted code. Once committed, these secrets can remain exposed in the repository's history indefinitely, even if developers remove them from the current codebase later. Automated secret detection scans catch these exposures as part of the normal development workflow, allowing teams to identify and remediate them quickly rather than discovering them after they're exploited.


Impact:

  • Flag commits or merge requests containing suspected secrets for review.

  • Require developers to remove or rotate any detected secrets before proceeding.

  • Add scanning time to the CI/CD pipeline.

  • Significantly reduce the risk of credential leakage and unauthorized access resulting from exposed secrets.


Default Value:

Disabled By default, GitLab projects do not include Secret Detection in their CI/CD pipeline. It must be explicitly added via the project's .gitlab-ci.yml configuration or through GitLab's Security Configuration page.


Pre-Requisites:

  • Maintainer or Owner access to the project

  • An existing GitLab project


Test Plan:

  1. Sign in to GitLab at https://gitlab.com.

  2. Navigate to the target project.

  3. Select Secure → Security configuration.

  4. Locate the Secret Detection row under Security testing.

  5. Verify that Secret Detection is configured and included in the project's CI/CD pipeline.

  6. Alternatively, review the project's .gitlab-ci.yml file and confirm it includes the Secret-Detection.gitlab-ci.yml template.


Implementation Steps:

  1. Sign in to GitLab at https://gitlab.com.

  2. Navigate to the target project.

  3. Select Secure → Security configuration.

          

  1. Locate the Secret Detection row.

  2. Click "Configure with a merge request" to auto-generate a merge request adding the required CI/CD template.

  1. Review and merge the generated merge request.

  2. Confirm the pipeline runs successfully and includes the secret_detection job.


Backout Plan:

  1. Sign in to GitLab at https://gitlab.com.

  2. Navigate to the project's repository.

  3. Edit the .gitlab-ci.yml file.

  4. Remove the Secret-Detection.gitlab-ci.yml template include that was added as part of this remediation.

  5. Commit the change to the default branch.

  6. Confirm the pipeline runs successfully after the rollback.


Reference: