Amended commit can bypass the pipeline-policy-pre job
A pipeline execution policy that runs a job in the .pipeline-policy-pre stage to block pipelines on certain file changes can be bypassed by amending the last commit and force pushing. The amended push triggers a new pipeline in which the policy-pre job is skipped, so the remaining jobs run despite the policy.
GitLab
Originally disclosed on GitLab
- Fixed in 15 days
- Disclosed after 15 days
⚠️ Please read the process on how to fix security issues before starting to work on the issue. Vulnerabilities must be fixed in a security mirror.
HackerOne report #3353694 by j0v on 2025-09-22, assigned to GitLab Team:
Report | Attachments | How To Reproduce
Original Report
Summary
With the secure policies it is possible to add a pipeline policy. This makes it possible to create a pipeline job with the stage .pipeline-policy-pre, which is executed before all other pipeline jobs. This can be used to stop the pipeline from further execution when a condition is met. It is possible to bypass the .pipeline-policy-pre job and still execute the jobs in the rest of the pipeline by using git commit --amend.
In my PoC I added a pipeline policy which prevents any changes to the README.md file as example. So the use case is that the rest of the pipeline is not executed when someone changed the README.md file. In real life this can for example be used to block the run of other jobs when someone has changed files like the Makefile or the .gitlab-ci.yml file to prevent the execution of arbitrary commands during the build.
Steps to reproduce
As the security policies is a Ultimate feature, it is required to have a group in GitLab with a trial license. You can test it on GitLab Cloud at gitlab.com.
Prerequisites:
- A group with a trial license for Ultimate
Steps:
- Create a new blank project, I called it 'test-project'
- Create a pipeline (.gitlab-ci.yml) file; go to Build > Pipeline editor and click 'Configure pipeline'. I used the following pipeline for testing:
stages:
- test
testing:
stage: test
script:
- echo "Test 1..2..3.."
- Create a pipeline policy file. I created one on the same 'test-project' project, but normally this is located in a different project. For testing purposes I don't think this really matters. Go to Code > Repository and click New File. I named it 'policy.yml' and added the following content:
check-readme-changes:
stage: .pipeline-policy-pre
script:
- echo "You cannot change the README, failing now"
- exit 1
rules:
- changes:
- README.md
when: always
This security policy should fail the pipeline if the README.md is changed.
-
Enable the pipeline policy by going to Secure > Policies and click 'New policy'. Choose 'Pipeline execution policy', named it 'Block README change', select the 'test-project' and use 'policy.yml' as file path (see Screenshot_2025-09-22_at_14.47.44.png).
-
Click 'Create with merge request' and merge the merge request afterwards.
-
Now go back to the 'test-project' and clone it locally to your computer.
-
You can verify that the policy blocks the changes in README.md on the first commit:
echo $RANDOM > README.md
git add .
git checkout -b feature/test
git commit -m "Changed README"
git push -u origin feature/test
- Now amend the last commit and force push to the new branch. This will trigger a new pipeline, but the .pipeline-policy-pre stage is skipped.
git commit --amend
git push --force
First blocked pipeline: Screenshot_2025-09-22_at_14.51.52.png
Second amended commit: Screenshot_2025-09-22_at_14.52.42.png
Impact
If the pipeline policy is used to prevent further execution of a pipeline, this trick can bypass this policy. In a real world example someone can change the .gitlab-ci.yml file to run arbitrary commands at the build of the branch.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
- Screenshot_2025-09-22_at_14.51.52.png
- Screenshot_2025-09-22_at_14.47.44.png
- Screenshot_2025-09-22_at_14.52.42.png
How To Reproduce
Please add reproducibility information to this section:
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the amended push causes the policy-pre job not to be scheduled, so the stage is skipped.
Impact
A user who can push to a branch could bypass a pipeline policy intended to stop jobs, for example running arbitrary commands by changing the CI configuration file.
What the attacker needed
A group with an Ultimate trial licence; ability to push to a branch; a pipeline execution policy configured
How it was found
- Create a project with a basic pipeline file.
- Create a policy file whose .pipeline-policy-pre job fails when README.md changes.
- Enable the policy as a pipeline execution policy on the project and merge it.
- Clone the project, change README.md, commit and push a branch; confirm the pipeline is blocked.
- Amend the last commit and force push the branch.
- Observe the new pipeline runs without the policy-pre job.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
GitLab lets administrators attach security policies to projects. One kind runs a check job before everything else in a pipeline, and if that check fails the rest of the pipeline should not run. The researcher found that rewriting the most recent commit and pushing it again makes GitLab start a new pipeline without running that early check, so the jobs the policy was meant to stop still execute.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.