Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1933266 - Update domain allowlist for Widevine #3252

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

aosmond
Copy link
Contributor

@aosmond aosmond commented Nov 26, 2024

No description provided.

uwsgi/admin.wsgi Outdated
@@ -34,6 +34,10 @@ DOMAIN_ALLOWLIST = {
"Widevine",
"Widevine-L1",
),
"www.google.com": (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a gaping hole in that Balrog would allow anything accessible through https://www.google.com to be served as a Widevine plugin... Is there any we can get a more scoped down domain for the mirrors? Or would that just end up with the same problem of things getting blocked?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could see how that might get abused, but part of the point is to use a domain that is unlikely to be blocked. The URL does have a set form though, perhaps I could extend the allowlisting to support partial URLs, e.g. https://www.google.com/dl/release2/chrome_component

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the only place that uses the result directly, so I could change the format a bit to provide both domains and URLs:

if domain not in allowlistedDomains:

If it doesn't match a domain, it can check to see if the URL matches one of the starting fragments instead. Change DOMAIN_ALLOWLIST to something like

DOMAIN_ALLOWLIST = {
  "domains": {
    // ... existing list
  },
  "urlFragments": {
    "https://www.google.com/dl/release2/chrome_component": (
        "Widevine",
        "Widevine-L1",
    )
  },
}

Copy link
Contributor Author

@aosmond aosmond Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or alternatively, something like, where the domain either just has the list of products straight up like now, or it provides an additional criteria of URL fragments that the URL path needs to match:

DOMAIN_ALLOWLIST = {
  // ... existing list
  "www.google.com": {
    "dl/release2/chrome_component": (
        "Widevine",
        "Widevine-L1",
    )
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a more advanced version of the latter and updated the PR. Now it can take in an optional fullmatch regex for the path to ensure more generic domains don't get abused. The regex for www.google.com should only allow us to access files from the chrome component update service.

@aosmond aosmond force-pushed the ao_gmp_google_allowlist branch from f0cb94d to a2fee56 Compare November 26, 2024 23:11
@aosmond aosmond changed the title Bug 1932482 - Update domain allowlist for Widevine Bug 1933266 - Update domain allowlist for Widevine Nov 26, 2024
@aosmond aosmond force-pushed the ao_gmp_google_allowlist branch from a2fee56 to b04c715 Compare November 26, 2024 23:21
Copy link
Contributor

@bhearsum bhearsum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for implementing this! This needs a small revision for the isinstance bug noted below. The other one is up to you.

@@ -34,14 +35,29 @@ def isSpecialURL(url, specialForceHosts):
def isForbiddenUrl(url, product, allowlistedDomains):
if allowlistedDomains is None:
allowlistedDomains = []
domain = urlparse(url)[1]
parsedUrl = urlparse(url)
domain = parsedUrl[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize that you're inheriting this, but it would be a good time to update this to use the named attributes that urlparse returns (it looks like you want .netloc and .path specifically).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I noticed that from the docs, but chose to follow the convention set in the code. Fixed!

logging.warning("Forbidden domain for product %s: %s", product, domain)
return True
return False
elif isinstance(allowlistedDomain, object):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want isinstance(allowlistedDomain, dict) here. (object is the base class of the class hierarchy, so this happens to work, but if there was another elif block afterwards there'd be a problem.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Corrected.

@aosmond aosmond force-pushed the ao_gmp_google_allowlist branch from b04c715 to b04680c Compare November 27, 2024 02:47
@aosmond aosmond requested a review from bhearsum November 27, 2024 03:19
@bhearsum bhearsum merged commit 120709e into mozilla-releng:main Nov 27, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants