Skip to content
Business logic Write-up Intermediate

Moderation Filter Bypass in support.mozilla.org

The spam filter on support.mozilla.org used an outdated list of valid top-level domains, so replies containing links to newer TLDs were not flagged as spam. An attacker could post such links without moderation.

Brandon Roldan Follow

Published on tomorrowisnew.com

Recently, the triager at mozilla pointed out to me, that when replying a link to a question, the reply will be mark as spam, and will be up for moderation.

tomorrowisnew (@tomorrowisnew_), on tomorrowisnew.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

Context

support.mozilla.org is Mozilla's support site, built on Kitsune, a Django application. One of its features is the question and answer forum: a user posts a question, and other users reply to it. Replies are submitted through a form called AnswerForm, and the application runs a spam check on the submitted content before accepting it. If the check decides the content looks like spam, the reply is flagged and held for moderation instead of being published directly.

The researcher's starting point was a remark from the Mozilla triager: when a reply contains a link to a question, the reply is marked as spam and put up for moderation. That behaviour is the spam filter working as intended, but it also marks a clear boundary worth attacking: the code that decides whether a link is acceptable.

Setup

The write-up does not describe any special accounts, roles or tooling. The work is a source code review of the public Kitsune codebase, plus a comparison of two versions of the IANA top level domain list. The only precondition is the ability to post a reply to a question on support.mozilla.org, which is the normal forum functionality.

Finding it

The reply view loads the question and builds the form with the current user and the question attached:

Python
def reply(request, question_id):
    """Post a new answer to a question."""
    question = get_object_or_404(Question, pk=question_id, is_spam=False)
    answer_preview = None

    if not question.allows_new_answer(request.user):
        raise PermissionDenied

    form = AnswerForm(request.POST, **{"user": request.user, "question": question}) # LOOK HERE

AnswerForm overrides clean, but only to exempt the question owner from spam filtering. It calls the parent's clean first and then removes the is_spam flag if the replying user is the question creator:

Python
class AnswerForm(KitsuneBaseForumForm):
    """Form for replying to a question."""

    content = forms.CharField(
        label=_lazy("Content:"),
        min_length=5,
        max_length=10000,
        widget=forms.Textarea(attrs={"placeholder": REPLY_PLACEHOLDER}),
    )

    class Meta:
        model = Answer
        fields = ("content",)

    def clean(self, *args, **kwargs):
        """Override clean method to exempt question owner from spam filtering."""
        cdata = super(AnswerForm, self).clean(*args, **kwargs) # LOOK HERE
        # if there is a reply from the owner, remove the spam flag
        if self.user and self.question and self.user == self.question.creator:
            cdata.pop("is_spam", None)

        return cdata

The parent class, KitsuneBaseForumForm, is where the actual decision is made. Users in trusted groups, users with the flagit.can_moderate permission and users with the sumo.bypass_ratelimit permission skip the check entirely. Everyone else has their content passed to check_for_spam_content, and if that returns true the form data gets is_spam: True:

Python
class KitsuneBaseForumForm(forms.Form):
   def __init__(self, *args, **kwargs):
        #UNIMPORTANT SNIPPET

    def clean(self, *args, **kwargs):
        cdata = self.cleaned_data.get("content")

        # UNIMPORTANT SNIPPET

        if not (
            self.user.groups.filter(name__in=TRUSTED_GROUPS).exists()
            or self.user.has_perm("flagit.can_moderate")
            or self.user.has_perm("sumo.bypass_ratelimit")
        ) and check_for_spam_content(cdata): # LOOK HERE
            self.cleaned_data.update({"is_spam": True})

        return self.cleaned_data

check_for_spam_content combines three signals: a toll free number, a NANP phone number, and a blocked link:

Python
def check_for_spam_content(data):
    digits = "".join(filter(type(data).isdigit, data))
    is_toll_free = settings.TOLL_FREE_REGEX.match(digits)

    is_nanp_number = match_regex_with_timeout(settings.NANP_REGEX, data)

    has_links = has_blocked_link(data) # INTERESTING PART

    return is_toll_free or is_nanp_number or has_links

