There are traps.
What do you think needs to be added to them?
There are traps.
What do you think needs to be added to them?
This might be reasonable, though we already mark user profiles as noindex and links as nofollow so spam in profiles isn’t effective for pagerank if crawled/indexed. We also don’t link the website profile field for TL0 users as an extra precaution.
Links in posts for low trust users are also nofollow.
Unfortunately this is kind of impossible for a number of sites that operate as a support forums, including Meta… sometimes people just want to show up and post about their issue without building trust first.
I know it varies by site, but new account linkspam isn’t even the problem we’re seeing here… it’s posting vaguely related content in an attempt to build trust, and then posting spam later. So they’re already knowledgeable enough to build reputation before creating spam.
The Newuser max links setting can already do this for sites facing new user link spam though, that can be set to 0 today to achieve this.
Yes, this is true, and plenty of bots are getting past it… maybe it catches some. We sometimes see bad inputs in our “pronouns” custom field on signup, which is an indication of a low-effort bot, but still plenty getting past.
Use anti-spam challenges on sign up
Such as the ones that show an image of something and ask you to drag it to where it should fit.
Discourse Captcha is available for this
There are traps.
That’s good ![]()
This might be reasonable, though we already mark user profiles as
noindexand links asnofollowso spam in profiles isn’t effective for pagerank if crawled/indexed. We also don’t link thewebsiteprofile field for TL0 users as an extra precaution.Links in posts for low trust users are also
nofollow.
I think we need to shift to stronger (more obvious) deterrents now. I would rather zero links allowed in profiles until they have proved to be a genuine member.
Unfortunately this is kind of impossible for a number of sites that operate as a support forums, including Meta… sometimes people just want to show up and post about their issue without building trust first.
I know it varies by site..
…exactly - a huge number of forums would be totally ok with it, and the ones that don’t need it can just switch it off.
I think perhaps a global setting (like Newuser max links - but tied to trust levels beyond new users) and then per-category options might work best. For instance we’d turn it off in certain sections or allow TL1’s post links in certain sections, and TL2 for everywhere else).
Management the “monitor” user group is facilitated by another workflow, which is triggered by a “Post button” trigger. This adds a new icon to the post menu for staff members. Moderators can add or remove users by clicking that icon.
In case it will be useful to anyone, I’ll share the Workflow:
add-revoke-monitor-group-membership.json (17.6 KB)
The JSON file above can be imported into a new Discourse Workflow. See the note in the workflow for configuration instructions.
Here is a screenshot:
Some companion workflows:
lock-monitor-group-posts.json (7.2 KB)
tidy-monitor-group.json (3.8 KB)
The system I implemented uses an algorithm to identify new accounts with suspicious characteristics. It then raises flags on their posts.
Here is the workflow that raises flags on posts from accounts with potentially suspicious characteristics:
flag-posts-from-reviewable-users.json (47.0 KB)
with potentially suspicious characteristics
how do you define that and how does it differ from the existing AI spam detection?
how do you define that
It is defined in the Code node named “Reviewable user classifier” in the workflow:
// SPDX-License-Identifier: CC0-1.0
// Threshold weighting scores for various account characteristics.
const characteristicScores = {
// Other accounts use the same IP address.
associatedAccounts: 4,
// Account has bio.
bio: 1,
/*
IP address has changed since registration. This may indicate the account is being used by a different entity than
the registrant, or the use of a VPN/proxy to bypass IP/locational restrictions.
*/
ipChanged: 1,
// Location has changed countries (possibly indicating use of VPN/proxy to circumvent IP/locational restrictions).
migrated: 10,
// Location specified in profile doesn't match IP address geolocation.
profileLocationMismatch: 10,
// IP address used by other suspended account.
suspendedAssociation: 15,
// Suspicious content in profile bio.
suspiciousBio: 5,
// Suspicious content in email.
suspiciousEmail: 4,
// Suspicious content in post.
suspiciousPost: 3,
// Suspicious content in profile website link.
suspiciousWebsite: 6,
// Profile has website link.
website: 2,
};
const thresholdData = {
/*
User will be classified as "reviewable" if account stats do not surpass at least one of these thresholds.
Thresholds are defined as a range. The effective threshold is weighted according to the account's scoring, as
defined above.
*/
/*
Spammer accounts are often created some days before being used. However, it is likely that they will be used
before too much time has passed.
Unit: seconds.
*/
accountAge: {
description: "account age",
range: {
low: 8 * 24 * 60 * 60,
high: 40 * 24 * 60 * 60,
},
},
daysVisited: {
description: "days visited",
range: {
low: 2,
high: 6,
},
},
// Includes topic original posts and replies.
postCount: {
description: "post count",
range: {
low: 1,
high: 5,
},
},
postsRead: {
description: "posts read",
range: {
low: 4,
high: 60,
},
},
// Unit: seconds.
timeReading: {
description: "time spent reading",
range: {
low: 3 * 60,
high: 15 * 60,
},
},
topicsEntered: {
description: "topics entered",
range: {
low: 2,
high: 10,
},
},
/*
Note: A maximum trust level for general workflow run is configured in the configuration of the "Post edited"
trigger, and in the "Low trust level?" filter node.
*/
trustLevel: {
description: "trust level",
range: {
low: 0,
high: 1,
},
},
};
const associatedAccountData = $("Associated accounts").first().json;
const emailAddress = $("User email address").first().json.normalized_email;
const postData = $("Get post data").first().json;
const profileLocation = $("Profile location").item.json.profile_location;
const userData = $("User data").first().json;
const userLocations = {};
if ($("Profile location").item.json.profile_location != null) {
userLocations.profile = $("Profile location").item.json.profile_location;
}
const userCharacteristics = {
associatedAccounts: associatedAccountData.matching_account_count > 0,
bio: userData.user.bio_raw !== null && userData.user.bio_raw !== "",
ipChanged: userData.user.ip_address !== userData.user.registration_ip_address,
migrated:
userData.user.last_location !== null &&
userData.user.registration_location !== null &&
userData.user.last_location.country !==
userData.user.registration_location.country,
profileLocationMismatch: !evaluateProfileLocationMatch(
$("Compare last location").first().json,
$("Compare registration location").first().json,
),
suspendedAssociation:
associatedAccountData.matching_suspended_account_count > 0,
suspiciousBio:
userData.user.bio_raw !== null && suspiciousContent(userData.user.bio_raw),
suspiciousEmail: spamKeywords(emailAddress),
suspiciousPost: suspiciousContent(postData.post.raw),
suspiciousWebsite:
userData.user.website !== null && spamKeywords(userData.user.website),
website: userData.user.website !== null && userData.user.website !== "",
};
const thresholdStats = {
accountAge: (Date.now() - Date.parse(userData.user.created_at)) / 1000, // Seconds.
daysVisited: userData.user.stats.days_visited,
// `user.post_count` is actually only the reply count, so `user.topic_count` must be added in order to get the total
// post count.
postCount: userData.user.stats.topic_count + userData.user.stats.post_count,
postsRead: userData.user.stats.posts_read_count,
timeReading: userData.user.stats.time_read, // Seconds.
topicsEntered: userData.user.stats.topics_entered,
trustLevel: userData.user.trust_level,
};
const userStats = {
associatedAccountCount: associatedAccountData.matching_account_count,
locations: userLocations,
monitorGroup: monitorGroup(userData),
staff: userData.user.staff,
};
if (reviewable()) {
return [
{
flag: true,
reason: reason(),
},
];
}
console.log(reason());
// Do not flag.
return [
{
flag: false,
reason: "",
},
];
// evaluateProfileLocationMatch evaluates the profile location vs. IP geolocation comparison data.
function evaluateProfileLocationMatch(
lastLocationComparison,
registrationLocationComparison,
) {
const confidenceThreshold = 0.7;
if (Object.keys(lastLocationComparison).includes("classification")) {
if (
lastLocationComparison.classification.match.choice === "false" &&
lastLocationComparison.classification.match.confidence >=
confidenceThreshold
) {
return false;
}
}
if (Object.keys(registrationLocationComparison).includes("classification")) {
if (
registrationLocationComparison.classification.match.choice === "false" &&
registrationLocationComparison.classification.match.confidence >=
confidenceThreshold
) {
return false;
}
}
return true;
}
// formatDuration formats a duration value into a human friendly format.
function formatDuration(totalSeconds) {
const hours = Math.floor(totalSeconds / 3600)
.toString()
.padStart(2, "0");
const minutes = Math.floor((totalSeconds % 3600) / 60)
.toString()
.padStart(2, "0");
const seconds = Math.round(totalSeconds % 60)
.toString()
.padStart(2, "0");
return `${hours}:${minutes}:${seconds} (H:M:S)`;
}
// monitorGroup returns whether the account is in the `monitor` user group.
function monitorGroup(data) {
for (group of data.user.groups) {
// The `monitor_group_id` Workflow Variable is the ID of the `monitor` user group.
if (group.id == $vars.monitor_group_id) {
return true;
}
}
return false;
}
// reason returns the text of the message that will be displayed in the flag.
function reason() {
let reason = `<br />
**Account Stats**
- **Account age:** ${formatDuration(thresholdStats.accountAge)}
- **Associated account count:** ${userStats.associatedAccountCount}
- **Days visited:** ${thresholdStats.daysVisited}
- **Time spent reading posts:** ${formatDuration(thresholdStats.timeReading)}
- **Post count:** ${thresholdStats.postCount}
- **Posts read:** ${thresholdStats.postsRead}
- **Topics entered:** ${thresholdStats.topicsEntered}
- **Trust level:** ${thresholdStats.trustLevel}
`;
if (userStats.monitorGroup) {
reason = reason.concat(
`
❗ User is a member of the "monitor" user group.
`,
);
}
if (userCharacteristics.migrated) {
reason = reason.concat(
`
❗ User's location has changed countries.
This might indicate use of a proxy/VPN to circumvent location-based restrictions.
`,
);
} else if (userCharacteristics.ipChanged) {
reason = reason.concat(
`
❗ User's IP address has changed.
This might indicate use of a proxy/VPN to circumvent IP-based restrictions.
`,
);
}
if (userCharacteristics.profileLocationMismatch) {
reason = reason.concat(
`
❗ User's IP address does not match the location "${userStats.locations.profile}" they specified in their account profile.
`,
);
}
if (userCharacteristics.suspendedAssociation) {
reason = reason.concat(
`
❗ User IP address has been used by other suspended accounts.
This might indicate bulk account use for spam deployment.
`,
);
}
if (userCharacteristics.suspiciousEmail) {
reason = reason.concat(
`
❗ User email address contains keywords commonly seen in those of spammer accounts.
`,
);
}
return reason;
}
// reviewable returns whether the user is classified as "reviewable".
function reviewable() {
if (userStats.staff) {
/*
In order to manage the `monitor` user group, moderators must be members of the group. For this reason, it is
necessary to explicitly exempt them from being classified as "reviewable".
*/
console.log("Not reviewable: user is staff.");
return false;
}
if (userStats.monitorGroup) {
// User is in the `monitor` user group, and thus is always reviewable regardless of other stats.
console.log("Reviewable: user is in monitor group.");
return true;
}
// Check if data indicate the user should be assigned a "reviewable" classification.
const weight = thresholdWeight();
for (const [stat, value] of Object.entries(thresholdStats)) {
const threshold = Math.round(
(thresholdData[stat].range.high - thresholdData[stat].range.low) *
weight +
thresholdData[stat].range.low,
);
if (value > threshold) {
console.log(
`Not reviewable: ${thresholdData[stat].description} ${value} exceeds threshold ${threshold}.`,
);
return false;
}
}
console.log("Reviewable: account does not pass any threshold");
return true;
}
// spamKeywords returns whether the given string contains keywords associated with spammers.
function spamKeywords(content) {
const keywords = [
"777",
"agency",
"apk",
"app",
"astrolog",
"backlink",
"brand",
"casino",
"chems",
"club",
"coin",
"consultan",
"crm",
"crypto",
"design",
"digital",
"escort",
"estate",
"fashion",
"fitness",
"game",
"gelatin",
"gift",
"girls",
"gluco",
"gummies",
"gummy",
"homes",
"logistic",
"manage",
"manufactur",
"market",
"meds",
"menu",
"official",
"pcb",
"pharma",
"properties",
"repair",
"resort",
"review",
"sale",
"seo",
"sephora",
"service",
"slot",
"soda",
"solution",
"spell",
"spotif",
"team",
"travel",
"website",
];
for (keyword of keywords) {
if (content.includes(keyword)) {
return true;
}
}
return false;
}
// suspiciousContent returns whether the given string contains content common to spammer posts.
function suspiciousContent(content) {
const suspiciousTexts = ["pcbcool", "digital market", "online marketing"];
const suspiciousPatterns = [
/*
Multiple em dashes are sometimes utilized as a graphical element by legitimate users. It is only the solitary
em dash used as punctuation that is the indicator of AI-generated content.
*/
/.+[^—]—[^—].+/,
/\bSEO\b/,
];
for (suspiciousText of suspiciousTexts) {
if (content.includes(suspiciousText) != null) {
return true;
}
}
for (suspiciousPattern of suspiciousPatterns) {
if (content.match(suspiciousPattern) != null) {
return true;
}
}
return false;
}
// thresholdWeight returns the threshold weight based on the given score.
function thresholdWeight() {
let score = 0;
// Add characteristic-based scores.
for (const [characteristic, present] of Object.entries(userCharacteristics)) {
if (present) {
score += characteristicScores[characteristic];
}
}
// Calculate maximum score.
let maxCharacteristicScore = 0;
for (characteristicScore of Object.values(characteristicScores)) {
maxCharacteristicScore += characteristicScore;
}
// Calculate weight.
return score / maxCharacteristicScore;
}
If you have any specific questions about the code, I’m happy to provide clarification.
how does it differ from the existing AI spam detection?
The fundamental difference is that this system is intended to bring the activity of accounts that have characteristics commonly found in spammer accounts to the attention of the moderators. It is similar to the “Review TL1 users first post” (or “Review every post”) feature built into the Discourse core, except better suited to a popular forum where reviewing every post would be too much of a burden for the moderation team.
In my opinion, the spam detector system is designed to detect objective spam, and should only be used for that purpose. You should not configure the spam detector prompt in a manner that results in a high incidence of false positives, because these result in a bad user experience. This is the reason why I created an independent system for the task of highlighting potentially suspicious activity, which is inherently prone to false positives.
thanks for detailing that @per1234 ![]()