Skip to content
IDOR Write-up Intermediate

IDOR leads to leaked the likes count even though is hidden by victim | YouTube ($XXXX)

The like and dislike counts of a video were meant to be hidden when the uploader chose not to show them, but an API response still exposed an average rating value. By combining that rating with the known like count, an attacker could calculate the hidden dislike count.

R ando Follow

Published on bloggerrando.blogspot.com

April 20, 2021

R ando (@Rando02355205), on bloggerrando.blogspot.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. 6 min read.

Context

YouTube lets a video owner hide the number of likes and dislikes that a video has received. The setting is exposed in the video edit page as a choice between showing and not showing how many viewers liked or disliked the video. The intent is that the counts stay private.

The researcher found that the hidden counts could still be recovered. The likes count could be read directly, and the dislikes count could be derived from the averageRating value that the player endpoint returns, combined with the likes count. The report was filed against Google's YouTube program and was awarded $1,000.

Setup

Two roles are involved: a victim who owns a video with the counts hidden, and an attacker with their own YouTube account. No special tooling is described beyond a browser and the ability to observe the player request. The victim side requires a live or scheduled live video, because that is the flow the researcher used to reach the edit page and the visibility setting.

Finding it

The researcher noticed that the player endpoint still returned an averageRating field for a video whose like and dislike counts had been hidden by the owner. That field is a number between 1 and 5, and it is derived from the ratio of likes to dislikes. On its own it does not reveal either count, but combined with a known likes count it is enough to solve for the dislikes.

The researcher also observed that the likes count itself could be leaked, which is the direct IDOR-style part of the finding: the hidden value was still reachable through the player endpoint.

Exploitation

Step 1: Prepare the victim video

  1. Create ---> Go live.
  2. Create a live video or scheduled video.
  3. Edit video.
  4. Show how many viewers like and dislike this video ---> Don't show how many viewers like and dislike this video.
  5. Save.

This produces a video whose like and dislike counts are hidden from viewers.

Step 2: Prepare the attacker account

  1. Create ---> Go live.
  2. Create a live video.

The attacker creates a live video of their own, as listed in the reproduction steps.

Step 3: Read the hidden values from the player endpoint

The researcher queries the player endpoint for the victim video:

HTTP
[POST] https://www.youtube.com/youtubei/v1/player?key=...

"videoId":"videoId"

The request carries a key query parameter and a videoId in the body, both shown as placeholders. The researcher used this request to obtain the averageRating value for the victim video.

Step 4: Understand what averageRating means

By liking and disliking the victim video and watching the resulting averageRating, the researcher mapped the value to the underlying counts. Green is like(s) and red is dislike(s).

Text
"averageRating": 1 - 5

1 like(s) / 0 dislike(s) = averageRating: 5 (without dislike) %100
2 like(s) / 0 dislike(s) = averageRating: 5 (without dislike) %100
3 like(s) / 0 dislike(s) = averageRating: 5 (without dislike) %100

1 like(s) / 1 dislike(s) = averageRating: 3 (like and dislike is the same) %50
2 like(s) / 2 dislike(s) = averageRating: 3 (like and dislike is the same) %50
3 like(s) / 3 dislike(s) = averageRating: 3 (like and dislike is the same) %50

0 like(s) / 1 dislike(s) = averageRating: 1 (without like) %0
0 like(s) / 2 dislike(s) = averageRating: 1 (without like) %0
0 like(s) / 3 dislike(s) = averageRating: 1 (without like) %0

The mapping between averageRating and the like percentage is:

averageRating Percentage
5.000 100.0% (4.000)
4.000 75.00% (3.000)
3.000 50.00% (2.000)
2.000 25.00% (1.000)
1.100 2.50% (0.100)
1.010 0.25% (0.010)
1.001 0.025% (0.001)
1.000 0% (0.000)

So averageRating encodes the like share of the total votes, not the raw counts.

Step 5: Derive the dislikes count

With the likes count known and averageRating known, the dislikes count follows from the ratio. The researcher's example: the victim video has 100 likes and 100 dislikes.

Text
averageRating = 3
Like(s) = 100

100 likes*(5-averageRating)/(averageRating-1)
100*(5-3)/(3-1)
100*(2)/(2) = 100 dislikes

The formula is likes * (5 - averageRating) / (averageRating - 1). It works because averageRating is a linear function of the like-to-dislike ratio, so once one count is known the other can be solved for.

Step 6: Handle the zero-like edge case

If the video has no likes, the percentage is 0% and averageRating is 1, which makes the formula divide by zero. The researcher notes that you can click like on the video yourself so that the percentage is no longer 0% and averageRating is no longer 1. The dislikes count cannot be determined if the video has no likes.

The researcher provided a small PHP calculator that implements the formula:

PHP
<?php error_reporting(E_ALL ^ E_NOTICE); ?>

<?php

$averageRating=$_POST['averageRating'];
$like=$_POST['like'];

if ($averageRating <= 1)
{
 $like=0;
}

if (($averageRating > 1 AND $averageRating <= 5) AND $like >= 1)
{
 $percentage=($averageRating-1)*25;
 $percentageDislike=100-$percentage;
 $dislike=($like*(5-$averageRating))/($averageRating-1);
}
else
{
 $percentage=0;
 $percentageDislike=0;
 $dislike=0;
}

?>

<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post'>
 averageRating: <input type='text' name='averageRating' value='<?php echo $averageRating; ?>'>
 <br>
 Like(s): <input type='text' name='like' value='<?php echo $like; ?>'>
 <input type='submit'>
</form>

<?php echo "<font color='green'> Like(s) 👍 $like</font> ($percentage%) | <font color='red'>Dislike(s) 👎 $dislike</font> ($percentageDislike%)" ?>

The script takes averageRating and like as POST parameters, computes the like percentage as (averageRating - 1) * 25, the dislike percentage as the remainder, and the dislikes count with the same formula. When averageRating is 1 or less it forces the likes to 0 and reports zeros.

A proof-of-concept video accompanies the report:

Or watch on YouTube
From the original on bloggerrando.blogspot.com

Root cause

The visibility setting on the video edit page controls what the UI shows, but the player endpoint still returns averageRating for the video regardless. That value is a function of the like and dislike counts, so hiding the counts in the UI does not hide the underlying data. The likes count is also reachable through the same endpoint, which is the IDOR-style part of the issue: the hidden value is returned to a party who should not receive it.

Impact

An attacker can leak the likes count of a victim video whose counts are hidden, and from that plus averageRating can compute the dislikes count. The technique requires the video to have at least one like; if it has none, the attacker can add a like themselves to move the percentage off 0%, but the dislikes count cannot be determined for a video with no likes.

Fix

The report records that the issue was fixed on 04/21/2021, the same day the bounty was awarded. The report does not describe the change that was made.

Variants to test

  1. Other endpoints that return rating or engagement metadata for the same object, such as search, recommendations or embed responses. A positive result is any of them returning averageRating or a like count for a video whose counts are hidden.
  2. Other privacy toggles on the same product, such as hidden subscriber counts or hidden view counts. A positive result is the hidden value appearing in an API response that the UI does not show.
  3. The same ratio-derived field on other platforms that expose a star or percentage rating alongside a hidden vote count. A positive result is a rating value that changes predictably as you add votes, letting you solve for the hidden count.
  4. The zero-vote edge case on any target: check whether the rating field still leaks a value when there are no votes, and whether adding one vote of your own moves it into a solvable range.

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

What happened, in plain words

YouTube lets the owner of a video decide whether viewers can see how many people liked or disliked it. There is a setting on the video edit page: you can choose to show the like and dislike counts, or to hide them. When the owner hides them, the idea is that nobody else should be able to find out those numbers.

The researcher found that the numbers were not really hidden. The likes count could still be read from a request that the YouTube player makes behind the scenes, and the dislikes count could be worked out from a value called averageRating that the same request returns. averageRating is a score between 1 and 5 that YouTube calculates from the mix of likes and dislikes. On its own it does not tell you either number, but if you also know the likes count, you can do a little arithmetic to get the dislikes count.

The report was sent to Google's YouTube bug bounty programme and was rewarded with $1,000.

Some background you need first

Before the steps make sense, here are a few ideas explained from scratch.