The link check is the interesting part. has_blocked_link iterates over every potential link in the content, extracts the TLD, and only continues if that TLD is in VALID_TLDS. If it is, the full domain is compared against the allowlist in settings.ALLOW_LINKS_FROM; a domain that is not in the allowlist causes the function to return true, which means spam:

Python
def has_blocked_link(data):
    for match in POTENTIAL_LINK_REGEX.finditer(data):
        tld = match.group(1).upper()
        if tld in VALID_TLDS: # VULNERABLE PART OF THE CODE
            full_domain = match.group(0).lower()
            in_allowlist = False
            for allowed_domain in settings.ALLOW_LINKS_FROM:
                split = full_domain.rsplit(allowed_domain, 1)
                if len(split) != 2 or split[-1]:
                    continue
                if not split[0] or split[0][-1] == ".":
                    in_allowlist = True
                    break
            if not in_allowlist:
                return True
    # UNIMPORTANT SNIPPET
    return False

The gate is VALID_TLDS. The code loads it from a text file shipped with the application:

Python
# downloaded from https://data.iana.org/TLD/tlds-alpha-by-domain.txt
path = os.path.join(os.path.dirname(__file__), "tlds-alpha-by-domain.txt")

with open(path) as f:
    VALID_TLDS = set(f.read().splitlines()[1:])

Opening that file showed the header of an old snapshot of the IANA list:

# Version 2020062200, Last Updated Mon Jun 22 07:07:01 2020 UTC
AAA
AARP
ABARTH
...

So the application was validating links against a TLD list frozen in June 2020. Any TLD delegated after that date would not be in VALID_TLDS, and a link using it would never reach the allowlist comparison, so has_blocked_link would not flag it.

Exploitation

Step 1: Diff the bundled list against the current IANA list

The researcher downloaded the current list from https://data.iana.org/TLD/tlds-alpha-by-domain.txt and compared it with the bundled one to find TLDs present in only one of the two files:

CONSOLE
$ cat tlds-alpha-by-domain.txt* | sort | uniq -u
AFAMILYCOMPANY
AIGO
BUDAPEST
CASEIH
CEB
CSC
DUCK
FUJIXEROX
GLADE
INTEL
IVECO
JCP
LIXIL
LUPIN
METLIFE
MUSIC
NATIONWIDE
NEWHOLLAND
OFF
ONYOURSIDE
QVC
RAID
RIGHTATHOME
RMIT
SCJOHNSON
SHRIRAM
SPA
SPREADBETTING
SWIFTCOVER
SYMANTEC
# Version 2020062200, Last Updated Mon Jun 22 07:07:01 2020 UTC
# Version 2022040300, Last Updated Sun Apr  3 07:07:01 2022 UTC
XN--3OQ18VL8PN36A
XN--4DBRK0CE
XN--KPU716F
XN--PBT977C

The output mixes TLDs that were added and TLDs that were removed between the two snapshots, plus the two version header lines. The researcher then wrote a small script to check which of these TLDs are absent from the list Mozilla ships:

Python
import os

#LIST OF TLDS THAT IS NOT ON BOTH TEXT FILES
lamaw = ["AFAMILYCOMPANY","AIGO","BUDAPEST","CASEIH","CEB","CSC","DUCK","FUJIXEROX","GLADE","INTEL","IVECO","JCP","LIXIL","LUPIN","METLIFE","MUSIC","NATIONWIDE","NEWHOLLAND","OFF","ONYOURSIDE","QVC","RAID","RIGHTATHOME","RMIT","SCJOHNSON","SHRIRAM","SPA","SPREADBETTING","SWIFTCOVER","SYMANTEC","XN--3OQ18VL8PN36A","XN--4DBRK0CE","XN--KPU716F","XN--PBT977C"]

path = os.path.join(os.path.dirname(__file__), "tlds-alpha-by-domain.txt")

for i in lamaw:
    with open(path) as f:
        VALID_TLDS = set(f.read().splitlines()[1:])
        for x in VALID_TLDS:
            if x==i:
                continue
    print(i)

