The Public Suffix List Guide for Modern Web Applications

Author

Reads 12K

An artist’s illustration of artificial intelligence (AI). This illustration visualises an artificial neural network as physical objects. The complex structure represents a network of infor...
Credit: pexels.com, An artist’s illustration of artificial intelligence (AI). This illustration visualises an artificial neural network as physical objects. The complex structure represents a network of infor...

The Public Suffix List is a crucial component of modern web applications, providing a comprehensive list of domain suffixes to help prevent phishing and other security threats. It's a game-changer for web developers.

The list is maintained by Mozilla and is updated regularly to reflect changes in the domain name system. This ensures that web applications can stay up-to-date with the latest domain suffixes.

Here's the key: the Public Suffix List helps web applications determine whether a domain is a subdomain or a top-level domain. This is crucial for security and performance reasons.

What is the Public Suffix List

The Public Suffix List is a list of all known public suffixes, which are domain suffixes under which Internet users can directly register names. Examples of public suffixes include com, co.uk, and pvt.k12.ma.us.

The Public Suffix List is intended to enumerate all domain suffixes controlled by registrars, as well as those controlled privately. For instance, users can register second-level domains within com, such as example.com.

Credit: youtube.com, Ask Al 31: What is the Public Suffix List (PSL)?

A public suffix is not always a top-level domain (TLD); Internet users cannot always register the next level of domain, such as "co.uk" or "wy.us", because these may be controlled by domain registrars.

Some uses for the list include avoiding "supercookies", which are HTTP cookies set by related-domain attackers for high-level domain name suffixes. This is to prevent a same-site attack, where a page at foo.example.co.uk might normally have access to cookies at bar.example.co.uk.

The Public Suffix List can also be used to find DMARC policy records for email subdomains, or to highlight the most important part of a domain name in the user interface.

Here are some examples of public suffixes:

  • com
  • co.uk
  • pvt.k12.ma.us
  • github.io

Not all browsers use the Public Suffix List, but the Mozilla Foundation's project to record and share public domains across browser vendors is an important step in ensuring the security and functionality of the internet.

Using the Public Suffix List

The Public Suffix List is a powerful tool for protecting internet users from security issues like same-site attacks. It's a list of all known public suffixes, which are domain suffixes controlled by registrars or private entities.

Credit: youtube.com, Webmasters: What do they mean by using asterisks in this "Public Suffix List" of TLDs?

Some examples of public suffixes include com, co.uk, and pvt.k12.ma.us. These suffixes are used to distinguish between different domains and subdomains.

To use the Public Suffix List effectively, software developers can utilize the list to restrict adding subdomains as zones, as Cloudflare does. They can also use the list to handle cookies properly, preventing super cookie creation on public suffixes, as Google Chrome and Firefox do.

Here are some key methods for working with the Public Suffix List:

  • PublicSuffixList.getRegistrableDomain(): Returns the registrable domain or null.
  • PublicSuffixList.isRegistrable(): Returns whether a domain is registrable or not.
  • PublicSuffixList.isPublicSuffix(): Returns whether a domain is a public suffix or not.
  • PublicSuffixList.getPublicSuffix(): Returns the public suffix from a domain or null.

These methods are case insensitive, making it easier to work with the list in different scenarios.

Usage

The Public Suffix List is used in various software to handle cookies properly and prevent security issues. Cloudflare utilises the list to restrict adding subdomains as zones, while Google Chrome uses it to handle cookies on public suffixes.

Firefox uses the list to handle cookies effectively and highlight the root domains in the URL. Not all browsers use the Public Suffix List, but it's a crucial tool for maintaining online security.

Credit: youtube.com, How to use PublicSuffix & Addressable gems to parse URLs in Rails | Preview

The list is used to identify public suffixes, which are domain suffixes that can be registered by users. Some examples of public suffixes include com, co.uk, and pvt.k12.ma.us.

