Page MenuHomePhabricator

Make tools-static fontcdn/ and cdnjs/ redact UA
Open, MediumPublic

Description

[...] it might be permissible, but sending it onto Google would make it definitely not

Current configuration sends the UA upstream.

Event Timeline

zhuyifei1999 removed Legoktm as the assignee of this task.

One issue here: I seem to recall that the fontcdn bit may not work without a user agent. I know that Google fonts behave a bit odd if you use odd UAs. I mean, perhaps we could just send a valid "Firefox" UA to everything :)

(Why did I not get a phab notification?)

Google fonts IIRC tries to be smart and gives different CSSs depending on what the browser supports. If we sent an invalid UA... would it make google 'send everything'?

Eg: https://tools-static.wmflabs.org/fontcdn/css?family=Open+Sans

With my Firefox Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0:

/* cyrillic-ext */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFWJ0bbck.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFUZ0bbck.woff2) format('woff2');
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFWZ0bbck.woff2) format('woff2');
  unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFVp0bbck.woff2) format('woff2');
  unicode-range: U+0370-03FF;
}
/* vietnamese */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFWp0bbck.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFW50bbck.woff2) format('woff2');
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFVZ0b.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

With curl curl/7.66.0:

@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFVZ0e.ttf) format('truetype');
}

With Invalid UA:

@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFVZ0e.ttf) format('truetype');
}

With curl + Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36:

/* cyrillic-ext */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFWJ0bbck.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFUZ0bbck.woff2) format('woff2');
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFWZ0bbck.woff2) format('woff2');
  unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFVp0bbck.woff2) format('woff2');
  unicode-range: U+0370-03FF;
}
/* vietnamese */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFWp0bbck.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFW50bbck.woff2) format('woff2');
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://tools-static.wmflabs.org/fontcdn/s/opensans/v17/mem8YaGs126MiZpBA-UFVZ0b.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

... so apparently it's just valid UA vs invalid UA?

Modern edge, chrome, safari and firefox all support woff2, so that's probably why it gives the same results for both firefox and safari UAs . I imagine you'll get different results for opera mini, IE11 and maybe older safari.

https://caniuse.com/#feat=woff2

• Bstorm triaged this task as Medium priority.Feb 11 2020, 4:55 PM

Could we get away with bucketing user-agents to partially anonymize people? That does seem like a decent amount of work though.

Toolforge is considered third-party (even if the maintainer has signed the NDA), and the Privacy Policy considers the User-Agent header to be PII that cannot be sent to Google even if everything else is stripped. See T166138. And, yes, I did check with WMF Legal. It’s currently Catch 22-impossible.

While it's not great, it's still much better to hit toolforge than hitting Google.

Apparently this toolforge tool still forwards user-agents to google, because the google fonts vary by user agent. I suggest we adapt that tool to simply override the user agent, as it is no longer required to vary on user-agent as all modern webbrowsers support woff and woff2.

OK, looked a bit further. It seems that:

google fonts api returns woff2 for Windows, but returns woff for macOS
This apparently has to do with issues like https://github.com/google/fonts/issues/2602

Still that means that if we have like 2 buckets, we'll probably cover the most significant browser support for that ppl will actually need.

google fonts api returns woff2 for Windows, but returns woff for macOS
This apparently has to do with issues like https://github.com/google/fonts/issues/2602

Still that means that if we have like 2 buckets, we'll probably cover the most significant browser support for that ppl will actually need.

The linked issue seems to be with a broken font and not macOS support for WOFF2 as such, and caniuse suggests nearly all Grade A browsers support WOFF2 without caveats. In addition, webfonts should be used sparingly and for non-critical purposes, so if there is some minor visual glitch in some cases for some browsers it's not the end of the world.

I'd suggest fontcdn should just pretend to be Firefox and put everyone in the same bucket so that we actually get something we can use (I need a couple of specialised fonts enabled by default, cf. T166138). Iff problems turn up it'll be soon enough to figure out what to do about them then. For example, maybe the buckets are Grade A vs. Grade C rather than Windows vs. macOS, or maybe (like with Inter) the fix is really to upstream a bug report against the font. Or put another way, I think we're in perfect-as-the-enemy-of-good territory now.

If fontcdn stopped sending any client-provided UA to Google we could start the (probably uphill) climb to either get Legal to sign off on an exception for fontcdn on Toolforge, or getting fontcdn moved to production and so non-controversially covered by the WMF Privacy Policy. Given it's just proxy config (aiui) it should be surmountable resource-wise (not sure whether zhuyifei1999 is still interested in helping out with this, but in production we'd need involvement from staff in any case).

Yeah, I also think that the proper way to deal with this is to pass the uniform user agent for all requests that would just output WOFF2 fonts and nothing else. Having fonts is a progressive enhancement, so exposing UA data for that is not really necessary. If someone wants to do that nonetheless for whatever reason, you could leave an opt-in parameter for doing that, like senduseragent=1 (but obviously that parameter would not be allowed on Wikimedia sites).