Running it printed the candidate TLDs that are not in Mozilla's copy. The write-up does not list the final result separately; the point is that at least one currently delegated TLD is not in the bundled file.

Step 2: Post a reply with a link using a missing TLD

With such a TLD in hand, a reply containing a URL like https://evil.spa is submitted through the normal reply form. Because SPA is not in VALID_TLDS, the if tld in VALID_TLDS branch is skipped, the allowlist comparison never runs, and has_blocked_link returns false. The reply is not marked as spam, bypassing the filter.

Root cause

The spam filter treats the TLD as the entry condition for link checking: a link is only considered for the allowlist comparison if its TLD appears in a static, bundled copy of the IANA list. That list is a point-in-time snapshot (June 2020 in the version shown), so TLDs delegated after it are missing. so every TLD delegated after the snapshot is effectively invisible to the filter. The allowlist logic in settings.ALLOW_LINKS_FROM is never consulted for those links, and the function falls through to return False.

The design also fails open: an unrecognised TLD is treated as not-a-link rather than as suspicious. The trusted group and permission checks in KitsuneBaseForumForm are unrelated to this path and do not help, since an ordinary user posting a reply goes through check_for_spam_content as intended.

Impact

A normal user can post replies containing links to domains under TLDs missing from the bundled list without the reply being flagged as spam or held for moderation. The researcher notes that the only thing achievable with this bug is a spam filter bypass, which Mozilla treats as out of scope. The write-up does not describe any other effect, such as script execution or access to other users' data, and states that in another functionality it would have been a more interesting bug.

Fix

A possible fix would be to keep the TLD list current and make the link check fail closed, but the write-up does not discuss remediation.

Variants to test

  1. Stale data files in general. Look for any security decision driven by a bundled snapshot (TLD lists, public suffix lists, blocklists, allowlists, CVE feeds). A positive result is a value that the current upstream source contains but the bundled copy does not, and that changes the decision.
  2. Allowlist matching by suffix. The rsplit logic in has_blocked_link accepts a domain when the part before the allowed domain is empty or ends with a dot. Try domains such as evil.example.com against an allowlist entry of example.com, and try entries where the allowed domain appears mid-string, to see whether the boundary check can be defeated.
  3. Case and encoding of the TLD. The code upper-cases the matched TLD before the lookup. Try mixed case, trailing dots, punycode and percent-encoded forms in the URL to see whether the regex and the lookup disagree.
  4. Other branches of the same spam check. The toll free and NANP checks run on digits extracted from the content. Try formatting phone numbers so the digit extraction or the regexes miss them, and confirm whether the reply is still flagged.
  5. Privilege shortcuts. The trusted group and permission checks skip the spam filter entirely. On another target, check whether any of those group names or permissions can be obtained by a normal user through profile settings or invitation flows.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 18 min read.

What happened, in plain words

Mozilla runs a support website at support.mozilla.org. People go there to ask questions about Firefox and other Mozilla products, and other people reply to those questions. The software behind the site is called Kitsune, and it is written in a programming language called Python, using a framework called Django. A framework is a ready-made set of building blocks that developers use so they do not have to write everything from scratch.

Because a public forum attracts spammers, the site has an automatic spam filter. When you submit a reply, the site inspects the text before publishing it. If the text looks like spam, the reply is not shown straight away: it is flagged and put in a moderation queue, where a human moderator decides what to do with it.

A Mozilla triager (the person who reads incoming bug reports and decides whether they are valid) mentioned to the researcher that replying with a link to a question gets the reply marked as spam. That is the filter doing its job. But it also points at the exact piece of code that decides whether a link is acceptable, and that is where the researcher went looking.

The researcher read the public source code of Kitsune and found that the link check depends on a list of top level domains (TLDs) that was copied into the project in June 2020 and never updated. A TLD is the last part of a web address, like the com in example.com or the org in wikipedia.org. New TLDs are created over time, and any TLD created after June 2020 was missing from the site's copy of the list. A link using such a TLD was never examined at all, so the spam filter let it through. The researcher gave the example of a link ending in .spa, a TLD that was not in the site's old list.

