Skip to content
Account takeover Write-up Beginner

How I Hacked Netflix users & Use it free forever

Netflix session cookies did not expire on logout and could be reused, allowing an attacker who obtained a cookie to access the victim's account and bypass plan limits. The report claims this enables privilege escalation and sharing a paid account with many users.

blueberryinfosec Follow

Published on medium.com

{{media:0}}

Bbinfosec, on medium.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

Netflix accounts are protected by a session mechanism built on cookies. The researcher's claim is that Netflix permits reuse of cookies and that those cookies do not expire even when the user session is logged out. Reusing a cookie would then let someone reach any paid Netflix account without knowing its credentials, which the author frames as cookie injection leading to privilege escalation and bypass of the basic Netflix plans.

The author opens with a note that the report was closed as won't fix and is being disclosed under standard terms, and that the title might be misleading; the title was kept for explanation.

Bbinfosec
Bbinfosec From the original on medium.com

The post also spends a lot of space on background: what a cookie is, what cookie injection is, and how HttpOnly works. That background matters here because the whole argument rests on the client-side nature of cookies and on the limits of HttpOnly as a defence.

Setup

The reproduction needs very little:

  1. A cookie editor extension for your favourite browser.
  2. Access to a paid Netflix account whose cookies you can export (the author uses a friend's account).
  3. Optionally, a proxy tool such as Burp to capture HTTP cookies.
  4. Optionally, an XSS hook such as BeEF against a vulnerable website, for the case where the target request does not use HttpOnly.

The author notes that there are few areas where HttpOnly is not implemented, which is the precondition for the XSS-based path.

Finding it

The observation is simple: Netflix cookies can be reused, and they do not expire on the browser side when the user logs out. Because the session state lives in a cookie that the client holds, anyone who obtains that cookie can present it and be treated as the account holder. The author's attack chain is that Alice catches Bob's cookies through a vulnerable request and reuses them forever, since the cookies do not expire at browser side.

Before getting to Netflix, the post explains why this class of bug is usually skipped. Most bug bounty programs leave or skip cookie injection because it is basically a client-side attack carried out based on user interaction. The author points to the Netflix bug bounty exceptions on Bugcrowd, which clearly state it as out of scope.

Exploitation

Step 1: export the cookie (the noob way)

Using a cookie editor in the browser, go to your friend's account, export his or her cookie and save it as JSON. Then come to your own computer and import the JSON. No request or payload is shown for this step; it is done entirely through the cookie editor extension.

Step 2: capture the cookie through XSS (the PT way)

This path applies if the request does not use HttpOnly, and the author notes there are few areas where HttpOnly is not implemented.

  1. Send an XSS hook of a vulnerable website, for example BeEF.
  2. Capture the victim's cookie.
  3. Import it and enjoy the free Netflix.

Step 3: ask the account holder, or replay through a proxy

Alternatively, the author suggests asking your paid friend to send the cookies, or capturing the HTTP cookies in any proxy tool such as Burp and repeating the request.

Background the author uses to justify the HttpOnly bypass

The post distinguishes a simple cookie from an HttpOnly cookie. A cookie is data sent by a web server and stored in a text file through a web browser; it can also be manipulated with JavaScript code or HTTP headers during replies from a web server. An HttpOnly cookie is only accessible via HTTP(S), and access is restricted to all non-HTTP connections such as JavaScript. HttpOnly cookies are commonly used to store authentication information to protect them against XSS.

The first example shows a Set-Cookie header without the HttpOnly flag:

HTTP
Set-Cookie: <name>=<value>[; <max -Age>=<age>][; expires=<date>][; domain=<domain_name>][; path=<some_path>][; secure][; HttpOnly]</some_path></domain_name></date></age></max></value></name>set-Cookie: [redacted]=admin|134982|[redacted]; Expires=Wed, 09 Jun 2021 10:18:14 GMT; domain=www.test.org; path=/; Secure

With that cookie, executing the following JavaScript returns and displays the cookie:

HTML
<script>alert(document.cookie)</script>

The second example adds the HttpOnly flag:

HTTP
Set-Cookie: [redacted]=admin|134982|[redacted]; Expires=Wed, 09 Jun 2021 10:18:14 GMT; domain=www.test.org; path=/; Secure; HttpOnly

Running the same script again produces a dialog box with a blank message, because the HttpOnly flag makes the cookie inaccessible to JavaScript. The author then argues that in some cases it is possible to bypass this protection and extract the contents of these cookies, and links to references on XSS to session hijack, why HttpOnly won't protect you, a proof of concept for stealing HttpOnly session cookies with XSS using Apache cookie overflow (CVE-2012-0053), and a SecurityFocus thread. A cookie stealing script is linked for the case where the server is Apache.

Notes from feedback

The author answers the objection that HttpOnly exists to secure the session:

  • A cookie flagged Secure is only sent to the server if the connection is secure (HTTPS), so a man-in-the-middle attacker cannot capture it by intercepting a plain HTTP connection to the site.
  • A cookie flagged HttpOnly is not accessible to scripts, so an XSS vulnerability would not allow an attacker to directly exfiltrate it via JavaScript's document.cookie.
  • If a website has TRACE enabled, HttpOnly can be beaten.
  • HttpOnly restricts all access to document.cookie in IE7, Firefox 3 and Opera 9.5 (the author is unsure about Safari).
  • HttpOnly removes cookie information from the response headers in XMLHttpObject.getAllResponseHeaders() in IE7. It should do the same in Firefox, but it does not, because of a bug.
  • XMLHttpObjects may only be submitted to the domain they originated from, so there is no cross-domain posting of the cookies.

Additional references given are a talk on active HTTPS cookie stealing, a blog post on protecting your cookies with HttpOnly, and a Greasemonkey script for importing Netflix cookies.

On the objection that an XSS hook via BeEF cannot steal the whole user session, the author's answer is short: once you own the browser, we can do anything.

Proof of concept

The post links to a pastebin containing sample cookies which you can test. No cookie values are reproduced in the text.

Root cause

The design mistake described is that Netflix permits reuse of cookies and does not expire them when the user session is logged out. The author's general rule is that cookies should not be reused, should be randomised, should expire on post logout, should have proper server-side validation, and should carry proper attributes such as no cache and no store. The post also lists sending the cookie only to your application, not sharing it with subdomains, requiring a secure connection, and protecting against XSS.

The author's stated reason why this cannot be controlled is that users can be tracked via login sessions, whereas users cannot be tracked based on cookies. The report does not describe the server-side implementation, so the exact mechanism by which the reused cookie is accepted is not shown.

Impact

The listed impacts are privilege escalation, bypass of limited users' plans, and the ability to buy Netflix as one user and share it with as many users as you can. The attack chain is that Alice catches Bob's cookies and reuses them forever, because the cookies do not expire at browser side. The cookie can be obtained from the account holder directly, from a cookie editor export, from a proxy capture, or through XSS where HttpOnly is not enforced.

Fix

The report does not describe any fix. It records that the issue was reported to Netflix through Bugcrowd on 9 November 2018, closed as out of scope on 13 November 2018, explained with an attack chain and proof video the same day, escalated to Bugcrowd support on 14 November 2018, confirmed as won't fix by the Bugcrowd team on 15 November 2018, and publicly disclosed through the Medium blog on 19 November 2018. The author's own recommendations are the cookie rules above: no reuse, randomisation, expiry on logout, server-side validation, and proper attributes.

Variants to test

  1. Log out of an account and replay the captured cookie in a fresh browser profile. A positive result is that the session is still accepted after logout.
  2. Export cookies from one browser with a cookie editor and import them into another machine. A positive result is access to the account without entering credentials.
  3. Capture cookies through a proxy such as Burp and repeat the request from a different client. A positive result is the same authenticated response.
  4. Look for endpoints that do not set HttpOnly on session cookies, then use an XSS hook such as BeEF to read them. A positive result is a cookie value returned to the hook.
  5. Check whether TRACE is enabled on the target, since the author states HttpOnly can be beaten if it is. A positive result is that TRACE is enabled on the target.
  6. Test whether cookies are shared with subdomains, since the author lists that as a rule to enforce. A positive result is a cookie shared with subdomains.

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. 15 min read.

What happened, in plain words

A security researcher found that Netflix accounts could be accessed by copying a small piece of data called a cookie from one browser to another. The claim is that Netflix lets cookies be reused and that those cookies do not expire even after the user logs out. If that is true, anyone who gets hold of a paid user's cookie can open that account without knowing the password.

The researcher reported it to Netflix through the Bugcrowd bug bounty platform. Netflix closed it as out of scope, and later the Bugcrowd team confirmed it as won't fix. The researcher then published the details on Medium on 19 November 2018. The post opens with a note that the title might be misleading and that the title was kept for explanation.

Bbinfosec
Bbinfosec From the original on medium.com

The image above is the author's avatar on the Medium post, credited as Bbinfosec.

A bug bounty is a programme where a company invites outside people to report security problems and sometimes pays for them. Each programme has rules about what counts, and things outside those rules are called out of scope. The researcher points out that most programmes leave cookie injection out of scope because it is basically a client-side attack, meaning it depends on something happening on the user's own computer or with the user's interaction. The post links to the Netflix bug bounty exceptions on Bugcrowd, which it says clearly state this as out of scope.

The setup you need

To follow the reproduction you need very little:

  1. A cookie editor extension for your favourite browser. This is a small add-on that lets you look at, change, export and import the cookies your browser holds.
  2. Access to a paid Netflix account whose cookies you can export. The author uses a friend's account.
  3. Optionally, a proxy tool such as Burp. A proxy sits between your browser and the website and lets you read and repeat the requests, including the cookies inside them.
  4. Optionally, an XSS hook such as BeEF, used against a vulnerable website, for the case where the target request does not use HttpOnly. XSS means cross-site scripting: getting a website to run JavaScript that an attacker wrote. BeEF is a tool that manages such hooked browsers.

The author notes there are few areas where HttpOnly is not implemented, and that this is the precondition for the XSS-based path. HttpOnly is explained below.

Background: what a cookie is

Before the Netflix part, the post explains the basics, because the whole argument rests on cookies living on the client side.

Cookies are small files stored on a user's computer. They hold a modest amount of data specific to a particular client and website, and they can be accessed either by the web server or by the client computer. This lets the server deliver a page tailored to a particular user, or lets the page contain script that is aware of the data in the cookie and can carry information from one visit to the website, or a related site, to the next.

A useful comparison: a cookie is like a cloakroom ticket. You hand in your coat, you get a small ticket with a number on it, and later you show the ticket to get the coat back. The ticket itself is not the coat. It is just a reference the staff recognise. If someone else picks up your ticket, the staff will hand them your coat, because the ticket is all they check.

Cookies are simply key/value pairs that let us get around HTTP being a stateless protocol. Stateless means the server does not remember you between requests: each request arrives on its own, with no memory of the previous one. When a developer has data they wish to last for more than one connection, they can use cookies to store that data on the client side. This tends to be handled by the programming language being used, but underneath it is done with HTTP headers. Headers are the labelled lines sent along with every request and response, separate from the page content.

When the server wants to set a cookie, it passes back a header named Set-Cookie with the key-value pair and some options. On subsequent requests the client sends along its own header to let the server know the name and value of its stored cookies. The server will not keep sending the cookies back; it only sends them if there is a change.

The post suggests you can see all the headers for yourself using the LiveHeaders plugin for Firefox.

The problem with cookies

This data is completely in control of the client. It is trivial to change the values of a cookie. That means that, just like post and get data, all cookie data must be validated in some way. At the same time you want to avoid storing sensitive information such as passwords, because cookies are stored in cleartext and anyone with access to the computer later can easily pick those up. The author mentions knowing of at least one security forum that was hacked in this way. It is also important to note that HTTP does not encrypt the headers in any way. If the connection is not over SSL, it is not protected from snooping eyes. SSL is the older name for the encryption layer that HTTPS uses.

Session cookies are no different from any other cookie: their value is just a simple ID. Those IDs are susceptible to all of the same limitations as other cookies. The real power behind sessions happens server side, where the ID is used to pull out data stored on the server. This has many benefits over storing data directly in the cookie itself: data cannot be manipulated by the user, large amounts of data can be stored without having to send it back and forth with each request, and you can store data you otherwise would not want the client to have access to.

A session is the server's memory of you being logged in. The cookie carries only the session ID, like the number on the cloakroom ticket, and the server looks up the real details in its own records.

What cookie injection is

The majority of web applications are based on an authentication mechanism that enables them to define user privileges. This mechanism is based on sessions. It defines cookies whose validity period depends on the parameters. If the controls are only based on these cookies, the application is likely to be vulnerable, since cookies are saved on local machines. Hence it is easy to modify their values or manually create new cookies.

Cookie injection, in plain terms, is putting a cookie into a browser that the browser did not legitimately receive, or changing one it did receive, so that the server treats you as someone else. The basic rule of security would be handling secure cookies, and cookies should expire whenever the session is closed out.

The post lists some basic cookie security rules:

  • Cookies should not be reused.
  • Cookies should be randomised.
  • Cookies should expire on post logout.
  • Cookies should have proper server side validations.
  • Cookies should have proper attributes like no cache, no store, etc.
  • Send the cookie to only your application.
  • Do not share the cookie with subdomains.
  • Require a secure connection.
  • Protect against XSS exploits.

What the bug is

Netflix permits reuse of cookies, and their cookies will not expire even when the user session gets logged out. Reuse of cookies would let you gain access to any paid Netflix user account without their credentials.

Step 1: the noob way

This is the simplest reproduction, done entirely through a cookie editor extension. No request or payload is shown for this step.

  1. You might need any cookie editor of your favourite browser.
  2. Go to your friend's account, export his or her cookie, and save it as JSON. JSON is a plain text format for structured data, so the exported cookie becomes a small text file you can carry around.
  3. Now come to your computer and import the JSON.

Step 2: the PT way, through XSS

This path applies if the request does not use HttpOnly. The author notes there are few areas where HttpOnly is not implemented.

  1. Send an XSS hook of a vulnerable website, for example BeEF.
  2. Capture the victim's cookie.
  3. Import it and enjoy the free Netflix.

An XSS hook means planting script on a site the victim visits, so that when the victim loads the page the script runs in their browser and reports back to you. The reason to try this route is that a normal script cannot read an HttpOnly cookie, so you need a place where the cookie is not marked HttpOnly.

Alternatively, the author says it might be weird, but you can ask your paid friend to send the cookies for you, and capture the HTTP cookies in any proxy tool such as Burp, then repeat the request.

How HttpOnly works, with examples

Before entering the heart of the matter, it is important to distinguish between a simple cookie and an HttpOnly cookie, since they are really two completely different concepts. Basically a cookie is data sent by a web server and stored in a text file through a web browser; it can also be manipulated with JavaScript code or HTTP headers during the replies from a web server.

An HttpOnly cookie has the distinction of being only accessible via HTTP(S). Access to this element is restricted to all non-HTTP connections such as JavaScript. HttpOnly cookies are commonly used to store authentication information in order to protect them against XSS attacks. The article aims to show how it is possible to circumvent this protection, and how to deal with this kind of attack.

First example

HTTP
Set-Cookie: <name>=<value>[; <max -Age>=<age>][; expires=<date>][; domain=<domain_name>][; path=<some_path>][; secure][; HttpOnly]</some_path></domain_name></date></age></max></value></name>set-Cookie: [redacted]=admin|134982|[redacted]; Expires=Wed, 09 Jun 2021 10:18:14 GMT; domain=www.test.org; path=/; Secure

Line by line, in plain words:

  • The first part is a template showing the shape of a Set-Cookie header: a name, a value, and optional pieces in square brackets. Square brackets here mean optional, not literal characters.
  • max -Age and expires control how long the cookie lasts.
  • domain says which site the cookie belongs to, and path says which part of the site it applies to.
  • secure means the cookie is only sent over an encrypted connection.
  • HttpOnly means scripts cannot read it. In this first example the template lists it as an option, but the actual cookie line below does not include it.
  • The second part is a real example cookie for a WordPress site. Its name is [redacted] and its value is admin|134982|[redacted].
  • It expires on Wed, 09 Jun 2021 at 10:18:14 GMT, belongs to www.test.org, applies to the whole site (path=/), and is marked Secure.
  • Crucially, it is not marked HttpOnly.

If we execute the following JavaScript code:

HTML
<script>alert(document.cookie)</script>

Your browser will return and display the cookie. document.cookie is the browser's built-in way for a page's script to read the cookies for that page, and alert shows the result in a pop-up box. Because the cookie is not HttpOnly, the script can see it.

Second example

HTTP
Set-Cookie: [redacted]=admin|134982|[redacted]; Expires=Wed, 09 Jun 2021 10:18:14 GMT; domain=www.test.org; path=/; Secure; HttpOnly

This is the same cookie as before, with one addition at the end: HttpOnly. Everything else, the name, the value, the expiry, the domain, the path and Secure, is unchanged.

Now if we execute once again the following JavaScript code:

HTML
<script>alert(document.cookie)</script>

The result will be a dialog box displaying a blank message. The HttpOnly flag makes the cookie inaccessible to JavaScript. However, the author says it is possible in some cases to bypass this protection and extract the contents of these cookies.

References the author gives for the bypass

The post links to several sources on why HttpOnly is not a complete answer:

  • A Medium post on XSS to session hijack.
  • A gnucitizen.org article titled "Why HttpOnly Won't Protect You".
  • A proof of concept on stealing HttpOnly session cookies with XSS using Apache cookie overflow, CVE-2012-0053.
  • A SecurityFocus thread.

It also links a cookie stealing script on pastebin for the case where the server is Apache.

Notes after feedback from friends

The author answers the objection that HttpOnly exists to secure the session:

  • A cookie flagged Secure is only sent to the server if the connection is secure, that is HTTPS. A man-in-the-middle attacker cannot capture it by intercepting a plain HTTP connection to your site. A man-in-the-middle is someone positioned on the network path between you and the server.
  • A cookie flagged HttpOnly is not accessible to scripts. An XSS vulnerability on your site would not allow an attacker to directly exfiltrate an HttpOnly cookie via JavaScript's document.cookie.
  • In addition, if a website has TRACE enabled, HttpOnly can be beaten. TRACE is an HTTP method where the server echoes back the request it received, which can include headers.
  • HttpOnly restricts all access to document.cookie in IE7, Firefox 3 and Opera 9.5. The author is unsure about Safari.
  • HttpOnly removes cookie information from the response headers in XMLHttpObject.getAllResponseHeaders() in IE7. It should do the same thing in Firefox, but it does not, because of a bug.
  • XMLHttpObjects may only be submitted to the domain they originated from, so there is no cross-domain posting of the cookies.

Additional references given are a talk on active HTTPS cookie stealing, a blog post on protecting your cookies with HttpOnly, and a Greasemonkey script for importing Netflix cookies. Greasemonkey is a browser add-on that runs user-written scripts on pages.

On the objection that an XSS hook via BeEF cannot steal the whole user session, the answer is short: once you own the browser, we can do anything.

The attack chain and its impact

Alice sends a vulnerable request to catch Bob's cookies and reuses it forever. Since cookies do not expire at browser side, it can be used forever.

The listed impacts are:

  • Privilege escalation. Privilege escalation means getting more access than you are entitled to, here moving from no account, or a basic plan, to a paid account.
  • Bypass of limited users' plans.
  • You can buy Netflix as one user and share it with as many users as you can.

Why it cannot be controlled

The author's stated reason is that users can be tracked via login sessions, whereas we cannot track users based on cookies. The report does not describe the server-side implementation, so the exact mechanism by which the reused cookie is accepted is not shown.

How you can secure yourself

  • Do not fall for false popups.
  • Always check on your concurrent login. Concurrent login means the list of devices or sessions currently signed in to your account.
  • More importantly, never reuse your passwords and never keep weak passwords.

Proof of concept

The post links to a pastebin containing sample cookies which you can test. No cookie values are reproduced in the text.

Disclosure timeline

  • 9 November 2018: issue reported to Netflix through Bugcrowd.
  • 13 November 2018: closed as out of scope.
  • 13 November 2018: attack chain explained with a proof video.
  • 14 November 2018: contacted Bugcrowd support.
  • 15 November 2018: won't fix confirmed by the Bugcrowd team.
  • 19 November 2018: public disclosure through the Medium blog.

The report does not describe any fix. The author's own recommendations are the cookie rules above: no reuse, randomisation, expiry on logout, server-side validation, and proper attributes.

Variants to test

  1. Log out of an account and replay the captured cookie in a fresh browser profile. A positive result is that the session is still accepted after logout.
  2. Export cookies from one browser with a cookie editor and import them into another machine. A positive result is access to the account without entering credentials.
  3. Capture cookies through a proxy such as Burp and repeat the request from a different client. A positive result is the same authenticated response.
  4. Look for endpoints that do not set HttpOnly on session cookies, then use an XSS hook such as BeEF to read them. A positive result is a cookie value returned to the hook.
  5. Check whether TRACE is enabled on the target, since the author states HttpOnly can be beaten if it is. A positive result is that TRACE is enabled on the target.
  6. Test whether cookies are shared with subdomains, since the author lists that as a rule to enforce. A positive result is a cookie shared with subdomains.

Glossary

  • Bug bounty: a programme where a company invites outside researchers to report security problems, sometimes for a reward.
  • Out of scope: a report or technique that the programme's rules exclude from consideration.
  • Won't fix: the vendor's decision not to change the product in response to a report.
  • Cookie: a small key/value piece of data a website stores in your browser and gets back on later requests.
  • Cookie injection: placing or altering a cookie in a browser so the server treats you as another user.
  • Session: the server's record of you being logged in, referenced by an ID kept in a cookie.
  • Session cookie: the cookie that carries the session ID.
  • Stateless protocol: a protocol such as HTTP where each request is independent and the server keeps no memory between them.
  • Header: a labelled line sent with an HTTP request or response, separate from the page content.
  • Set-Cookie: the response header a server uses to give the browser a cookie and its options.
  • HttpOnly: a cookie flag that stops page scripts from reading the cookie.
  • Secure: a cookie flag that sends the cookie only over an encrypted HTTPS connection.
  • HTTPS / SSL: the encrypted version of HTTP; SSL is the older name for the encryption layer.
  • Cleartext: data stored or sent without encryption.
  • XSS (cross-site scripting): getting a website to run JavaScript written by an attacker.
  • XSS hook: script planted on a page that runs in the victim's browser and reports back to the attacker.
  • BeEF: a tool for managing browsers hooked through XSS.
  • Proxy tool (Burp): software that sits between browser and server so you can read and repeat requests.
  • Man-in-the-middle: an attacker positioned on the network path between you and the server.
  • TRACE: an HTTP method where the server echoes back the request it received.
  • CVE-2012-0053: a known Apache vulnerability referenced by the author for leaking cookies.
  • Privilege escalation: gaining more access than you are entitled to.
  • JSON: a plain text format for structured data.
  • Greasemonkey: a browser add-on that runs user-written scripts on pages.
  • Concurrent login: the devices or sessions currently signed in to an account.

More from Netflix

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.