DMCA / abuse-notice service for the Webtor platform.
It does three things behind a single gRPC API:
- Stoplist for illegal content. Reports with
cause = ILLEGAL_CONTENTorINTIMATE_IMAGEare persisted, each ban with its kind (CSAM, a risk class, copyright, intimate image, malware, other), andtorrent-storecallsCheck(by infohash and by payload fingerprint) to refuse a reported torrent everywhere downstream. With--form-confirm, such a report from the web form waits until its reporter confirms it by email. - Mail relay. Every accepted notice (illegal content, malware, app error, generic question) generates a support email and, when the reporter provided a return address, an acknowledgement.
- Cleanup fan-out via NATS. Once a ban's purge is due (CSAM and risk-class bans at once, the others after
--purge-delay, default 72h, unlesspurge_now), whichever cause banned it, it publishesresource.bannedsoweb-uiandvaultpurge data tied to the banned infohash. The block itself is immediate; the delay leaves time to review a report before data is irreversibly deleted.
gRPC client ──► Push / Check ─┬─► PostgreSQL (source of truth, persisted abuses)
├─► BadgerDB (in-memory hot cache, rebuilt from PG on boot)
├─► Mailer ──► SMTP ──► support + reporter
└─► NATS ──► resource.banned ──► web-ui / vault cleanup
- PostgreSQL stores the canonical abuse records (
migrations/1_abuse.up.sql). - BadgerDB at
/tmp/badgerholds an infohash-keyed cache used byCheck. It is loaded from the fullabusetable on startup (Store.Sync) and refreshed every--sync-intervalminutes — this is the only mechanism that propagates inserts and deletions between replicas (a deleted row stops blocking within one interval), so don't expect sub-second cross-pod consistency. - SMTP delivery is best-effort and runs in goroutines; failures are logged but don't fail the RPC.
Defined in proto/abuse-store.proto, served on two listeners:
| Listener | Bind | Serves | Who uses it |
|---|---|---|---|
public, --grpc-port (50051) |
--grpc-host; the Kubernetes Service |
Push (copyright and intimate-image kinds only; purge_now ignored; form notices held with --form-confirm), Check, Confirm; Exempt and Lift are UNIMPLEMENTED |
web-ui (DMCA form, its confirmation page), torrent-store (Check), the automated intake of forwarded abuse reports |
admin, --admin-port (50052; 0 disables it) |
127.0.0.1 inside the pod only |
Push of every kind, with purge_now honoured, Check, Exempt, Lift, Confirm |
the CSAM ban script of the platform's monitoring agent, and owner decisions |
The admin port has no Service port and no containerPort. It is reached with kubectl port-forward deploy/abuse-store <local>:50052, so its access control is Kubernetes RBAC (pods/portforward or exec in the namespace). It carries the calls that override an earlier decision: an immediate ban beats an exemption, and an exemption or a lift removes a ban.
Push(PushRequest) → PushReply— submit an abuse notice naminginfohashand, optionally, moreextra_infohashes. Each hash must be a full 40-character hex infohash (case and surrounding whitespace are normalized), repeats are dropped,emailis validated, CR and LF are dropped fromsubjectandnotice_id;notice_idandstarted_atdefault to a fresh UUID and the current time. OnlyILLEGAL_CONTENTandINTIMATE_IMAGEcause a database write (reporter_name,good_faithandauthorizedare kept on the rows);CSAM_REPORTis mailed to support only, with its subject prefixed[CSAM report], and never stored or banned, from any port or source. A write is one row per hash not yet blocked, or blocked but not with this kind and fingerprint (see Ban kinds), under the samenotice_id, purged after--purge-delay. On the admin port,purge_now = truepurges at once and brings forward a pending purge of an already-blocked hash; the public port ignores it (the delay applies, and the server logs a warning). A notice whose every hash is a repeat (already blocked with the same kind and fingerprint), and that brought no pending purge forward, is rejected withALREADY_EXISTSand mailed to no one; a repeat report without an immediate purge publishes nothing. A hash markedexemptin the table absorbs ordinary reports: they are mailed as usual (the reporter is told it is under moderation, support sees it marked[exempt]) but neither stored nor fanned out.purge_nowon the admin port beats any exemption, set by hand or withExempt: in one transaction it clears the exemption, brings every pending purge of the hash forward and stores its row, then publishes, and support is told "an exemption was overridden by an immediate ban". A server with--purge-delay 0purges every report at once but does not override exemptions. One letter goes to support and at most one to the reporter per notice, listing every hash; the reporter gets none for a kind only the admin port takes (CSAM, risk class, malware, other).Confirm(ConfirmRequest) → ConfirmReply— confirms a notice held by--form-confirmwith thettoken of its link.CONFIRMED(andhashes, the number of infohashes) stores and mails it asPushwould have;ALREADY_CONFIRMEDfor a token used before,EXPIREDfor one not used within 72 hours,UNKNOWNotherwise, including an expired one after the next sync dropped it. Served on both ports.Check(CheckRequest) → CheckReply— returnsexists = trueif the infohash is in the stoplist (Badger lookup). Deleting a row or settingexempt = truelifts the block at the next sync;ExemptandLiftlift it at once.Exempt(ExemptRequest) → ExemptReply— admin port only. A hash with a CSAM or risk-class ban is never exempted:FAILED_PRECONDITION, lift it instead. Otherwise setsexempton exactly the rows ofinfohashit checked, and only while its ban is in the review window: it has rows, and every non-exempt one has apurge_afterstill ahead. The block lifts at once on the replica that serves the call, fingerprint included (other replicas follow at their next sync), and the purge never goes out.rowsis the number of rows changed, 0 if the hash was already exempt. Apurge_nowban, a row from before the purge delay (purge_afterNULL) or a ban whose purge is due is refused withFAILED_PRECONDITION; an unknown hash isNOT_FOUND. Those bans are exempted by hand in the database. Every exemption that changed rows is mailed to support as[exempt] <hash> — <reason>and journaled withactor(one of--actors, or empty) andreason.Lift(LiftRequest) → LiftReply— admin port only. Removes a ban outright, of any kind and in any window: the rows ofinfohash, or the fingerprint-only rows offingerprint(exactly one of the two, and areason, elseINVALID_ARGUMENT; nothing to remove isNOT_FOUND). An exempt infohash blocks nothing and isFAILED_PRECONDITION: its exemption is an owner decision, and nothing is removed. Rows of other infohashes with the same fingerprint are other reports of the same content and are left alone;still_blocked_rowsandstill_blocked_kindssay how many of them still block it, and of what kinds. They are found through the fingerprints on the removed rows:payload_knownis false when there were none (a ban pushed without a fingerprint, as form bans are), and then 0 means unknown, not that nothing else blocks the content.rowsis the number of rows removed;purgedsays the data purge had already gone out, and that data does not come back. The block lifts at once on the replica that serves the call (others at their next sync); a later ban of the hash purges again. A ban of the target that lands while the call runs makes itABORTEDwith nothing removed. Every lift is journaled and mailed to support as[lift] <target> — <reason>.
PushRequest.kind is the kind of ban (cause stays the kind of report: it routes the letters and decides whether anything bans). risk_class names the class for KIND_RISK_CLASS (one of --risk-classes), and actor who is asking (one of --actors, or empty).
| Kind | Port | Data purge | Exempt |
|---|---|---|---|
CSAM, RISK_CLASS |
admin only | always at once, as purge_now |
never (Lift removes it) |
MALWARE, OTHER (work = the reason) |
admin only | as asked | inside the window |
COPYRIGHT, INTIMATE_IMAGE |
both | --purge-delay; purge_now on the admin port |
inside the window |
- Without a kind, the public port infers it from the cause (
ILLEGAL_CONTENT→ copyright,INTIMATE_IMAGE→ intimate image) and the actor from the source (form,mail-intake), so existing callers need no change. Another kind there isPERMISSION_DENIED. The admin port stores a ban without a kind as unspecified and logs a warning;--require-kindrefuses it, exceptpurge_nowof hashes that all block already, which only brings their purge forward. A kind on a cause that bans nothing isINVALID_ARGUMENT. - Repeats: a hash that already blocks gets no new row when it has a row of the same kind and risk class and already carries the fingerprint; a new kind or fingerprint is stored, also for a form notice held by
--form-confirm(decided by the same rule before it is held, and again once confirmed). A report without a kind is never another kind, and a kind the public port inferred matches a ban from before kinds with the same cause, so unchanged callers' repeats stay silent. Fingerprint-only bans dedup on fingerprint and kind. - Journal: every decision (
ban,repeat,purge_advanced,override,absorbed,exempt,lift,held,confirmed,purge_published,expired,vanished,inserted) goes into the append-onlyban_eventtable in the same transaction.purge_publishedis everyresource.bannedpublish; Sync journalsexpiredfor a held notice that ran out and, with actoroutside,vanishedandinsertedfor rows deleted or added by hand outside the service. A report that bans nothing is journaled asreportwith its cause, source, port and number of hashes only, never the hashes or its text.
--form-confirm (FORM_CONFIRM, default false; off, nothing changes) holds an ILLEGAL_CONTENT or INTIMATE_IMAGE Push that arrives on the public port with source = FORM. source = MAIL and the admin port ban as before.
- A held takedown (
ILLEGAL_CONTENT) needsemail,reporter_name,good_faithandauthorized;INTIMATE_IMAGEneedsemail. OtherwiseINVALID_ARGUMENT. One whose every infohash would be a repeat (see Ban kinds: already blocked with the same kind and fingerprint) isALREADY_EXISTSand mailed to no one, as without the flag; another kind on a blocked hash is held like a new hash. - It is stored in the
unconfirmed_noticetable, never inabuse, so it blocks nothing and nothing that readsabuse(the cache,Check, the fan-out,Exempt, review queries) needs a new filter. The token is 32 random bytes, kept only as its sha256. - The reporter gets one letter, sent before
Pushreturns: subjectConfirm your report <notice id>, a fixed body with the link<--confirm-url>?t=<token>(CONFIRM_URL, defaulthttps://webtor.io/support/confirm), the number of torrents, their infohashes and the 72-hour expiry, and nothing else the caller typed. The reply hasconfirmation_sent = true; support hears nothing yet. A letter that cannot be sent isUNAVAILABLE. - At most 3 held notices per address and 200 in all per 24 hours, else
RESOURCE_EXHAUSTED. - The page behind the link must confirm on
POSTonly: mail scanners and link previewers open every link they see, and a confirmingGETwould confirm every notice for the reporter. Confirmapplies a notice once, however many times or on however many replicas it is called; a failed one can be retried. Each sync deletes held notices past their expiry.
- The public
Pushis unauthenticated: anything that reaches the Service can ban any infohash. The block is immediate; the purge waits out the delay, so a reviewer can still exempt it in time.--form-confirmtrusts the caller'ssource: it guards the web form, not a caller that reaches the Service and saysMAIL. - Reporter mail can be sent to any address:
emailis only syntax-checked, so a caller can have the acknowledgement, quoting its own description, sent anywhere. Held form notices get only the fixed confirmation letter, rate-limited per address and per day; other causes still quote. - Several replicas race: the store lock is per process.
ExemptandLiftlift the block at once only on the replica that served it, two replicas pushing the same new hash can both insert a row, and an exempt row inserted by hand while an immediate ban is in flight is not seen by it (the hash ends exempt, its data purged). - An immediate ban waits for row locks under the store lock: an open transaction holding a row of the hash (a hand UPDATE in psql) holds up that ban, and Push and Sync on the replica, until it ends or the caller's deadline does.
Bans of every cause publish to subject resource.banned, once their purge is due, with body:
{ "infohash": "<lowercase hex>" }The platform's JetStream stream common captures resource.*, so any consumer in the cluster can subscribe via a durable pull consumer. Existing subscribers:
web-ui— drops the resource fromlibrary,watch_history,cache_index,torrent_resource, media metadata and thevault.pledge/vault.tx_log/vault.resourcetables (refunding VP).vault— queues the resource for deletion (S3 + own DB) viaResourceQueueForDeletion.
Publishing is best-effort and never fails the RPC. Consumers must be idempotent — a purge_now repeat re-fires the event. Each periodic sync publishes every blocking infohash that is due (a row with purge_after NULL or passed) and not yet recorded in banned_published, and forgets the ones that stopped blocking, so a delayed ban, a failed publish, a row inserted by hand, or an exemption lifted (exempt back to false) is fanned out within one --sync-interval of being due. Setting exempt (by hand or with Exempt) or deleting the row before purge_after cancels the automatic purge; web-ui's manual metadata backfill, if run meanwhile, can still remove the data.
go build ./... # main server binary + ./client CLI
go run . serve [flags...] # start the server
go run . migrate up # apply PostgreSQL migrations
make protoc # regenerate proto/*.pb.go--probe-host probe host [$PROBE_HOST]
--probe-port (8081) probe port [$PROBE_PORT]
--use-probe enable probe [$USE_PROBE]
--postgres-host postgres host [$PG_HOST]
--postgres-port (5432) postgres port [$PG_PORT]
--postgres-user [$PG_USER]
--postgres-password [$PG_PASSWORD]
--postgres-database [$PG_DATABASE]
--postgres-ssl [$PG_SSL]
--grpc-host grpc listening host [$GRPC_HOST]
--grpc-port (50051) grpc listening port [$GRPC_PORT]
--admin-port (50052) admin grpc port on 127.0.0.1; 0 = off [$ADMIN_GRPC_PORT]
--form-confirm hold form notices until confirmed by mail [$FORM_CONFIRM]
--confirm-url (https://webtor.io/support/confirm) confirmation page [$CONFIRM_URL]
--nats-service-host nats host (auto-injected in K8s) [$NATS_SERVICE_HOST]
--nats-service-port (4222) nats port [$NATS_SERVICE_PORT]
--sync-interval, --si (10) PG → Badger resync interval, minutes [$STORE_SYNC_INTERVAL]
--purge-delay (72h) ban → resource.banned delay; 0 = at Push [$PURGE_DELAY]
--risk-classes (ZOOPHILIA,JUNIOR_IDOL,TOILET_VOYEUR,BATH_VOYEUR,ANIMAL_CRUSH) [$RISK_CLASSES]
--actors (form,mail-intake,content-agent,prod-agent,skiplist-agent,executor,owner,claude-code,review-job) [$ACTORS]
--require-kind refuse an admin ban without a kind [$REQUIRE_KIND]
--smtp-host [$SMTP_HOST]
--smtp-port [$SMTP_PORT]
--smtp-user [$SMTP_USER]
--smtp-pass [$SMTP_PASS]
--smtp-tls use implicit TLS (port 465 style) [$SMTP_TLS]
--smtp-start-tls use STARTTLS over plaintext connection [$SMTP_STARTTLS]
--smtp-tls-secure (true) verify TLS certificates [$SMTP_TLS_SECURE]
--mail-sender (noreply@webtor.io) [$MAIL_SENDER]
--mail-support (support@webtor.io) [$MAIL_SUPPORT]
--smtp-tls and --smtp-start-tls are mutually exclusive. Set --smtp-tls-secure=false only against a self-signed dev SMTP.
The client/ directory contains a small urfave/cli tool for smoke-testing:
go run ./client --host 127.0.0.1 --port 50051 push \
--hash <infohash> --work "..." --email reporter@example.com --description "..."
# also: --extra-hash <infohash> (repeatable), --purge-now (admin port only), --source form|mail (default form),
# --subject, --started-at (RFC 3339 or unix seconds), --notice-id, --fingerprint,
# --cause illegal|malware|app_error|question|csam_report|intimate_image (default illegal),
# --reporter-name, --good-faith, --authorized
# --kind csam|risk_class|copyright|intimate_image|malware|other (admin port for all but copyright and intimate_image),
# --risk-class <name> (with --kind risk_class; the server normalizes it), --actor <who decided, for the journal>
# a notice held by --form-confirm: the t parameter of the mailed link; prints e.g. "CONFIRMED 2"
go run ./client --host 127.0.0.1 --port 50051 confirm --token <t>
go run ./client --host 127.0.0.1 --port 50051 check --hash <infohash>
# admin port: Exempt, and Push with --purge-now honoured
kubectl port-forward deploy/abuse-store 50052:50052 &
go run ./client -H 127.0.0.1 -P 50052 exempt --hash <infohash> --reason "..."
# --actor <who decided> goes to the journal. Prints the rows set exempt; exits 1 with the gRPC error (code = FailedPrecondition / NotFound) otherwise;
# against the public port it exits 1 with code = Unimplemented
# admin port: remove a ban of any kind, by infohash or by 32-byte hex fingerprint (exactly one)
go run ./client -H 127.0.0.1 -P 50052 lift --hash <infohash> --reason "..." --actor owner
# prints rows=<n> still_blocked_rows=<n> still_blocked_kinds=<e.g. CSAM,MALWARE> purged=<bool> payload_known=<bool>SQL files in migrations/, numbered N_name.{up,down}.sql, run by the migrate subcommand from webtor-io/common-services. The Docker image copies the directory to /migrations so migrations are available at runtime.
docker build -t webtor/abuse-store .
docker run --rm -p 50051:50051 -p 8081:8081 \
-e PG_HOST=... -e PG_USER=... -e PG_PASSWORD=... -e PG_DATABASE=... \
-e SMTP_HOST=... -e SMTP_PORT=587 -e SMTP_USER=... -e SMTP_PASS=... -e SMTP_STARTTLS=true \
webtor/abuse-storeBuilt and pushed to ghcr.io/webtor-io/abuse-store by .github/workflows/docker-image.yml on push to main and on v* tags.