The only thing this bug allows is getting past the spam filter, and Mozilla treats spam filter bypasses as out of scope, meaning they do not pay a bounty for them. The researcher says that in another part of the site it would have been a more interesting bug.

The background you need

Before walking through the code, here are the ideas that come up, explained from zero.

Source code review. Many websites, especially open source ones, publish their code so anyone can read it. Reading code to look for mistakes is called source code review. It is like reading the blueprint of a building instead of walking around inside it: you can spot a door that was never fitted with a lock.

Form and clean. When you type a reply into a box on a website and press submit, the browser sends your text to the server. On the server, a piece of code called a form takes that text and checks it. In Django, the checking step is a method (a named block of code) usually called clean. If clean decides something is wrong, the submission is rejected or altered. Here, clean is where the spam decision is made.

Class and inheritance. In Python, code is organised into classes. One class can build on another: the child class inherits everything the parent class does, and can add or change parts. When the child's clean runs, it can call the parent's clean with the line super(...).clean(...), which means "run the parent's version first, then continue". This matters because the actual spam decision lives in the parent, not the child.

Regex. A regular expression (regex) is a pattern for matching text. For example, a regex can describe "something that looks like a web address". The site uses regexes to find links and phone numbers inside a reply.

TLD. The top level domain is the final segment of a domain name: com, org, net, uk, spa. The full, official list of TLDs is maintained by an organisation called IANA, and it is published as a plain text file at a fixed web address. That file has a version line at the top with a date.

Allowlist. An allowlist is a list of things that are explicitly permitted. Here, settings.ALLOW_LINKS_FROM is a list of domains whose links are considered fine. A link to a domain not on that list is treated as spam.

Fail open vs fail closed. When a check cannot decide, it can either let the thing through (fail open) or block it (fail closed). For a spam filter, failing open means an unrecognised link is treated as harmless. That is the design choice at the heart of this bug.

Moderation queue. A holding area. Flagged replies wait there until a moderator approves or rejects them, instead of appearing publicly right away.

Setting up

The write-up does not describe any special accounts, roles or tools. The work is reading the public Kitsune source code and comparing two versions of the IANA TLD list. The only thing you need on the site itself is the ordinary ability to post a reply to a question, which every normal forum user has.

Finding it

The reply view

When you submit a reply, the server runs a function called reply. Here it is:

Python
def reply(request, question_id):
    """Post a new answer to a question."""
    question = get_object_or_404(Question, pk=question_id, is_spam=False)
    answer_preview = None

    if not question.allows_new_answer(request.user):
        raise PermissionDenied

    form = AnswerForm(request.POST, **{"user": request.user, "question": question}) # LOOK HERE

Line by line:

  1. def reply(request, question_id): defines the function. request is the incoming web request (who is asking, what they sent). question_id identifies which question is being answered.
  2. question = get_object_or_404(...) looks up the question in the database. If it does not exist, or if it is already marked as spam (is_spam=False is part of the lookup), the server returns a 404 "not found" page. This is like a librarian refusing to hand you a book that is not on the shelf.
  3. answer_preview = None sets up a variable for a preview, unused in this snippet.
  4. if not question.allows_new_answer(request.user): asks whether this particular user is allowed to answer this particular question (for example, the question might be locked).
  5. raise PermissionDenied stops the request with a "permission denied" error if the answer is no.
  6. form = AnswerForm(request.POST, ...) builds the form object, handing it the submitted data (request.POST) plus the current user and the question. The comment # LOOK HERE marks the line the researcher wants you to notice: the form knows who is posting and which question they are answering.

The child form

AnswerForm is the form used for replies. It has its own clean method:

Python
class AnswerForm(KitsuneBaseForumForm):
    """Form for replying to a question."""

    content = forms.CharField(
        label=_lazy("Content:"),
        min_length=5,
        max_length=10000,
        widget=forms.Textarea(attrs={"placeholder": REPLY_PLACEHOLDER}),
    )

    class Meta:
        model = Answer
        fields = ("content",)

    def clean(self, *args, **kwargs):
        """Override clean method to exempt question owner from spam filtering."""
        cdata = super(AnswerForm, self).clean(*args, **kwargs) # LOOK HERE
        # if there is a reply from the owner, remove the spam flag
        if self.user and self.question and self.user == self.question.creator:
            cdata.pop("is_spam", None)

        return cdata

Line by line:

  1. class AnswerForm(KitsuneBaseForumForm): declares the class and says it inherits from KitsuneBaseForumForm. Everything the parent does, this class also does, unless it overrides it.
  2. content = forms.CharField(...) defines the reply text box: a label, a minimum length of 5 characters, a maximum of 10000, and a text area widget with a placeholder hint.
  3. class Meta: with model = Answer and fields = ("content",) ties the form to the Answer database model and says the only field is the content.
  4. def clean(self, *args, **kwargs): overrides the parent's clean.
  5. cdata = super(AnswerForm, self).clean(*args, **kwargs) runs the parent's clean first. The comment # LOOK HERE points out that the real decision happens inside this call.
  6. if self.user and self.question and self.user == self.question.creator: checks whether the person replying is the person who asked the question.
  7. cdata.pop("is_spam", None) removes the is_spam flag if so. In other words, the question's own author is exempt from the spam filter. This is a courtesy rule, not the bug.
  8. return cdata hands the cleaned data back.

The parent form, where the decision is made

The parent class is where the spam decision actually happens:

Python
class KitsuneBaseForumForm(forms.Form):
   def __init__(self, *args, **kwargs):
        #UNIMPORTANT SNIPPET

    def clean(self, *args, **kwargs):
        cdata = self.cleaned_data.get("content")

        # UNIMPORTANT SNIPPET

        if not (
            self.user.groups.filter(name__in=TRUSTED_GROUPS).exists()
            or self.user.has_perm("flagit.can_moderate")
            or self.user.has_perm("sumo.bypass_ratelimit")
        ) and check_for_spam_content(cdata): # LOOK HERE
            self.cleaned_data.update({"is_spam": True})

        return self.cleaned_data

Line by line:

  1. class KitsuneBaseForumForm(forms.Form): declares the parent class, built on Django's standard form.
  2. def __init__(...) is the setup step that runs when the form is created. The snippet is marked unimportant.
  3. def clean(...) is the checking step.
  4. cdata = self.cleaned_data.get("content") pulls out the reply text that has already passed basic validation.
  5. The big if not (...) is a set of exemptions. Three kinds of user skip the spam check entirely: members of trusted groups (TRUSTED_GROUPS), users with the flagit.can_moderate permission (moderators), and users with the sumo.bypass_ratelimit permission. The not means: if none of these apply, continue to the spam check.
  6. and check_for_spam_content(cdata) runs the spam check on the text. The comment # LOOK HERE marks the call the researcher followed next.
  7. self.cleaned_data.update({"is_spam": True}) marks the reply as spam if the check said yes. That flag is what sends the reply to moderation.
  8. return self.cleaned_data returns the result.

The spam check

check_for_spam_content combines three signals:

Python
def check_for_spam_content(data):
    digits = "".join(filter(type(data).isdigit, data))
    is_toll_free = settings.TOLL_FREE_REGEX.match(digits)

    is_nanp_number = match_regex_with_timeout(settings.NANP_REGEX, data)

    has_links = has_blocked_link(data) # INTERESTING PART

    return is_toll_free or is_nanp_number or has_links

Line by line:

  1. digits = "".join(filter(type(data).isdigit, data)) keeps only the digit characters from the reply and joins them into one string. This is a crude way to catch phone numbers even if they are written with spaces or dashes.
  2. is_toll_free = settings.TOLL_FREE_REGEX.match(digits) checks whether those digits look like a toll free number.
  3. The match is run with a timeout.
  4. has_links = has_blocked_link(data) runs the link check. The comment # INTERESTING PART marks it as the part the researcher focused on.
  5. return is_toll_free or is_nanp_number or has_links says: if any of the three signals is true, the content is spam.

