iTranslated by AI
Reported a Session Hijacking Vulnerability to Hashnode
In October 2022, I reported a vulnerability to Hashnode (a popular tech blogging service in the English-speaking world), and since it seems to have been fixed recently, I'm writing this article about it.
I have received permission from the team at Hashnode to write an article about the vulnerability[1].
About Hashnode's Custom Domain Feature
One of Hashnode's flagship features is the ability for each user to create their own blog and link it to a custom domain. Even on blogs with custom domains, users can use features that involve Hashnode authentication, such as Liking and following.
Features like following are available even on blogs with custom domains
This means that if you are logged into hashnode.com, your login status is maintained even when you open a user's blog (example.com).
Maintaining Login Status Across Domains is Extremely Difficult
As I have written in a previous article, safely maintaining login status across different domains becomes extremely difficult without third-party cookies.
The Session Hijacking Vulnerability that Existed in Hashnode
Curious about how Hashnode maintains login status, I investigated and found that an authentication cookie is issued for each custom domain. In other words, when you access a Hashnode blog at example.com, an authentication cookie for example.com is issued (separately from the authentication cookie for hashnode.com).
Upon examining the attributes of this cookie, I discovered it was configured so that the cookie is also sent to subdomains. This means that if an attacker hosts a site on a subdomain, they can collect the authentication cookie values for example.com.

Furthermore, since the authentication cookies for both hashnode.com and the individual custom domain blogs shared the same value, it was possible to use that cookie to retrieve or update data on Hashnode itself.
PoC
Specifically, I was able to hijack a third party's Hashnode account through the following steps:
- Create a blog on Hashnode and link a domain I own,
example.com. - Create a site on a subdomain called
evil.example.comand self-host it. - Place a link to
https://evil.example.comwithin a blog post onexample.comand trick a user into clicking it (e.g., a link like "How I went from no experience to an annual income of 50 million yen in one year"). - Looking at the HTTP request on the
evil.example.comserver, the Hashnode authentication cookie is revealed. - Open Hashnode and paste the cookie value from step 4 into the browser's cookie settings to gain access as the third-party user.
What Was the Problem?
Cookie Domain Attribute
If the value of the cookie's domain attribute is .example.com instead of example.com, that cookie will also be sent to subdomain hosts.
By omitting the domain attribute in Set-Cookie, the cookie will only be sent to the same host.
Cookie Expiration
Even if the cookie is only sent to example.com, if an attacker rewrites DNS records, it becomes possible to route requests to any site.
It would be best to shorten the cookie's expiration time so that the period during which this attack is possible is as short as possible (at the time, Hashnode's cookie expiration was set to over a year).
Make Authentication Cookie Values Unique per Domain
To minimize the damage from session hijacking in the unlikely event that a user's authentication cookie is stolen by an attacker, the cookie values should be unique per domain. At the very least, I believe the cookie values should be different between hashnode.com and each user's blog domain.
Additionally, it would be wise to limit the operations possible via authentication cookies on user custom domains to the bare minimum, such as Liking or following.
Perform Re-authentication Before Important Operations
At the time, Hashnode allowed critical operations like changing the account's email address or deleting the account using a stolen cookie. To mitigate the impact of session hijacking or XSS, it would be best to require re-authentication before these critical operations.
Self-Reflection
I also pay as much attention as possible when running my own services, but even so, vulnerabilities can sometimes creep in. While creating an application without any vulnerabilities is ideal, as the scale grows, mistakes or unforeseen cases are bound to occur.
As a developer, I've realized once again that I must always be careful and respond sincerely if a vulnerability is ever found.
-
Recently, I stopped receiving replies, so I haven't had them review the content of this article. ↩︎
Discussion