A web page is not the whole story. When you open YouTube in a browser, the page you see is only the visible part. Behind it, the browser is constantly sending requests to YouTube's servers and receiving data back. Some of that data is used to draw the page, and some of it is never shown to you at all. If a number is hidden on screen, it may still be travelling to your browser inside one of those responses.

An API is a way for programs to talk to each other. Think of a restaurant: you do not walk into the kitchen, you tell the waiter what you want and the waiter brings it back. An API (Application Programming Interface) is the waiter. Your browser asks a YouTube API for information about a video, and the API answers with data, usually in a structured format that programs can read easily.

An endpoint is one specific address in that API. If the API is the restaurant, an endpoint is one particular dish on the menu. The endpoint in this report is the "player" endpoint, which is what the YouTube player asks for when it needs the details of a video so it can start playing it.

A request is the message your browser sends. It has a method (such as POST, meaning "here is some data, please process it"), an address (the URL), and often a body containing data. The body here contains the ID of the video you are asking about.

An API key is a password-like string that identifies the application making the request. In the URL below you will see key=.... It is a value the web client sends so the server knows which application is calling. It is not your personal password; it belongs to the YouTube web client itself.

A video ID is the short code that identifies one specific video. Every YouTube video has one, and it appears in the video's URL. The request below sends it in the body as videoId.