The link check

has_blocked_link is where the flaw lives:

Python
def has_blocked_link(data):
    for match in POTENTIAL_LINK_REGEX.finditer(data):
        tld = match.group(1).upper()
        if tld in VALID_TLDS: # VULNERABLE PART OF THE CODE
            full_domain = match.group(0).lower()
            in_allowlist = False
            for allowed_domain in settings.ALLOW_LINKS_FROM:
                split = full_domain.rsplit(allowed_domain, 1)
                if len(split) != 2 or split[-1]:
                    continue
                if not split[0] or split[0][-1] == ".":
                    in_allowlist = True
                    break
            if not in_allowlist:
                return True
    # UNIMPORTANT SNIPPET
    return False

Line by line:

  1. for match in POTENTIAL_LINK_REGEX.finditer(data): walks through every piece of text in the reply that looks like a link. finditer returns one match at a time.
  2. tld = match.group(1).upper() takes the captured TLD from the match and converts it to upper case, so spa becomes SPA.
  3. if tld in VALID_TLDS: is the gate. The comment # VULNERABLE PART OF THE CODE marks it. Only if the TLD is in the site's list does the code go on to examine the domain. If the TLD is not in the list, the loop simply moves on to the next match, and this link is never judged.
  4. full_domain = match.group(0).lower() takes the whole matched domain, lower-cased.
  5. in_allowlist = False starts by assuming the domain is not allowed.
  6. for allowed_domain in settings.ALLOW_LINKS_FROM: loops over the domains the site considers fine.
  7. split = full_domain.rsplit(allowed_domain, 1) splits the full domain at the allowed domain, from the right, at most once. This is a way of asking "does the full domain end with the allowed domain?".
  8. if len(split) != 2 or split[-1]: continue skips this allowed domain if the split did not produce exactly two parts, or if there is text after the allowed domain. In other words, the allowed domain must be at the end.
  9. if not split[0] or split[0][-1] == ".": checks the part before the allowed domain: it must be empty, or end with a dot. This is meant to stop evil-example.com from matching an allowlist entry of example.com.
  10. in_allowlist = True and break mark the domain as allowed and stop looping.
  11. if not in_allowlist: return True means: if the domain is not on the allowlist, report it as a blocked link, which means spam.
  12. return False at the end means: no blocked links found, so not spam.

Where the TLD list comes from

The gate is VALID_TLDS. The code loads it from a text file shipped with the application:

Python
# downloaded from https://data.iana.org/TLD/tlds-alpha-by-domain.txt
path = os.path.join(os.path.dirname(__file__), "tlds-alpha-by-domain.txt")

with open(path) as f:
    VALID_TLDS = set(f.read().splitlines()[1:])

Line by line:

  1. The comment records where the file came from: the official IANA list.
  2. path = os.path.join(...) builds the path to the file, which sits next to the code file itself.
  3. with open(path) as f: opens the file.
  4. VALID_TLDS = set(f.read().splitlines()[1:]) reads the whole file, splits it into lines, drops the first line (the version header), and turns the rest into a set. A set is a collection where each item appears once and lookups are fast.

Opening that file showed the header of an old snapshot:

# Version 2020062200, Last Updated Mon Jun 22 07:07:01 2020 UTC
AAA
AARP
ABARTH
...

The header says the list was last updated on 22 June 2020. So the site was checking links against a TLD list frozen on that date. Any TLD created after that date would not be in VALID_TLDS, and a link using it would never reach the allowlist comparison, so has_blocked_link would not flag it.

Exploitation

Step 1: Compare the bundled list with the current IANA list

The researcher downloaded the current list from https://data.iana.org/TLD/tlds-alpha-by-domain.txt and compared it with the bundled one to find TLDs present in only one of the two files:

