Repository navigation
Remove the DELETE /api/messages/{id} endpoint - #70
Merged
Atharva0506 merged 9 commits intoOct 26, 2026
Merged
Conversation
The rate limiter keyed on the leftmost X-Forwarded-For entry, or X-Real-IP, both of which the client controls. Sending a different value on every request gave a fresh bucket each time, so the limit never applied. Add security.trusted_proxies (RELAY_SECURITY_TRUSTED_PROXIES). At 0, the default, forwarding headers are ignored and requests are limited by the connecting address. At N, the client IP is the Nth X-Forwarded-For entry from the right, the last one written by a trusted proxy; entries further left are never read. X-Real-IP is no longer consulted. Deployments behind a proxy must now set trusted_proxies, otherwise every client shares the proxy's bucket. README covers this for Nginx, Cloudflare Tunnel and hosting platforms.
Every read returned the whole mailbox, so clients re-downloaded and
deduplicated everything on each poll. Each message now gets a seq, its
position in the recipient's mailbox, and GET /api/messages/{address}
accepts ?after=<seq> and ?limit=<n> so a client can fetch only what it has
not handled yet. Without the parameters the endpoint behaves as before.
Sequence numbers come from a per-mailbox counter in a separate mailboxes
table rather than MAX(seq)+1, so deleting or purging the newest message
can never cause its number to be handed out again and a client's cursor
never skips a message. Transactions use BEGIN IMMEDIATE so concurrent
sends to one mailbox cannot read the same counter. Existing databases are
migrated on startup: messages are numbered per mailbox in arrival order.
Message IDs are now the hex SHA-256 of the length-prefixed to, from and
payload instead of a random UUID. Resending an identical message stores
nothing new and returns the existing one with 200 instead of 201, so a
send is safe to retry. This drops the google/uuid dependency.
Number migrated messages by created_at then rowid instead of created_at then id. created_at only has one-second precision and the old IDs are random UUIDs, so messages that arrived in the same second were numbered in random order. rowid follows insertion order. The migration test now includes two same-second rows whose IDs sort against arrival order; it fails with the old ordering. Document that a non-zero trusted_proxies is only safe when the relay is reachable solely through the proxy, since a direct client controls X-Forwarded-For. Point out that the bundled docker-compose.yml publishes the port on all interfaces, and clarify what Cloudflare's entry is.
Release notes: - docs/releases/v1.0.0.md: highlights, how it works and architecture diagrams, getting started, upgrade notes and known limitations. - CHANGELOG.md in Keep a Changelog format. The release workflow never produced a release: - On the template's initial commit it tagged v1.0.0 and then failed, because Release Drafter had no draft yet. With no published release as a baseline, Release Drafter afterwards only kept an empty "v0.0.1, No changes" draft, and version-release.yml would have published whatever draft it found first. - Tags pushed with GITHUB_TOKEN do not trigger other workflows, so the tag-triggered Docker and GoReleaser builds never ran for a release. version-release.yml now runs when VERSION or docs/releases/ changes on main, or by hand. It skips versions that are already published, tags the commit (or reuses a tag an interrupted run left on the same commit), publishes a release whose body is docs/releases/vX.Y.Z.md followed by GitHub's generated "What's Changed", and dispatches docker-publish.yml on the tag. Release Drafter is replaced by .github/release.yml, which groups the generated list by label. GoReleaser is now manual-only: .goreleaser.yaml is still the unconfigured template, and releases ship as Docker images for now. Also adds a Releasing section to CONTRIBUTING.md and fixes the README architecture diagram, which was missing the CORS middleware.
Release notes are now written as a GitHub draft release named vX.Y.Z. When VERSION changes on main, or the workflow is run by hand, version-release.yml tags the commit and publishes that draft on the tag, appending GitHub's generated "What's Changed" list unless the draft already has one. Without a matching draft it still publishes, with the generated list only. The v1.0.0 notes moved from docs/releases/v1.0.0.md into a draft release on GitHub; CHANGELOG.md and CONTRIBUTING.md point there instead.
DELETE did not check who was asking, and GET /api/messages/{address}
returns every message ID in a mailbox, so anyone could delete any user's
messages before they were read (security review finding 1). Nothing uses
it: none of Chainvoice's branches calls the relay's delete, and no other
project uses ThruBox yet.
Messages now leave the relay only by expiring (ttl_days). With
ttl_days: 0 they are kept forever, so the server now logs a warning for
that setting. Removes the handler, Store.DeleteMessage, DELETE from the
CORS allowed methods, and the endpoint from the README, config comments
and changelog. The sequence-number reuse test now purges the newest
message instead of deleting it, and a new test checks that DELETE gets
405 and leaves the message in place.
Reverts e35198e on this branch. The removal will be reviewed and merged separately, after this pull request.
DELETE did not check who was asking, and GET /api/messages/{address}
returns every message ID in a mailbox, so anyone could delete any user's
messages before they were read (security review finding 1). Nothing uses
it: none of Chainvoice's branches calls the relay's delete, and no other
project uses ThruBox yet.
Messages now leave the relay only by expiring (ttl_days). With
ttl_days: 0 they are kept forever, so the server now logs a warning for
that setting. Removes the handler, Store.DeleteMessage, DELETE from the
CORS allowed methods, and the endpoint from the README, config comments
and changelog. The sequence-number reuse test now purges the newest
message instead of deleting it, and a new test checks that DELETE gets
405 and leaves the message in place.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 46 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
4 of 6 tasks
Contributor
3 of 6 tasks
Atharva0506
marked this pull request as ready for review
October 26, 2026 07:23
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addressed Issues:
No separate issue. This closes Finding 1 of the 2026-09-23 security review ("Any caller can delete any user's messages") and Issue 1 from the security discussion on Discord.
Screenshots/Recordings:
N/A. Covered by tests; see below.
Additional Notes:
Why:
DELETE /api/messages/{id}did not check who was asking, andGET /api/messages/{address}returns every message ID in a mailbox. So anyone who knew a wallet address could delete every message sent to it before the recipient read them. I reproduced this locally: every delete returned 204 and the mailbox came back empty.Who uses it: nobody. None of Chainvoice's 94 branches calls the relay's delete; it leaves messages to expire. No other AOSSIE project uses ThruBox yet. The TypeScript SDK's
delete()is removed in AOSSIE-Org/ThruBox-Client#65.What changes:
HandleDelete,Store.DeleteMessageand its SQLite implementation, andDELETEfrom the CORS allowed methods.DELETEnow gets 405 Method Not Allowed from the router. A new test,TestNoDeleteEndpoint, checks this and that the message is still there.ttl_days). Withttl_days: 0they are kept forever, so the server now logs a warning for that setting, and the README andconfig.yamlsay so.CHANGELOG.md(a Security entry) andBestPracticesChecklist.mdare updated.Design note: Bruno suggested on Discord that delete could be useful for other ThruBox use cases. This doesn't rule that out. Authenticated deletion (for example a wallet signature over the message ID) can be added back later as a new, non-breaking endpoint. Shipping 1.0.0 with an unauthenticated delete would make it part of the stable API.
go vet ./...is clean andgo test -race ./...passes.AI usage: Claude Code (Claude Opus 5.5) helped with this change and its tests. I reviewed the diff and ran the tests locally.
Checklist
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.