IDOR stands for Insecure Direct Object Reference. It is a fancy way of saying: a program lets you ask for a specific object (here, a video's data) by its identifier, and it does not properly check whether you are allowed to see everything it sends back. Imagine a hotel clerk who, when you ask for your own room key, also hands you a printout of another guest's bill because the computer did not check whose bill you asked for. The identifier (the video ID) is direct, and the check is missing or incomplete.

A logic flaw is a mistake in the rules of the application rather than in its plumbing. The code may run perfectly, but it enforces the wrong rule, or enforces a rule in one place (the screen) and forgets it in another (the API).

A token or cookie is a small piece of data your browser stores and sends with requests so the server can recognise your session. This report does not involve stealing anyone's token; the point is simply that the server returned data it should have kept back.

A bug bounty programme is a scheme where a company pays researchers for reporting security problems responsibly. Google runs one for its products, including YouTube.

Setting up the victim's video

The report describes two roles: a victim, who owns a video with the counts hidden, and an attacker, who has their own ordinary YouTube account. No special tools are needed beyond a browser and the ability to look at the request the player makes.

The victim side uses a live or scheduled live video, because that is the flow the researcher used to reach the edit page and the visibility setting.

  1. Create ---> Go live.
  2. Create a live video or scheduled video.
  3. Edit video.
  4. Show how many viewers like and dislike this video ---> Don't show how many viewers like and dislike this video.
  5. Save.

The result is a video whose like and dislike counts are hidden from viewers. On screen, nobody should be able to see the numbers.

Setting up the attacker's account

  1. Create ---> Go live.
  2. Create a live video.

The attacker creates a live video of their own, as listed in the reproduction steps.

Reading the hidden values

The researcher asked the player endpoint about the victim's video:

HTTP
[POST] https://www.youtube.com/youtubei/v1/player?key=...

"videoId":"videoId"

Line by line:

  • [POST] is the method. POST means the browser is sending data to the server, not just asking for a page.
  • https://www.youtube.com/youtubei/v1/player is the address of the player endpoint. This is the API the YouTube player uses to fetch a video's details.
  • ?key=... is a query parameter called key. It carries the API key the web client uses. The report shows it as ... rather than the real value.
  • The blank line separates the address from the body of the request.
  • "videoId":"videoId" is the body: a small piece of JSON (a text format for structured data) that says which video is being asked about. The report uses the placeholder videoId in place of a real one.

The important part is what comes back. The researcher used this request to obtain the averageRating value for the victim video. The likes count itself is also reachable through this endpoint, which is the IDOR-style part of the finding: a value the owner chose to hide is still being handed out.

What averageRating actually means

averageRating is a number between 1 and 5. It is not a count; it is a score derived from the ratio of likes to dislikes. To understand it, the researcher liked and disliked the victim's video and watched how the value changed. In the report, green is like(s) and red is dislike(s).

Text
"averageRating": 1 - 5

1 like(s) / 0 dislike(s) = averageRating: 5 (without dislike) %100
2 like(s) / 0 dislike(s) = averageRating: 5 (without dislike) %100
3 like(s) / 0 dislike(s) = averageRating: 5 (without dislike) %100

1 like(s) / 1 dislike(s) = averageRating: 3 (like and dislike is the same) %50
2 like(s) / 2 dislike(s) = averageRating: 3 (like and dislike is the same) %50
3 like(s) / 3 dislike(s) = averageRating: 3 (like and dislike is the same) %50

0 like(s) / 1 dislike(s) = averageRating: 1 (without like) %0
0 like(s) / 2 dislike(s) = averageRating: 1 (without like) %0
0 like(s) / 3 dislike(s) = averageRating: 1 (without like) %0

What this shows:

  • If there are likes and no dislikes at all, the score sits at 5 and the like share is 100%.
  • If likes and dislikes are equal in number, the score is 3 and the like share is 50%, whatever the actual counts are. One like and one dislike gives the same score as three and three.
  • If there are dislikes and no likes, the score is 1 and the like share is 0%.

The mapping between the score and the like percentage is:

averageRating Percentage
5.000 100.0% (4.000)
4.000 75.00% (3.000)
3.000 50.00% (2.000)
2.000 25.00% (1.000)
1.100 2.50% (0.100)
1.010 0.25% (0.010)
1.001 0.025% (0.001)
1.000 0% (0.000)

So averageRating tells you the like share of all the votes, not how many votes there are. That is why it is not enough on its own, and why the likes count matters.

Working out the dislikes count

If you know the likes count and the score, the dislikes count follows from the ratio. The researcher's example: the victim's video has 100 likes and 100 dislikes.

Text
averageRating = 3
Like(s) = 100

100 likes*(5-averageRating)/(averageRating-1)
100*(5-3)/(3-1)
100*(2)/(2) = 100 dislikes

Line by line:

  • averageRating = 3 and Like(s) = 100 are the two known values.
  • 100 likes*(5-averageRating)/(averageRating-1) is the formula: take the likes count, multiply by 5 minus the score, then divide by the score minus 1.
  • 100*(5-3)/(3-1) substitutes the numbers: 5 minus 3 is 2, and 3 minus 1 is 2.
  • 100*(2)/(2) = 100 dislikes gives the answer: 100 dislikes.

The formula is likes * (5 - averageRating) / (averageRating - 1). It works because the score moves in a straight, predictable line with the ratio of likes to dislikes, so once one count is known the other can be solved for.

The case where there are no likes

If the video has no likes, the like share is 0% and the score is 1. Put 1 into the formula and you divide by zero, which has no answer. The researcher notes that you can click like on the video yourself, so the percentage is no longer 0% and the score is no longer 1. The dislikes count cannot be determined if the video has no likes.

To make the arithmetic easy, the researcher wrote a small PHP calculator. PHP is a programming language commonly used for web pages; this script is a page with a form that does the maths for you.

PHP
<?php error_reporting(E_ALL ^ E_NOTICE); ?>

<?php

$averageRating=$_POST['averageRating'];
$like=$_POST['like'];

if ($averageRating <= 1)
{
 $like=0;
}

if (($averageRating > 1 AND $averageRating <= 5) AND $like >= 1)
{
 $percentage=($averageRating-1)*25;
 $percentageDislike=100-$percentage;
 $dislike=($like*(5-$averageRating))/($averageRating-1);
}
else
{
 $percentage=0;
 $percentageDislike=0;
 $dislike=0;
}

?>

<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post'>
 averageRating: <input type='text' name='averageRating' value='<?php echo $averageRating; ?>'>
 <br>
 Like(s): <input type='text' name='like' value='<?php echo $like; ?>'>
 <input type='submit'>
</form>

<?php echo "<font color='green'> Like(s) 👍 $like</font> ($percentage%) | <font color='red'>Dislike(s) 👎 $dislike</font> ($percentageDislike%)" ?>

Line by line:

  • <?php error_reporting(E_ALL ^ E_NOTICE); ?> turns on error reporting but suppresses notices, so small warnings do not clutter the page.
  • $averageRating=$_POST['averageRating']; reads the score the user typed into the form. $_POST is how PHP receives data sent with a POST request.
  • $like=$_POST['like']; reads the likes count the user typed in.
  • if ($averageRating <= 1) { $like=0; } handles the zero-like case: if the score is 1 or less, the likes are forced to 0.
  • if (($averageRating > 1 AND $averageRating <= 5) AND $like >= 1) is the condition for doing real maths: the score must be above 1 and at most 5, and there must be at least one like.
  • $percentage=($averageRating-1)*25; converts the score into the like percentage. A score of 3 gives (3-1)*25 = 50%.
  • $percentageDislike=100-$percentage; the dislike percentage is whatever is left over from 100%.
  • $dislike=($like*(5-$averageRating))/($averageRating-1); is the same formula as before, in code.
  • The else block sets all three values to 0 when the condition is not met, so the page shows zeros instead of an error.
  • The <form> block draws two text boxes, one for the score and one for the likes, and a submit button. $_SERVER['PHP_SELF'] makes the form submit back to the same page.
  • The final echo prints the result: likes in green with their percentage, and dislikes in red with their percentage.

A proof-of-concept video accompanies the report:

Or watch on YouTube
From the original on bloggerrando.blogspot.com

Why this happens

The show/hide setting on the video edit page controls what the page displays, but the player endpoint still returns averageRating for the video regardless. That value is a function of the like and dislike counts, so hiding the counts on screen does not hide the underlying data. The likes count is reachable through the same endpoint too, which is the IDOR-style part: a hidden value is returned to someone who should not receive it.

What an attacker gets

An attacker can leak the likes count of a victim video whose counts are hidden, and from that plus averageRating can compute the dislikes count. The technique needs the video to have at least one like. If it has none, the attacker can add a like themselves to move the percentage off 0%, but the dislikes count cannot be determined for a video with no likes.

How it was fixed

The report records that the issue was fixed on 04/21/2021, the same day the bounty was awarded. It does not describe the change that was made.

Other places worth checking

  1. Other endpoints that return rating or engagement data for the same object, such as search, recommendations or embed responses. A positive result is any of them returning averageRating or a like count for a video whose counts are hidden.
  2. Other privacy toggles on the same product, such as hidden subscriber counts or hidden view counts. A positive result is the hidden value appearing in an API response that the page does not show.
  3. The same ratio-derived field on other platforms that expose a star or percentage rating alongside a hidden vote count. A positive result is a rating value that changes predictably as you add votes, letting you solve for the hidden count.
  4. The zero-vote edge case on any target: check whether the rating field still leaks a value when there are no votes, and whether adding one vote of your own moves it into a solvable range.

Glossary

  • API: a way for programs to talk to each other, like a waiter carrying requests to the kitchen and answers back.
  • API key: a string that identifies the application making a request, shown in the URL as key=....
  • averageRating: a score between 1 and 5 that YouTube derives from the ratio of likes to dislikes.
  • Bug bounty programme: a scheme where a company pays researchers for reporting security problems responsibly.
  • Cookie: a small piece of data a browser stores and sends with requests so the server can recognise your session.
  • Endpoint: one specific address in an API, such as the player endpoint.
  • IDOR (Insecure Direct Object Reference): a flaw where a program lets you ask for an object by its identifier and does not properly check what it sends back.
  • JSON: a text format for structured data, used in request and response bodies.
  • Logic flaw: a mistake in the rules an application enforces, rather than in its plumbing.
  • PHP: a programming language commonly used to build web pages.
  • POST: an HTTP method used when the browser sends data to the server for processing.
  • Query parameter: a value attached to a URL after a ?, such as key=....
  • Request: the message a browser sends to a server, with a method, an address and often a body.
  • Response: the data a server sends back.
  • Token: a small piece of data used to identify a session or application.
  • Video ID: the short code that identifies one specific YouTube video.
  • Victim: in this report, the owner of the video whose like and dislike counts are hidden.
  • Attacker: in this report, the person with their own YouTube account who reads the hidden values.

More by R ando

View all

11 more disclosed reports, best first.

More from Google

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Insecure direct object reference (IDOR)

The lesson behind this report.

One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.