CONSOLE
$ cat tlds-alpha-by-domain.txt* | sort | uniq -u
AFAMILYCOMPANY
AIGO
BUDAPEST
CASEIH
CEB
CSC
DUCK
FUJIXEROX
GLADE
INTEL
IVECO
JCP
LIXIL
LUPIN
METLIFE
MUSIC
NATIONWIDE
NEWHOLLAND
OFF
ONYOURSIDE
QVC
RAID
RIGHTATHOME
RMIT
SCJOHNSON
SHRIRAM
SPA
SPREADBETTING
SWIFTCOVER
SYMANTEC
# Version 2020062200, Last Updated Mon Jun 22 07:07:01 2020 UTC
# Version 2022040300, Last Updated Sun Apr  3 07:07:01 2022 UTC
XN--3OQ18VL8PN36A
XN--4DBRK0CE
XN--KPU716F
XN--PBT977C

Line by line:

  1. cat tlds-alpha-by-domain.txt* prints the contents of every file whose name starts with tlds-alpha-by-domain.txt. The * is a wildcard, so both the old and the new file are printed, one after the other.
  2. | pipes that output into the next command.
  3. sort puts all the lines in alphabetical order.
  4. uniq -u prints only the lines that appear exactly once. Lines that appear in both files appear twice and are dropped.

The output mixes TLDs that were added and TLDs that were removed between the two snapshots, plus the two version header lines. The researcher then wrote a small script to check which of these TLDs are absent from the list Mozilla ships:

Python
import os

#LIST OF TLDS THAT IS NOT ON BOTH TEXT FILES
lamaw = ["AFAMILYCOMPANY","AIGO","BUDAPEST","CASEIH","CEB","CSC","DUCK","FUJIXEROX","GLADE","INTEL","IVECO","JCP","LIXIL","LUPIN","METLIFE","MUSIC","NATIONWIDE","NEWHOLLAND","OFF","ONYOURSIDE","QVC","RAID","RIGHTATHOME","RMIT","SCJOHNSON","SHRIRAM","SPA","SPREADBETTING","SWIFTCOVER","SYMANTEC","XN--3OQ18VL8PN36A","XN--4DBRK0CE","XN--KPU716F","XN--PBT977C"]

path = os.path.join(os.path.dirname(__file__), "tlds-alpha-by-domain.txt")

for i in lamaw:
    with open(path) as f:
        VALID_TLDS = set(f.read().splitlines()[1:])
        for x in VALID_TLDS:
            if x==i:
                continue
    print(i)

Line by line:

  1. import os brings in Python's standard module for file paths.
  2. lamaw = [...] is the list of TLDs from the comparison above, copied in by hand.
  3. path = os.path.join(...) points at the bundled TLD file.
  4. for i in lamaw: loops over each candidate TLD.
  5. with open(path) as f: opens the bundled file.
  6. VALID_TLDS = set(f.read().splitlines()[1:]) loads it the same way the site does, dropping the header line.
  7. for x in VALID_TLDS: loops over every TLD in the bundled list.
  8. if x==i: continue does nothing if the candidate is found. The continue only skips the rest of the inner loop for that one item; it does not change what gets printed.
  9. print(i) prints the candidate TLD.

Running it printed the candidate TLDs that are not in Mozilla's copy. The write-up does not list the final result separately; the point is that at least one currently delegated TLD is not in the bundled file.

Step 2: Post a reply with a link using a missing TLD

With such a TLD in hand, a reply containing a URL like https://evil.spa is submitted through the normal reply form. Because SPA is not in VALID_TLDS, the if tld in VALID_TLDS branch is skipped, the allowlist comparison never runs, and has_blocked_link returns false. The reply is not marked as spam, bypassing the filter.

Root cause

The spam filter treats the TLD as the entry condition for link checking: a link is only considered for the allowlist comparison if its TLD appears in a static, bundled copy of the IANA list. That list is a point-in-time snapshot (June 2020 in the version shown), so TLDs delegated after it are missing. so every TLD delegated after the snapshot is effectively invisible to the filter. The allowlist logic in settings.ALLOW_LINKS_FROM is never consulted for those links, and the function falls through to return False.

