# AWS keys and user cookie leakage via uninitialized memory leak in outdated librsvg version in Basecamp

Outdated librsvg in Basecamp's SVG avatar preview leaked uninitialized heap memory, exposing AWS keys, session cookies, and Ruby config from the Rails process.

- Payout: $8,868
- Severity: high
- Program: Basecamp
- Found by: neex
- Disclosed: 2023-09-21
- Write-up quality: 9/10
- Original: https://hackerone.com/reports/2107680
- Library page: https://bugbountylibrary.com/r/h1%3A2107680
- Tags: area:web domain:web impact:data-leak impact:internal-access impact:pii-leak kind:bounty platform:hackerone sev:high tech:ruby technique:recon technique:source-review vuln:info-disclosure vuln:secrets-leak

**Target:** SVG avatar upload/preview pipeline (librsvg) on app.basecamp.com
**Root cause:** Outdated librsvg builds preview images from uninitialized malloc'd memory, and conversion runs in the same Unix process as the Rails app, so heap contents (configs, cookies, code) leak into rendered pixels.
**Steps:**
1. Generate malicious SVG via `python3 rsvgeb.py gen 260x260 --format bmp zalupa.png` (SVG filters chosen to survive re-encoding).
2. Upload as avatar in Basecamp profile and save.
3. Copy avatar image URL, follow redirect, replace `.avif` with `.png` and filename with `$RANDOM$RANDOM$RANDOM$RANDOM`.
4. Loop `curl "<url>$RANDOM$RANDOM$RANDOM$RANDOM.png?v=1" | python3 rsvgeb.py recover 260x260 - | strings -n 10` for hours to harvest leaked heap fragments.
5. Inspect output for AWS keys, cookies, Ruby source; validate keys with `aws sts get-caller-identity`.
**How found:** Researcher noticed Basecamp converts uploaded SVGs server-side, suspected an outdated librsvg with a known uninitialized-memory bug, and hypothesized the converter shares a process with Rails, so heap residue would leak into rendered pixels.
**Exploitation:** Attacker uploads crafted SVG avatar; server-side librsvg renders it, embedding uninitialized heap bytes into output pixels. Repeated requests with random filenames force fresh renders, accumulating leaked memory fragments (AWS creds, session cookies, config) which are decoded locally via the recover script.
**Escalation:** Leaked AWS keys granted S3 access (verified via sts get-caller-identity and s3 ls); leaked cookies enable session hijacking of other users.
**Insight:** When a target renders user-supplied images server-side, fingerprint the converter library version and test whether conversion shares a process with the app—uninitialized-memory bugs in image libs then become a memory disclosure oracle via pixel output.

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

**Command to generate malicious SVG avatar**

```
python3 rsvgeb.py gen 260x260 --format bmp zalupa.png
```

**Loop fetching avatar and recovering leaked memory**

```
while true; do curl "████$RANDOM$RANDOM$RANDOM$RANDOM.png?v=1" | python3 rsvgeb.py recover 260x260 - | strings -n 10 | tee -a pizda_hui_govno.txt; done
```

**AWS STS call verifying leaked keys**

```
$ AWS_DEFAULT_REGION=us-east-2 AWS_ACCESS_KEY_ID=████ AWS_SECRET_ACCESS_KEY=██████ aws sts get-caller-identity
{
    "UserId": "██████",
    "Account": "██████████",
    "Arn": "arn:aws:iam::██████:user/bc3-storage"
```

