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

新的 skinDomains 匹配方法 #91

Merged
merged 1 commit into from
Oct 17, 2020
Merged

新的 skinDomains 匹配方法 #91

merged 1 commit into from
Oct 17, 2020

Conversation

yushijinhun
Copy link
Owner

此 PR 使用了新的 skinDomains 匹配方法,以规避原先方法可能带来的安全问题。

问题背景

API 元数据 中包含了一项名为 skinDomains 的属性,即材质白名单。仅当材质 URL 的域名匹配白名单中的规则时,Minecraft 才会下载这一材质。引入这一机制的原因见 MC-78491

目前,authlib-injector 使用的匹配方法沿用自原版 MC,具体为:材质域名须以白名单中的任意一项结尾。例如:

  • .example.com 匹配 a.example.comb.a.example.com不匹配 example.com
  • example.com 匹配 example.coma.example.comeexample.com

如果您要匹配 example.com 下的子域名,您可以使用 .example.com 规则,这并无问题;但若您要匹配 example.com 这个顶级域名,您就必须使用 example.com 规则,example.com 与此同时也会匹配 eexample.com,而这就造成了潜在的安全问题

解决方法

skinDomains 的匹配方法修改为如下:

  • 如果规则以 . (dot) 开头,则匹配以这一规则结尾的域名。
    • 例如 .example.com 匹配 a.example.comb.a.example.com,不匹配 example.com
    • 这与先前无异。
  • 如果规则不以 . (dot) 开头,则匹配的域名须与规则完全相同
    • 例如 example.com 匹配 example.com不匹配 a.example.comeexample.com

兼容性

由于新的匹配方法更为严格,因此可能造成兼容性问题。

如果您使用单条规则(如 example.com)去同时匹配某个域名(如 example.com)及其下的子域名(如 a.example.com),这将不再有效。您需要使用 example.com(匹配顶级域名)和 .example.com(匹配子域名)两条规则。

@yushijinhun yushijinhun merged commit eaffc03 into develop Oct 17, 2020
@yushijinhun yushijinhun deleted the skindomains branch October 17, 2020 15:04
@yushijinhun yushijinhun mentioned this pull request Oct 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant