Page MenuHomePhabricator

Investigating unique devices traffic data
Closed, ResolvedPublic

Description

In response the findings in this ticket we have a couple of follow up questions that hopefully Traffic can help provide some insight to.

Summary of findings:

We have experienced a large (20%) increase in Unique Devices Year over Year for July 2024 and August 2024 in our monthly metrics which are computed from the unique_devices_per_project_family_monthly table. We noticed through our investigation that these increases were much less in the corresponding unique_devices_per_domain_monthly. Looking at the daily versions of these tables we noticed large spikes in unique devices on particular days such as August 14th 2024 July 14th. We narrowed down a large portion of the increase to apparently automated traffic flagged as 'is_redirect_to_pageview' (specifically status code 301) that made into the project_family table because our automata labelling heuristic is only applied to is_pageview= TRUE web requests. However, analysis revealed several anomalies/questions that we would like to explore as we continue our investigation:

  1. Is there an explanation for why there are users that apparently WMF-Last-Access-Global is set but not WMF-Last-Access and vice versa? It seems that Cookies should be set simultaneously such that any user should have a minimum a single pair of cookies.
select if(x_analytics_map['nocookies'] is null, 'accepts cookies', 'does not accept cookies') cookies,
        length(x_analytics_map['WMF-Last-Access-Global']) global_length,
        length(x_analytics_map['WMF-Last-Access']) local_length,
        count(*)
    FROM wmf.pageview_actor
    WHERE x_analytics_map IS NOT NULL
      AND agent_type = 'user'
      AND is_pageview = TRUE
      AND year = 2024 AND month = 8 AND day = 14 and hour = 10
 group by x_analytics_map['nocookies'] is null,
        length(x_analytics_map['WMF-Last-Access-Global']),
        length(x_analytics_map['WMF-Last-Access'])


cookies                 global_length   local_length    count(1)
accepts cookies         NULL            NULL            141697
accepts cookies         11              11              15651640
does not accept cookies NULL            NULL            2496307
accepts cookies         11              NULL            1810474
accepts cookies         NULL            11              162134
  1. Should every redirect correspond to a http_status code 200? The bulk of the automated requests that I mentioned ended as status 301 with no corresponding status 200. Our data shows they are being redirected to /wiki/a uri_path (probably from /wiki/A/) we did not see any 200 status that followed or preceded these requests in the webrequest data.
  1. Looking at the isp_data, or any other field, is there any way to determine the origin of the request? Even if it's a general determination of vpn, data center request, etc. We would appreciate help deciphering some of the fields in isp_data:

example:

ip                isp 	organization 	autonomous_system_organization 	autonomous_system_number
IP xxx.xx.xx  SPTEL PTE. LTD. 	SPTEL PTE. LTD. 	SPTEL PTE. LTD. 	23856
  1. What is the purpose of counting redirects? If a user is redirected from a desktop site (302) to the mobile site (200), then what's the problem of counting them only when they resolve as 200 on the correct mobile set? Global cookie being set there would still capture the domain and the project family since the mobile version of the site is still in the same project family. I can think of 2 answers: sometimes redirect fails and so we don't want to lose the original unique device as part of our count and the other reason is maybe a redirect can occur from one project family to another?

Event Timeline

  1. Is there an explanation for why there are users that apparently WMF-Last-Access-Global is set but not WMF-Last-Access and vice versa? It seems that Cookies should be set simultaneously such that any user should have a minimum a single pair of cookies.

Yes, since T174640 varnish doesn't set WMF-Last-Access-Global cookie for wikimedia.org or its subdomains. And T260943 excluded requests to api.wikimedia.org from getting WMF-Last-Access. Relevant code can be seen here

  1. Should every redirect correspond to a http_status code 200? The bulk of the automated requests that I mentioned ended as status 301 with no corresponding status 200. Our data shows they are being redirected to /wiki/a uri_path (probably from /wiki/A/) we did not see any 200 status that followed or preceded these requests in the webrequest data.

Redirections are handled by the user agent, tools like curlwon't follow redirects unless it's explicitly enabled, so it's entirely possible that the user agent responsible for the behavior you're seeing isn't following redirects.

  1. Looking at the isp_data, or any other field, is there any way to determine the origin of the request? Even if it's a general determination of vpn, data center request, etc. We would appreciate help deciphering some of the fields in isp_data:

From what you provided SPTEL (AS2856) is an ISP and cloud provider from Singapore, we would need more details (IPs) to get data from the reputation services that we are currently using to provide a more accurate answer.

  1. What is the purpose of counting redirects? If a user is redirected from a desktop site (302) to the mobile site (200), then what's the problem of counting them only when they resolve as 200 on the correct mobile set? Global cookie being set there would still capture the domain and the project family since the mobile version of the site is still in the same project family. I can think of 2 answers: sometimes redirect fails and so we don't want to lose the original unique device as part of our count and the other reason is maybe a redirect can occur from one project family to another?

