Automated shortlink abuse screening & moderation controls#3
Draft
navi-crwn wants to merge 1 commit into
Draft
Conversation
Motivated by a real incident: an anonymous user shortened a link to illegal (CSAM) content, exposing the operator to registrar/takedown action on an unmonitored, free-to-use service. Adds layered, automated defenses so abuse is caught and actioned without live monitoring. Screening (app/Services/LinkScreeningService.php), applied on every creation path (public/anonymous, API, dashboard) via a shared ScreensLinks trait: - Admin domain blacklist -> hard block - Google Safe Browsing -> hard block on known threats (opt-in via key) - Keyword heuristic -> flag for review (default) or block Verdicts are config-driven in config/abuse.php and fully tunable. Moderation: - Record creator IP on all links; add a non-redirecting "flagged" status with flagged_at/flag_reason (migration + Link model). - Email the security address on every auto-block/flag (notify_on_flag). - Admins can review auto-flagged links (?status=flagged); approving one clears its flag. - One-click takedown from the abuse report screen: disable the reported link and/or blacklist its domain. - Surface "Report this link" on the redirect interstitial and 404 page. Cleanup: archive unused views (duplicate half-migrated bio editor bio/edit + bio/partials/*, and orphan maintenance views) into a single compressed backup at archive/unused-20260702.tar.gz and remove them from the live tree. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lnoi65hsXRNZWtdWPSGDbe
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.
Why
A real incident prompted this: an anonymous visitor used the shortener to distribute illegal (CSAM) content, and the registrar contacted the operator as the apparent distributor. On a free-to-use service that isn't monitored around the clock, takedown can't depend on someone watching a dashboard. This PR adds layered, automated abuse defenses so bad links are caught at creation and are quick to action.
What
Screening at creation (
LinkScreeningService+ScreensLinkstrait)Applied to every creation path — anonymous public, API, and dashboard:
DomainBlacklist)SAFE_BROWSING_API_KEYis set; fails open on upstream errors)pediatrics/childcare/pedometerdo not trip)All behavior is config-driven in
config/abuse.phpand overridable via env — the operator tunes the keyword list, the flag-vs-block posture, and allowlisted hosts.Moderation & takedown
flaggedlink status (non-redirecting, held for review) withflagged_at/flag_reason, pluscreated_iprecorded on all links for forensics on anonymous abuse (migration +Linkmodel).?status=flagged; approving one clears its flag.Cleanup
bio/edit.blade.php+bio/partials/*) and two orphan maintenance views — into a single compressed backup atarchive/unused-20260702.tar.gz, and removed them from the live tree (~3.9k lines). Restore instructions are in the archive's README.Migration
Adds
created_ip,flagged_at,flag_reasontolinks— runphp artisan migrate.Config / setup
New keys in
.env.example(all optional; screening works out of the box with the built-in keyword net):Testing
php -lpasses on all changed PHP.vendor/in this environment, so the PHPUnit suite couldn't run here.Notes / follow-ups
SAFE_BROWSING_API_KEYis strongly recommended; it adds authoritative malware/phishing coverage the keyword net can't provide.🤖 Generated with Claude Code
https://claude.ai/code/session_01Lnoi65hsXRNZWtdWPSGDbe
Generated by Claude Code