Description
The swamp auth logout command only deletes the local ~/.config/swamp/auth.json file. It does not call any server-side API to revoke or delete the API key. The AuthCredentials interface stores an apiKeyId field (described as "The API key ID for revocation" in auth_credentials.ts:27), but it is never used.
Steps to Reproduce
- Run
swamp auth login to authenticate and create an API key
- Copy
~/.config/swamp/auth.json to a backup location
- Run
swamp auth logout
- Restore the backup
auth.json to ~/.config/swamp/auth.json
- Run
swamp auth whoami — the API key still works
Alternatively, read the source:
- Open
src/cli/commands/auth_logout.ts (lines 34-48)
- Observe it calls
repo.delete() which removes the local file only
- Search for any server-side revocation call:
grep -rn "revoke\|deleteApiKey\|delete.*api.key" src/
Returns nothing.
- Open
src/infrastructure/http/swamp_club_client.ts — no deleteApiKey or revokeApiKey method exists
Expected Behavior
swamp auth logout should revoke the API key on the server using the stored apiKeyId before deleting the local credentials file. After logout, the API key should no longer be accepted by swamp.club.
Actual Behavior
Only the local file is deleted. The API key remains valid on the server indefinitely. If an attacker has copied auth.json (via malware, backup exposure, or shared filesystem), running logout does not invalidate their copy.
// auth_logout.ts lines 34-48 — only local deletion
const repo = new AuthRepository();
const credentials = await repo.load();
if (!credentials) { /* already logged out */ return; }
await repo.delete(); // Only deletes ~/.config/swamp/auth.json
Impact
If a user's machine is compromised and the attacker copies auth.json, the user has no way to invalidate the stolen API key. Running swamp auth logout gives a false sense of security — the attacker retains access to swamp.club indefinitely. Additionally, each swamp auth login creates a new API key without revoking old ones, so stale keys accumulate on the server over time.
Summary of Fix
This affects auth_logout.ts and swamp_club_client.ts. The fix would involve:
- Adding a
deleteApiKey(apiKeyId) or revokeApiKey(apiKeyId) method to SwampClubClient that calls the BetterAuth API key deletion endpoint
- Updating
auth logout to call this method using the stored apiKeyId before deleting the local file
- Handling the case where the server call fails gracefully (still delete local file, but warn the user to revoke manually via the web UI)
- Optionally, listing and revoking old CLI API keys during
auth login for the same hostname
Environment
- swamp version: 20260225.011820.0-sha.4c63442a
- OS: All supported platforms
- Source commit: 4c63442
Description
The
swamp auth logoutcommand only deletes the local~/.config/swamp/auth.jsonfile. It does not call any server-side API to revoke or delete the API key. TheAuthCredentialsinterface stores anapiKeyIdfield (described as "The API key ID for revocation" inauth_credentials.ts:27), but it is never used.Steps to Reproduce
swamp auth loginto authenticate and create an API key~/.config/swamp/auth.jsonto a backup locationswamp auth logoutauth.jsonto~/.config/swamp/auth.jsonswamp auth whoami— the API key still worksAlternatively, read the source:
src/cli/commands/auth_logout.ts(lines 34-48)repo.delete()which removes the local file onlysrc/infrastructure/http/swamp_club_client.ts— nodeleteApiKeyorrevokeApiKeymethod existsExpected Behavior
swamp auth logoutshould revoke the API key on the server using the storedapiKeyIdbefore deleting the local credentials file. After logout, the API key should no longer be accepted byswamp.club.Actual Behavior
Only the local file is deleted. The API key remains valid on the server indefinitely. If an attacker has copied
auth.json(via malware, backup exposure, or shared filesystem), running logout does not invalidate their copy.Impact
If a user's machine is compromised and the attacker copies
auth.json, the user has no way to invalidate the stolen API key. Runningswamp auth logoutgives a false sense of security — the attacker retains access toswamp.clubindefinitely. Additionally, eachswamp auth logincreates a new API key without revoking old ones, so stale keys accumulate on the server over time.Summary of Fix
This affects
auth_logout.tsandswamp_club_client.ts. The fix would involve:deleteApiKey(apiKeyId)orrevokeApiKey(apiKeyId)method toSwampClubClientthat calls the BetterAuth API key deletion endpointauth logoutto call this method using the storedapiKeyIdbefore deleting the local fileauth loginfor the same hostnameEnvironment