# history.length reads 1 in a brand-new profile, every time

> history.length is a small fingerprint: a freshly launched browser reads 1, every launch. Pin a fake number and pushState stops moving it, so ours is an offset.

Source: https://mosaicbrowser.com/blog/history-length-fresh-profile

## history.length reads 1 in a brand-new profile, every time

history.length is a small fingerprint: a freshly launched browser reads 1, every launch. Pin a fake number and pushState stops moving it, so ours is an offset.

![1: A fresh tab reports 1, beside a screenshot: a profile fingerprint in Mosaic: GPU, screen, fonts, timezone and language matched to the proxy’s IP](https://mosaicbrowser.com/covers/history-length-fresh-profile.webp)

`history.length` is a fingerprint only in a narrow sense: it is the number of entries in the current tab's session history, and a browser launched fresh onto a page reads 1. One visit at 1 means nothing. A visitor who reads 1 on every visit for a month is a browser that is recreated or started by a script each time. Our engine shifts the starting number per profile, and every navigation still moves it from there.

## What history.length counts

Each tab keeps a list of the pages it has shown, which is what the back button walks through. `history.length` is the length of that list, including the current page. It covers one tab and gives a count, never addresses, so it reveals no browsing history. Opening a link in a new tab starts a new list at 1. Navigating within a tab adds an entry, and so does a single-page app calling `history.pushState` when its route changes. Chrome caps the list at 50 entries.

So the number tells a page roughly how deep into a session the visitor is. A person who opened a new tab, typed a search, clicked a result and then clicked through to a product page arrives at that product page with a few entries behind them. A browser that was started with the product page's address on its command line arrives with none.

## Why 1 on every visit is the signal

A real person reads 1 sometimes: a link opened in a new tab, a bookmark in a fresh window. What a real person does not do is read 1 every time. Their tabs have history, because they got to the page by browsing.

A freshly launched profile reads 1 every time, because every launch opens a tab directly onto its start page. That is true of an automated browser started by a script, and of an anti-detect profile opened onto the site that matters. A site that records the value on each visit can see the pattern without any other help. The comment in our engine code puts it this way: a page that reads 1 on every visit for a month has learned that the profile is recreated, or automated, or both.

It is a weak signal by itself, and we treat it as one. It is also free to read, takes one property access and needs no permission, which is why it is worth getting right.

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: Machines that exist](https://mosaicbrowser.com/features/real-fingerprints)

## The first fix pinned it, and that was worse

The obvious change is to return a believable number instead. Our first version of the change did that: the engine answered `history.length` with the value the profile claimed.

That broke the one thing the property must do, which is grow. Navigate, and the real list gets longer while the answer stays the same. A page can test it in three lines:

```
const a = history.length
history.pushState({}, '')
history.length === a   // true only on a browser that pinned it

```

On every real browser that comparison is `false`. A browser whose history does not grow when it navigates is far stranger than one that started at 1, so the pin traded a weak signal for a certain one. It is the same class of fault as our [geolocation spoof that answered only once](https://mosaicbrowser.com/blog/geolocation-answered-once): the first reading looks right, and the second one gives it away. The question that finds both is whether the value still behaves after you touch it.

## Shift the base instead

Tesseract Chrome, our Chromium build, now makes the claim an offset. The engine still asks Chromium for the real length. If the profile carries a claimed base, a fresh tab reports the base, and each push, replace or navigation moves the answer exactly as far as the real list moved. With a base of 3, the start page reads 3, the next navigation reads 4, and the `pushState` test above comes back `false` as it does everywhere else.

The base comes from the profile's own seed: a number from 2 to 5, the same on every launch of that profile and different across profiles. Small, because a real visitor's tab rarely has a long history before reaching a given page, and stable, because a profile whose starting depth changed at random every launch would be its own odd pattern.

The value is changed inside the engine, not by a script injected into the page, so every frame of the page sees the same number. Why we do every fingerprint value that way is in [why we change fingerprints inside the engine](https://mosaicbrowser.com/blog/cpp-not-javascript).

## What it does not do

The offset changes the number and nothing else. It does not create pages behind the start page. Those entries do not exist, so there is nothing for the back button to return to at the start of a session, as on any tab opened onto its first page. A page could test for that by calling `history.back()` and checking whether it is still there afterwards. On a real visitor with real history, that test sends them away from the page, which is a price we expect few sites to pay for one weak signal.

And it is one value among many. The [browser fingerprint entry](https://mosaicbrowser.com/glossary/browser-fingerprint) lists what else a page reads, and the [values every profile inherited from this Mac](https://mosaicbrowser.com/blog/values-inherited-from-the-host) shows what goes wrong when a value is left identical across profiles.

## Questions

### What does history.length return?

The number of entries in the current tab's session history, counting the page you are on. A tab that opened straight onto one page reads 1, and every navigation or pushState adds one.

### Can a website see my browsing history through history.length?

No. It only gets a count for the current tab, not the addresses. The count still says something: how far into a session the visitor is.

### Why is history.length a fingerprinting signal?

On its own it carries very little. It matters as a pattern: a visitor who reads 1 on every visit, for weeks, is a browser that is started fresh each time, which is what automation and recreated profiles look like.

### How do you spoof history.length without breaking it?

Shift its starting point instead of pinning it. If the value is fixed, history.pushState no longer increases it, and a page finds that in three lines of JavaScript.

## Related

[A spoof that answers once: the geolocation bug we shipped](https://mosaicbrowser.com/blog/geolocation-answered-once): A geolocation spoofing timeout we shipped: the first getCurrentPosition got the IP's coordinates, every later call failed with code 3. One latch was to blame.

[Why we change fingerprints in the engine, not in JavaScript](https://mosaicbrowser.com/blog/cpp-not-javascript): A JavaScript spoof is one realm deep. An iframe read the real source of 33 of our replaced functions; the same values set inside the engine agree everywhere.

[The values every profile inherited from this Mac](https://mosaicbrowser.com/blog/values-inherited-from-the-host): A browser fingerprint value inherited from the host is identical across two unrelated profiles and equal to the computer. That test found dark mode and more.

[Browser fingerprint: what a site can read about your machine](https://mosaicbrowser.com/glossary/browser-fingerprint): A browser fingerprint is the set of values a site reads about your browser and computer, which together recognize you without cookies. What goes into one.

[Machines that exist: fingerprints drawn from real hardware](https://mosaicbrowser.com/features/real-fingerprints): Mosaic draws each profile's GPU, screen, CPU, memory and fonts from one real device, so the parts of a fingerprint agree with each other and with the host.







[Why every Chrome lists the same five PDF plugins](https://mosaicbrowser.com/blog/five-pdf-plugins): The HTML spec fixes navigator.plugins to five PDF viewer entries, each with two MIME types. We once rebuilt that list in JavaScript and got it wrong.

## Mosaic, on your own computer

The browser this blog is about: its own Chromium, fingerprints from real machines and a proxy IP per profile. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

Mosaic is a desktop app

Email yourself the link and open it on your computer.
