

Subtle Modifications to the UA, Big Consequences
source link: https://www.otsukare.info/2014/05/27/ua-modifications
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

It always start with a very simple bug report. In this case the tester went through a sequence of tests and explains a bug. An additional person testing can't confirm the bug. They don't see the same effects. Temporary glitch from the site? Device Capabilities? Or… User Agent Sniffing.
The bug description gives the steps for reproducing the issue. The second tester before trying to contact the site owner tries to reproduce on Firefox OS 1.3 without success. The first tester seems to receive a mobile site, when the second one receives a desktop site.
So I decided to try myself with the normal Firefox OS User-Agent Mozilla/5.0 (Mobile; rv:28.0) Gecko/28.0 Firefox/28.0
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, compress
Host: www.baidu.com
User-Agent: Mozilla/5.0 (Mobile; rv:28.0) Gecko/28.0 Firefox/28.0
HTTP/1.1 200 OK
BDPAGETYPE: 1
BDQID: 0x8507592e000011f5
BDUSERID: 0
Cache-Control: private
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Tue, 27 May 2014 02:11:58 GMT
Expires: Tue, 27 May 2014 02:11:21 GMT
P3P: CP=" OTI DSP COR IVA OUR IND COM "
Server: BWS/1.1
Set-Cookie: BAIDUID=7AE87596241FD318F9262E1CFB77EA7D:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: BDSVRTM=0; path=/
Set-Cookie: H_PS_PSSID=6351_6552_1455_5223_6582_6478_4760_6017_6675_6697_6439_6771_6530_6450; path=/; domain=.baidu.com
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Powered-By: HPHP
Nothing seems weird at first site, but indeed we receive the Desktop content.

Let's use the Firefox for Android user agent string, Mozilla/5.0 (Android; Mobile; rv:28.0) Gecko/28.0 Firefox/28.0
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, compress
Host: www.baidu.com
User-Agent: Mozilla/5.0 (Android; Mobile; rv:28.0) Gecko/28.0 Firefox/28.0
HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html;charset=utf-8
Date: Tue, 27 May 2014 02:19:00 GMT
P3P: CP=" OTI DSP COR IVA OUR IND COM "
Server: nginx/1.2.4
Set-Cookie: BAIDUID=598A251DA68B3CD95209ABE496953EB8:FG=1; max-age=31536000; expires=Wed, 27-May-15 02:19:00 GMT; domain=.baidu.com; path=/; version=1
Set-Cookie: NBID=598A251DA68B3CD92D21226E95BCDA20:FG=1; max-age=2592000; expires=Thu, 26-Jun-14 02:19:00 GMT; domain=.baidu.com; path=/; version=1
Transfer-Encoding: chunked
Vary: Accept-Encoding
Interesting we can notice that we do not get the same site. The HTTP headers are different.

The only difference in between the two strings is the keyword Android
. But let's try further. The initial tester said further in the comment that the user agent string that was used is:
Mozilla/5.0 (Mobile;ALCATELOneTouch4019X/SVN 02001;rv:28.0)Gecko/28.0 Firefox /28.0
You will notice a few things:
* Missing spaces after `;`
* Introduction of `ALCATELOneTouch4019X/SVN 02001`
* An additional space in `Firefox /28.0`
When testing with this string.
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, compress
Host: www.baidu.com
User-Agent: Mozilla/5.0 (Mobile;ALCATELOneTouch4019X/SVN 02001;rv:28.0)Gecko/28.0 Firefox/28.0
HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html;charset=utf-8
Date: Tue, 27 May 2014 02:31:13 GMT
P3P: CP=" OTI DSP COR IVA OUR IND COM "
Server: nginx/1.2.4
Set-Cookie: BAIDUID=DA20BEF7ACDC0E6F05DB98261E04348B:FG=1; max-age=31536000; expires=Wed, 27-May-15 02:31:13 GMT; domain=.baidu.com; path=/; version=1
Set-Cookie: NBID=DA20BEF7ACDC0E6FFA525ADDCD080DDB:FG=1; max-age=2592000; expires=Thu, 26-Jun-14 02:31:13 GMT; domain=.baidu.com; path=/; version=1
Transfer-Encoding: chunked
Vary: Accept-Encoding
We receive something which looks like the Android version for the HTTP headers but the layout is this time, a third version which looks like it has been made for low capabilities mobile devices. It reminds us of yesterday's post about nginx and Chinese Web sites.

Let's try to "fix up" the bogus User Agent string by adding and removing the spaces in the string at the right place.
Mozilla/5.0 (Mobile; ALCATELOneTouch4019X/SVN 02001; rv:28.0)Gecko/28.0 Firefox/28.0
Fixing up the string that way doesn't change anything. We still get the simplified content. Removing the SVN 02001
doesn't change anything either. In fact by just doing User-Agent: ALCATELOneTouch4019X
, we receive the simplified version of the content. In fact even by reintroducing Android
, we still get the simplified version.
Android; ALCATELOneTouch4019X
Mozilla/5.0 (Android; Mobile; ALCATELOneTouch4019X/SVN 02001; rv:28.0)Gecko/28.0 Firefox/28.0
The simple presence of the token ALCATELOneTouch4019X
cancels the more graphic version.
All of this was for the home page, when you start browsing from these home page with different user agent strings, you get different code paths and layouts.
All of that led me to propose to have in the bug report the precise User Agent strings which have been used.
Otsukare.
Recommend
-
75
Introduction After I wrote the article about inheriting properties from a base class entity using @MappedSuperclass, I got an avalanche of opinions, but this one from Lukas deserves a blog post: While @MappedSuperclass has its benefit, allowing...
-
84
ungoogled-chromium A lightweight approach to removing Google web service dependency Help is welcome! See the
-
112
README.md PE-sieve
-
33
Bluetooth stack modifications to improve audio quality on headphones without AAC, aptX, or LDAC codecs Before reading this article, it is recommended to read the previous one:
-
49
README.md
-
35
README.md AntiSpy is a free but powerful anti virus and rootkits toolkit. It offers you the ability with the highest privileges that can detect,analyz...
-
11
Description FSharp.Data.Npgsql is F# type providers library on a top of well-known Npgsql ADO.NET client library. The library includes two type providers: NpgsqlConnection and...
-
9
Dev Tools: Debugging DOM Tree modifications This site is updating in the open It looks like stylesheets are missing, but actually I’m working on this site openly and I just started to redesign it. Things will look a...
-
7
Early Access Program Publication de la version 1.5.0-RC de Kotlin : modifications dans les bibliothèques standard et de tests ...
-
4
A second Biden term: 3 big consequences
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK