# Improper bot-authentication allows to impersonate any user when sending messages in a room

Bot key parsing split on '-' yielded nil token, so `1-` matched any user with nil bot_token, letting unauthenticated attackers post messages as any user.

- Payout: $2,000
- Severity: high
- Program: Basecamp
- Found by: stackered
- Disclosed: 2025-11-21
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/3329310
- Library page: https://bugbountylibrary.com/r/h1%3A3329310
- Tags: area:web domain:web impact:integrity kind:bounty platform:hackerone sev:high tech:ruby technique:source-review vuln:access-control vuln:auth-bypass

**Target:** Campfire room message endpoint (bot authentication)
**Root cause:** authenticate_bot splits bot_key on '-' and queries find_by(id:, bot_token:); a key like `1-` yields bot_token=nil, matching users whose bot_token is nil (all normal users).
**Steps:**
1. Observe bot auth: `bot_id, bot_token = bot_key.split("-")` then `active.find_by(id: bot_id, bot_token: bot_token)`.
2. Note user IDs are incremental and visible in URLs.
3. Send `POST /rooms/2/2-/messages` with body message text, no auth cookie.
4. Message posts as user id 2 (nil bot_token match).
**How found:** Code review of the bot authentication function; noticed split on '-' can produce nil token, and that normal users have nil bot_token, so the find_by matches them.
**Exploitation:** Unauthenticated attacker guesses/enumerates a target user ID, sends POST to /rooms/<room>/<id>-/messages with arbitrary body; server matches user with nil bot_token and posts message attributed to that user in rooms they can access.
**Insight:** When auth compares a parsed credential against a DB column, check whether a malformed/empty credential yields nil and whether nil-valued columns (unset tokens) match — nil==nil in find_by is a common auth bypass.

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

**POST request impersonating user via empty bot token**

```
POST /rooms/2/2-/messages HTTP/1.1
Host: localhost:8000
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0
Accept: text/vnd.turbo-stream.html, text/html, application/xhtml+xml
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 193

Hello ! I'm the test user, even though I'm not authenticated
```