The design also fails open: an unrecognised TLD is treated as not-a-link rather than as suspicious. The trusted group and permission checks in KitsuneBaseForumForm are unrelated to this path and do not help, since an ordinary user posting a reply goes through check_for_spam_content as intended.

Impact

A normal user can post replies containing links to domains under TLDs missing from the bundled list without the reply being flagged as spam or held for moderation. The researcher notes that the only thing achievable with this bug is a spam filter bypass, which Mozilla treats as out of scope. The write-up does not describe any other effect, such as script execution or access to other users' data, and states that in another functionality it would have been a more interesting bug.

Fix

A possible fix would be to keep the TLD list current and make the link check fail closed, but the write-up does not discuss remediation.

Variants to test

  1. Stale data files in general. Look for any security decision driven by a bundled snapshot (TLD lists, public suffix lists, blocklists, allowlists, CVE feeds). A positive result is a value that the current upstream source contains but the bundled copy does not, and that changes the decision.
  2. Allowlist matching by suffix. The rsplit logic in has_blocked_link accepts a domain when the part before the allowed domain is empty or ends with a dot. Try domains such as evil.example.com against an allowlist entry of example.com, and try entries where the allowed domain appears mid-string, to see whether the boundary check can be defeated.
  3. Case and encoding of the TLD. The code upper-cases the matched TLD before the lookup. Try mixed case, trailing dots, punycode and percent-encoded forms in the URL to see whether the regex and the lookup disagree.
  4. Other branches of the same spam check. The toll free and NANP checks run on digits extracted from the content. Try formatting phone numbers so the digit extraction or the regexes miss them, and confirm whether the reply is still flagged.
  5. Privilege shortcuts. The trusted group and permission checks skip the spam filter entirely. On another target, check whether any of those group names or permissions can be obtained by a normal user through profile settings or invitation flows.

Glossary

  • Allowlist: a list of things that are explicitly permitted; anything not on it is treated as suspect.
  • Bounty: a payment some companies make to researchers who report valid security bugs.
  • Class: a blueprint in Python that groups related data and code together.
  • Clean (method): the step in a Django form that validates and possibly alters submitted data.
  • CVE feed: a regularly updated public list of known security vulnerabilities.
  • Django: a popular framework for building websites in Python.
  • Domain: the human-readable name of a website, such as example.com.
  • Fail closed / fail open: when a check cannot decide, failing closed blocks the thing; failing open lets it through.
  • Form: the server-side code that receives and checks what a user typed into a web page.
  • Framework: a ready-made set of building blocks for building software.
  • IANA: the organisation that maintains the official list of top level domains.
  • Inheritance: when one class of code builds on another and reuses its behaviour.
  • Kitsune: the software that runs support.mozilla.org.
  • Method: a named block of code attached to a class.
  • Moderation queue: a holding area where flagged content waits for a human to review it.
  • NANP: the North American Numbering Plan, the system behind phone numbers in the US, Canada and parts of the Caribbean.
  • Out of scope: a category of bug that a bug bounty programme does not accept or pay for.
  • Parent class: the class a child class inherits from.
  • Permission: a specific right granted to a user account, such as the ability to moderate content.
  • Public suffix list: a maintained list of domain suffixes used to decide where one domain ends and another begins.
  • Punycode: an encoding that lets domain names contain non-Latin characters.
  • Regex (regular expression): a pattern for matching text.
  • Set: a collection in Python where each item appears once and lookups are fast.
  • Snapshot: a copy of something taken at one moment in time, which does not update itself.
  • Source code review: reading a program's code to look for mistakes.
  • Spam filter: software that automatically detects unwanted or abusive content.
  • TLD (top level domain): the last part of a domain name, such as com, org or spa.
  • Toll free number: a phone number that the recipient pays for, often used by spammers.
  • Triager: the person at a bug bounty programme who reads incoming reports and decides whether they are valid.
  • Trusted group: a group of user accounts that the site treats as more reliable than ordinary users.
  • Wildcard: a symbol such as * that stands for any characters in a filename or pattern.

More by Brandon Roldan

View all

2 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.