Here are some examples of how the Public Suffix List is used:

  • To prevent supercookie creation on public suffixes
  • To find DMARC policy records for email subdomains
  • To highlight the most important part of a domain name in the user interface
  • To improve the sorting of browser history entries by site

These are just a few examples of the many ways the Public Suffix List is used in software development. By understanding how the list works, developers can create more secure and user-friendly applications.

Effective TLD+1

The Effective TLD+1 is a crucial concept when working with the Public Suffix List. It refers to the effective top level domain plus one more label.

For example, the eTLD+1 for "foo.bar.golang.org" is "golang.org". This means that "golang.org" is the effective TLD+1 for the given domain.

The Effective TLD+1 is used to determine the public suffix of a domain. It's an important distinction because it helps identify the domain's public suffix.

In practice, the Effective TLD+1 is often used to filter out private suffixes and focus on the public suffix. This is particularly useful when working with large datasets of domain names.

For another approach, see: Golang Array of Structs

Public Suffix List Issues

Credit: youtube.com, upgrade libpsl slackware

The Public Suffix List has its own set of issues that can make its maintenance a challenge. One of the main concerns is that the list has been seen as a tool for various goals related to security, privacy, usability, and resource management, which can sometimes be in tension with each other.

The list's complexity can lead to operational challenges. Ideas for effective alternatives, such as dbound, HTTP State Tokens, and First Party Sets, have been explored but no consensus has been reached yet.

A perfect example of the tension between goals is the situation in 2021 when privacy enhancements in iOS 14.5 led to a flood of inappropriate requests for domains to be added to the Public Suffix List. This highlights the need for careful consideration when making changes to the list.

The Public Suffix List has been used to avoid "supercookies" and prevent same-site attacks. However, incorrect or outdated information in the list can lead to security issues.

Related reading: Domain Privacy

Getting Started

Student with documents and laptop happy about getting into university
Credit: pexels.com, Student with documents and laptop happy about getting into university

To get started with the Public Suffix List, it's essential to understand what it is and why it's used. The Public Suffix List is a list of domains that are not subdomains.

The list is used to determine whether a domain is a public suffix or not. A public suffix is a domain that is not a subdomain of another domain. For example, .com, .org, and .net are all public suffixes.

To use the Public Suffix List, you'll need to download the list and integrate it into your application or system. This will allow you to correctly identify public suffixes and subdomains.

Related reading: Do Not Call Register

Download with Maven

If you're using Maven in your project, you're in luck - you can easily download the Public Suffix List as part of your build process.

You can integrate the download of the latest list in your maven build process, making it a seamless part of your development workflow.

This saves you time and effort, as you won't need to manually download the list and update it in your project.

Documentation

Close-up of ethernet cables connected to a network switch panel in a data center.
Credit: pexels.com, Close-up of ethernet cables connected to a network switch panel in a data center.

Getting started with this tool requires a good understanding of its documentation.

The documentation for this tool is well-organized and easy to navigate.

You can find information on variables and functions in the documentation.

The documentation lists two functions: EffectiveTLDPlusOne and PublicSuffix.

These functions are used to work with domains and public suffixes.

Here are the functions listed in the documentation:

  • func EffectiveTLDPlusOne(domain string) (string, error)
  • func PublicSuffix(domain string) (publicSuffix string, icann bool)

You can use the PublicSuffix function to get the public suffix of a domain.

The PublicSuffix function is also used by the PublicSuffix Manager.

The PublicSuffix Manager is a useful tool for working with public suffixes.

Victoria Kutch

Senior Copy Editor

Victoria Kutch is a seasoned copy editor with a keen eye for detail and a passion for precision. With a strong background in language and grammar, she has honed her skills in refining written content to convey a clear and compelling message. Victoria's expertise spans a wide range of topics, including digital marketing solutions, where she has helped numerous businesses craft engaging and informative articles that resonate with their target audiences.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.