# Project Template functionality can be used to copy private project data, such as repository, confidential issues, snippets, and merge requests

Chaining three flaws in GitLab's custom project template flow let any user export and import a public project's restricted repo, confidential issues, and snippets into their own project.

- Payout: $12,000
- Severity: critical
- Program: GitLab
- Found by: jobert
- Disclosed: 2019-11-27
- Write-up quality: 9/10
- Original: https://hackerone.com/reports/689314
- Library page: https://bugbountylibrary.com/r/h1%3A689314
- Tags: area:web domain:web impact:data-leak impact:pii-leak kind:bounty platform:hackerone sev:critical tech:ruby technique:chained technique:source-review vuln:access-control vuln:business-logic vuln:privilege-escalation

**Target:** GitLab EE ProjectsController / CreateFromTemplateService / GitlabProjectsImportService
**Root cause:** validate_namespace_used_with_template returns early when project.group is nil, skipping authorization; ProjectsFinder returns public projects regardless of feature-level access; export job lacks authorization check.
**Steps:**
1. Create group (id 1) with public project `test_project`; set Repository/Issues/Wiki/Snippets visibility to Only Project Members.
2. As another user, POST /projects with `project[use_custom_template]=true`, `project[template_name]=test_project`, `project[group_with_project_templates_id]=1`, `project[namespace_id]=<attacker user namespace>`.
3. Server schedules export of victim project and imports into attacker's new project.
4. Wait for Sidekiq job; attacker project now contains victim repo, confidential issues, snippets, MRs, pipelines.
**How found:** Code reading of EE prepended controllers/services: noticed `return unless project.group` skips validation for user-namespace projects, then traced params through CreateFromTemplateService to ProjectsFinder and the export worker, spotting missing access-level and authorization checks.
**Exploitation:** Attacker submits crafted project-create request with use_custom_template=true and group_with_project_templates_id pointing at a public group whose project has restricted features. Validation is skipped because project is in a User namespace; ProjectsFinder returns the project despite feature-level restrictions; export job runs without re-authorization and imports data into attacker-controlled project.
**Escalation:** Chained three minor bugs (validation bypass, missing access-level check in ProjectsFinder, missing authz in export worker) into full data exfiltration of restricted project content.
**Insight:** When a validation method early-returns on a condition (e.g. `return unless project.group`), check whether the same params still flow into downstream services that assume validation ran; also audit async export/import workers for missing re-authorization (TOCTOU).

## Proof of concept (copied exactly from the original report)

**Modified project creation request with template params**

```
POST /projects HTTP/1.1
Host: instance
...

----------506740453
Content-Disposition: form-data; name="project[use_custom_template]"

false
----------506740453
Content-Disposition: form-data; name="project[template_name]"

----------506740453
Content-Disposition: form-data; name="project[group_with_project_templates_id]"

----------506740453
Content-Disposition: form-data; name="project[name]"

project_name
----------506740453
Content-Disposition: form-data; name="project[namespace_id]"

1
----------506740453
Content-Disposition: form-data; name="project[path]"

project_name
----------506740453--
```

