# Attacker is able to create,Edit & delete notes and leak the title of a victim's private personal snippet

Changing noteable_type to personal_snippet in a project note POST bypasses project scoping, letting an attacker comment on any private personal snippet and leak its title via their activity feed.

- Payout: $1,730
- Severity: medium
- Program: GitLab
- Found by: cryptopone
- Disclosed: 2023-06-02
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/1751258
- Library page: https://bugbountylibrary.com/r/h1%3A1751258
- Tags: area:web domain:web impact:integrity kind:bounty platform:hackerone sev:medium tech:ruby technique:param-pollution technique:source-review vuln:access-control vuln:idor

**Target:** GitLab notes API endpoint /:namespace/:project/notes (NotesFinder / noteable_type parameter)
**Root cause:** NotesFinder#noteables_for_type returns PersonalSnippet.all for the personal_snippet type without any project or ownership scoping, so the noteable_id is never validated against the attacker's project.
**Steps:**
1. Victim creates a private personal snippet; note its ID (VICTIM_SNIPPETID).
2. Attacker creates a private project and an issue, then posts a comment and intercepts `POST /attacker/privateattackerproject/notes?target_id=6&target_type=issue` with body `{"note":{"noteable_type":"Issue","noteable_id":6,...}}`.
3. Change query to `target_type=personal_snippet` and `target_id=VICTIM_SNIPPETID`; resend.
4. Note is created on the victim's private snippet; response returns note id.
5. Attacker visits own profile activity page to read the leaked snippet title.
6. Edit via `PUT /attacker/privateattackerproject/notes/8` with body `{"target_type":"personal_snippet","target_id":VICTIM_SNIPPETID,"note":{"note":"test2"}}`; delete via `DELETE .../notes/<id>`.
7. Iterate sequential snippet IDs to harvest titles of all personal snippets.
**How found:** Code reading of notes_finder.rb revealed the personal_snippet branch returns PersonalSnippet.all with no project check, unlike issue/merge_request/snippet branches; hypothesis tested by flipping the noteable_type parameter in an intercepted note request.
**Exploitation:** Attacker with any private project posts a note whose noteable_type is switched to personal_snippet and noteable_id set to the victim's snippet ID; the server skips project scoping, creates the note, and the attacker's own activity feed renders the private snippet's title. Attacker can then edit/delete the note (as its owner) to cover tracks.
**Escalation:** Sequential snippet IDs allow enumerating titles of all personal snippets; public/internal attacker project with labels/references enables social engineering against the victim.
**Insight:** When a finder has a case branch that returns an unscoped `.all` while sibling branches scope by project, that branch is the IDOR: flip the type discriminator parameter to it and supply a foreign ID.

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

**POST note with target_type changed to personal_snippet**

```
POST /attacker/privateattackerproject/notes?target_id=VICTIM_SNIPPETID&target_type=personal_snippet HTTP/2`
1. Send the request and review the response. A new note will be created under the private snippet.
```

**PUT edit note retargeted to victim snippet**

```
PUT /attacker/privateattackerproject/notes/8 HTTP/2
Host: gitlab-pentest2.example.com
<Rest of headers>

{"target_type":"personal_snippet","target_id":3,"note":{"note":"test2"}}
```

**DELETE note on victim snippet**

```
DELETE /attacker/privateattackerproject/notes/7 HTTP/2
Host: gitlab-pentest2.example.com
<Rest of headers>
```

