# Initial mirror user can be assigned by other user even if the mirror was removed

Stale project.mirror_user persisted after mirror removal let a maintainer set another user as mirror author, enabling a persistent backdoor push channel.

- Payout: $3,000
- Severity: medium
- Program: GitLab
- Found by: sky003
- Disclosed: 2020-08-26
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/819821
- Library page: https://bugbountylibrary.com/r/h1%3A819821
- Tags: area:web domain:web impact:integrity impact:privesc kind:bounty platform:hackerone sev:medium tech:ruby technique:source-review vuln:access-control vuln:business-logic

**Target:** GitLab pull repository mirror settings (safe_mirror_params / mirror_user)
**Root cause:** Removing a mirror does not clear the project.mirror_user association, so valid_mirror_user? still accepts the stale user id as a valid mirror author.
**Steps:**
1. Login as maintainer A, create a pull mirror on the project.
2. Remove the mirror; project.mirror_user remains persisted.
3. Login as maintainer B, open Settings > Mirroring repositories.
4. Create a new pull mirror with `mirror_user_id` set to A's id; validation passes because A is in default_mirror_users.
5. Point the mirror at an attacker-controlled repo so commits are attributed to A.
**How found:** Code reading of safe_mirror_params.rb: noticed default_mirror_users includes project.mirror_user even when no mirror exists, contradicting the documented 'assign only yourself' rule.
**Exploitation:** Temporary maintainer creates a pull mirror whose mirror_user is the permanent maintainer, pointing at an attacker-controlled repository. Even after the temporary maintainer is removed from the project, the mirror keeps pulling attacker commits attributed to the permanent maintainer, giving persistent maintainer-level push.
**Escalation:** Persistence beyond removal of the attacker's project membership via the stale mirror_user attribution.
**Insight:** When access-control checks derive allowed values from persisted associations, verify those associations are cleared on delete; stale foreign keys become authorization bypasses.

