Commit 0776a33e authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃 Committed by Richard Pospesel
Browse files

Bug 41116: Normalize system fonts.

System fonts are an enormous fingerprinting vector.
Even with font allow lists and with our custom configuration on Linux,
which counter metrics measurements, getComputedStyle leaks several
details.
This patch counters both these kinds of attacks.
parent 78c1435c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1901,6 +1901,14 @@ static void GetSystemUIFontFamilies([[maybe_unused]] nsAtom* aLangGroup,
  nsFont systemFont;
  gfxFontStyle fontStyle;
  nsAutoString systemFontName;
  if (nsContentUtils::ShouldResistFingerprinting()) {
#ifdef XP_MACOSX
    *aFamilies.AppendElement() = "-apple-system"_ns;
#else
    *aFamilies.AppendElement() = "sans-serif"_ns;
#endif
    return;
  }
  if (!LookAndFeel::GetFont(StyleSystemFont::Menu, systemFontName, fontStyle)) {
    return;
  }
+7 −1
Original line number Diff line number Diff line
@@ -9564,7 +9564,13 @@ void nsLayoutUtils::ComputeSystemFont(nsFont* aSystemFont,
                                      const Document* aDocument) {
  gfxFontStyle fontStyle;
  nsAutoString systemFontName;
  if (!LookAndFeel::GetFont(aFontID, systemFontName, fontStyle)) {
  if (aDocument->ShouldResistFingerprinting()) {
#ifdef XP_MACOSX
    systemFontName = u"-apple-system"_ns;
#else
    systemFontName = u"sans-serif"_ns;
#endif
  } else if (!LookAndFeel::GetFont(aFontID, systemFontName, fontStyle)) {
    return;
  }
  systemFontName.Trim("\"'");