This is related to question number 2, redirects are handled by the user, server side are two complete different requests. The user can follow or ignore the redirection depending on what's actually doing. Browsers "always" follow redirects unless there is some kind of loop (chrome will refuse to follow more than 20 redirections in a row for example)

  1. Is there an explanation for why there are users that apparently WMF-Last-Access-Global is set but not WMF-Last-Access and vice versa? It seems that Cookies should be set simultaneously such that any user should have a minimum a single pair of cookies.

Yes, since T174640 varnish doesn't set WMF-Last-Access-Global cookie for wikimedia.org or its subdomains. And T260943 excluded requests to api.wikimedia.org from getting WMF-Last-Access. Relevant code can be seen here

What we saw in the data is that for *.wikipedia.org we have webrequests with WMF-Last-Access-Global set but no WMF-Last-Access. I see the conditions that match what you say in the VCL code, but I didn't see anything that explained this happening on a request to wikipedia.org. Happy to hang out and find data we can look at.

This comment has been deleted.

What we saw in the data is that for *.wikipedia.org we have webrequests with WMF-Last-Access-Global set but no WMF-Last-Access. I see the conditions that match what you say in the VCL code, but I didn't see anything that explained this happening on a request to wikipedia.org. Happy to hang out and find data we can look at.

Happy to stare at data but take into account that cookies are sent by the user agent as well so it's entirely possible that some browser add-on is flagging one of our cookies as a tracking cookie and blocking it

Another observation looking at the unique devices data:

We notice there are a lot of actor signatures that don't appear as automated traffic (i.e., not triggering thresholds in our labeling and web request data shows no clear pattern of articles being accessed) whose ISP data based on their IP indicate they are requests coming through cloud services such Huawei Cloud, Cloudfare etc. In particular, Hong Kong and Singapore's data indicate that most of their unique devices are coming from such IPs. In addition, these actor_signatures are often associated with thousands of unique devices on a given day/month which should not be possible. Finally, we notice these actor signatures show they have Last Access and Last Access Global cookies set on some requests and not others on the same day which is counter-intuitive, but might indicate that these are in fact different devices.

Is the Traffic team aware of any increase in Cloud/VPN/ non-regular ISP data in these countries or in our web traffic in general?

It's possible that different users are being collapsed into the same actor signature via sharing IPs or some kind of IP masking/privacy setting that is setting a generic user agent - if this is the case, and these signatures are actually legitimate users, how can we tell? This is important because if they are automated, they should be classified as such; if they are not automated, we ideally would like their geolocation to be accurate so that it does not become a case of a bunch of users from a country being counted into Singapore's unique device count.

Is there anything we can look at it to help identify what the origin of these web requests are?

@Vgutierrez Just an FYI if you have any thoughts on the above findings?

image.png (2,126×761 px, 81 KB)
this is what we are seeing at the CDN on haproxy metrics for eqsin (Singapore DC) during the last 3 months, each data point in the graph is the number of requests during that day
last_over_time(sum(increase(haproxy_frontend_http_requests_total{proxy="tls", site="eqsin", cluster="cache_$cluster"}[24h]))[1d:1d])

Assuming that the automated traffic you're describing follows DNS and doesn't hardcode the IP of another of our DCs, the increase should be reflected in that graph.

We already provide some sort of cloud traffic identification as part of the X-Analytics cookie in the public_cloud key (T279380).

Besides that, the CDN sends all the details about the TLS session (ciphersuite, TLS version..) so if you have traffic from the same IP and same reported User Agent but TLS data doesn't match, you could have actually several unique "users" behind that IP/UA (it could also mean that some requests are impacted by some kind of MiTM device, usually deployed in corporate setups as part of their DLP (Data Leak Prevention) strategy

For September 2024 we see about 1800% increase in Unique Devices from Singapore, YoY which puts total unique devices counted in Singapore at 125,911,935 for a population of 5 million, which is about 36% of total new unique devices year-over-year. The majority (at peak 99% of unique device: see chart below) of these uniques, similar to last month and the month before, are coming from Cloud based ISPs such as Huawei Cloud.

image.png (1,030×561 px, 74 KB)

Consulting with @Vgutierrez, we believe this traffic is likely automated because:
a) Lack of referrer header.
b) UA looks like it's being faked.
c) The provider is Cloud infrastructure.
d) the volume of unique devices is basically impossible to be generated legitimately from Singapore.

OSefu-WMF assigned this task to Hghani.

Closing this task as investigations are largely complete. Will reopen if there are additional findings