-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Font Library: add a 'manage font' exclusive user permission to manage the install/remove fonts. #55280
Comments
Who will get default access to this capability? Super Admins and Admins only?
I think so, but is it just a shorthand for existing capabilities? I believe the main permissions that are specific to managing fonts are:
|
I believe this capability would by default need to be a so-called "meta capability". It wouldn't be added to the WordPress database (we rarely do that with new capabilities these days anyway), but it would be programmatically granted based on other capabilities present, and potentially additional logic. One important consideration here is that installing fonts (as far as I understand) requires access to the filesystem. This is somewhat sensitive and right now only administrators can perform such operations (install plugins, themes, language packs for example). Probably we'll need to follow that with fonts, although there may be room to diverge for that particular use-case. We also have to keep in mind that some WordPress installation disable filesystem access entirely, in which scenario effectively nobody could install new fonts. They would need to be managed through direct filesystem access outside of WordPress in that case. That also leads to another point: |
Yep, thinking so too. So who would really need a (separate) capability to manage fonts? Should someone be able to manage fonts but not manage/change the site's CSS? Think that wouldn't make sense? Then how often would someone need to actually manage the fonts on a site? Once per week, or month, or maybe year? Thinking that perhaps a separate Seems site admins are the right choice for that, no need of any changes currently. If the need for a dedicated user that can manage fonts but is restricted from managing other options arises, lets add that then. |
While I don't think we have to go too granular with font permissions, I do think at least one font-specific capability is necessary. See below:
While that conceptually may be related, the specific action of installing fonts writes things to the filesystem. Editing CSS does not. So there is a clear difference there.
Per the above, I don't think that's true. Editing CSS in WordPress only writes to the database, while installing fonts writes to the filesystem. I think a separate permission check for this is needed, if for no other reason at least due to server configuration implications, which may prevent installing fonts. |
Hmm, not more than uploading images? Seems (in the back-end) uploading font files should be treated in the same way as uploading images. It's not like font files can be used to upload any file types that can contain exploits? They are just another type of media files. |
Not sure. Fonts could potentially be handled similarly to things in the I wouldn't categorically say those files can't contain exploits. Specifically, I wonder why shouldn't fonts be similar to language packs (which in my impression have similarly high or low risk for exploits)? |
Yes but all of these can contain direct exploits. Themes and plugins have PHP files and are "most dangerous".
Language packs are generally trusted by WP to not contain HTML and JS. In that sense their "exploitability" is very high too. Afaik font files that are commonly used on the internet cannot contain executable code (good to confirm this in any case). Think there are malicious fonts that try to trick the user by making certain characters invisible, etc. but no direct exploits are possible. This seems less harmful and less exploitable than having a malicious PDF file for example. So yes, there is a big difference between language packs and font files when it comes to exploitability. |
Totally agree for plugins and themes. However, without much further research, I think we can't reasonably assume that font files are safer to trust/use than language packs. Until we know otherwise, I think our baseline needs to be on the side of security (better too much than too little). I think it would be great to get the security team's perspective on this to make a decision. |
Yep, it is prudent to be on the side of security, however as explained above font files are not similar in any way to language packs. If they need to be compared to anything they are closer to images and PDFs. Agree, it would be great to get the opinion of the security team. Until then I think font files should probably be treated the same way as any other file type that can be uploaded to WP? In any case, this PR is for determining if another capability may be needed to allow users other than admins to install fonts. I think it is not needed unless it is proven practical and useful. Frankly I don't see the need for someone to be able to install fonts but not be able to Further more if we think font files can be exploited it is even better to not allow more users to upload them, right? Same as with plugins themes and language packs. |
That's correct, and I think we can consider these two separately for which capabilities to use. The font library is still useful without being able to upload fonts, as the font source can be a remote url. Managing font settings This involves managing custom post types and post meta. It's closely tied to Global Styles, which uses the File uploads This is when a font file is uploaded to the site, and the font settings are configured to use the file url after upload. By default font files are stored in It not, continuing to use |
@azaozz @felixarntz @creativecoder I've read through this Issue. It seems that most folks agree that It seems we were waiting on the WordPress Security folks to provide input on how "exploitable" font files might be and that could form the basis for coming to a decision here. Have I understood this correctly? If so I will prompt those folks for input on this issue in the hope we can come to a decision about firming up the user permission for the Font Library feature. |
@getdave That's the most important question to answer, and I agree we need the security team's input for this one. Additionally though, I think in any case at least a single capability like It could be a meta capability that uses |
@getdave There are two issues with uploading that I am seeing:
The idea of the constant is that WP won't upload files outside of the uploads file regardless of the file settings. In cases in which the file settings are disabled at a server level I've started experimenting in PR #58957 but I am sure that there are things I am missing with the JavaScript permissions and other edge cases. |
@peterwilsoncc I tend to agree with you in that this needs to respect To be clear, I'm not vouching for either treatment, but just wanted to clarify the main point of discussion that needs to be addressed here: Should fonts be treated more like uploads (i.e. can be trusted and are expected to be always writable) or more like plugins/themes/language packs? |
I think they are more akin to themes or plugins than uploads. Mainly because they can be used to completely change the look of a site. Most WP sites are created in a client services environment in which a designer has chosen fonts carefully. On a more practical level, I don't think they can be treated as uploads as they are outside the folder. Servers locking file mods down via file permissions use the |
Given that the current capability being used is |
I think the PR #58957 is in a suitable shape for respecting file write permissions. |
I put together an experimental PR for another way we could handle respecting
This allows sites with immutable/transient file systems to install fonts and load them from a remote server. However, there are other issues to consider, like font collections may not want to be used as a CDN, or the site owner may have privacy concerns: see #58229. Those can be handled separately by adding other settings or filtering, but I wanted to mention them because they intersect with this issue here. |
@creativecoder I don't think this is necessary as it can be managed via permissions. For situations such as #58696 the following filter can be used: add_filter(
'file_mod_allowed',
function ( $allowed, $context ) {
if ( 'can_modify_font_faces' === $context ) {
return true;
}
return $allowed;
},
10,
2
); Hosts with immutable file systems (Pantheon, WP VIP, Altis DXP, etc, etc) outside of the uploads folder, can use that filter and |
@creativecoder I As WordPress 6.5 is in it's final stages, I think it's better to set up the roles and caps based on how WordPress is currently managing fonts and come back to allowing for CDNs and similar later. Ultimately this is best decided by @youknowriad @getdave @swissspidy and @dream-encode. |
@peterwilsoncc Thanks for taking another look at this issue and reviewing the PR--I'll work on updating the PR tomorrow.
Agreed on handling CDNs and triggering remote font hosting later--this needs more time and thought. |
Here's a PR that combines approaches, adding a meta capability for |
Was with the impression that a decision was reached here about not adding another user capability as the Also seems the use of Imho the most important part in all new WP features is the UX. That includes things like "easy to understand and use", "makes sense", "is logical", "has consistent behaviour", etc. so unsure if using Also see #59294 (comment) |
Reviewing the above conversation about whether a new capability is needed for uploading fonts seems to hinge on how you categorize font uploads: are they more like media uploads or more like themes/plugins/language packs? I see them more like media uploads, specifically: First, fonts are not versioned files and are unique to each site. For example, each site within a multisite network gets its own fonts folder, just like uploads. Say you use version control to manage your site files. Typically you'd put themes, plugins, and core files in version control, and not track uploads. I think generally you'd also keep uploaded font files out of version control. You can't composer install a font file onto a WordPress site like you can with a plugin. Second, the code that handles font uploads is the same as media uploads ( This will require hosts to allow a writable |
The discussion here still seems to be unresolved. To be clear, I personally am not strongly leaning in either direction, but we have to make a real decision here. As far as I can tell there are two options:
If we go for the first, then we could go with I think some of the discussion here goes too much into detail on the capabilities to use. The central question to decide on is whether font files can be trusted like media, or whether they cannot, and additionally, if they can be trusted, whether it's justifiable to make a disruptive change that requires many hosting providers to change their folder permissions for the new |
Same here.
Right, this is a very good question. As far as I see font files are considered to be "media" and not "code" (executable). For comparison SVG files are also considered to be "media" (afaik) despite that they can contain scripting (and are considered insecure/exploitable). However I agree the most important thing here is to look at this from the user perspective. At the end of the day I don't think it matters to the users whether font files are considered "software", "scripts", or "media" as long as the UX and UI for managing them in WP is consistent and works well. This is the top priority imho, and any solution can be "coded" and made to work even if it is "inconveniencing" some hosting providers by requiring them to make a change and treat Of course, this is just my opinion. I may be missing or misunderstanding something, and will be happy to change it if that's the case :) |
This conversation is becoming splintered across the issue and the PR. Cross posting #59294 (comment)
[there's more but that's the key bit so ... snip] |
We're a bit late in a cycle to have such fundamental discussions about whether fonts are considered to be media or not, that's a bit concerning 😞 😕 If we just think about capabilities, IMO it's a no brainer to have more fine-grained capabilities using Regardless of what we do, introducing a new |
+1 If this is supposed to go into 6.5, I think it is unreasonable to go with the requirement of So I think if the consensus is that font files should be treated like media, this may need to be delayed to give the ecosystem enough time to be prepared. Or at the very least, there would still need to be checks in place to hide or disable the UI for when the requirements are not met by the site. |
Right, will reply on #59294 (comment). |
Having just read through the discussion, my take is that worrying about specific meta caps is not as important at this stage as respecting the fundamental capabilities WP has to determine whether a file can be uploaded and used in an environment. I would encourage a decision to be made to either: a) Move the uploads destination for fonts files to the b) Keep the current uploads location (i.e., wp-content/fonts) but ensure the feature respects Personally, I would suggest moving the directory and treating fonts as an uploaded asset—just like media. As @peterwilsoncc has conveyed, there are simply too many environments that only allow files to be uploaded to the uploads directory for WP to assume otherwise. This would provide the most consistent user experience across all platforms and avoid a bunch of extra logic and overhead to account for environments where the fonts folder is not writable. If that's not possible for some reason, then affordances MUST be made in the UI to account for environments where the uploads will fail or else we will be shipping a frustrating experience to users on those environments. Adding additional meta-caps, or filters that would allow different environments to choose how to support font files is something that we can always add later based on user feedback and clear use cases,. Using |
The upload folder being Given the small surface area the UI has at the moment (global styles; site editor), honoring |
For more context, citing #53965 regarding that
|
@mtias Makes sense to me, my only concern is regarding:
I completely agree if we're thinking about fine grained capabilities for font management. However, due to the So I think if we want to keep new capabilities to a minimum, I'd suggest:
|
While I think ultimately some refined capabilities is best, I think @felixarntz's assessment of MVP here is correct.
Can you please share the link to this discussion to minimize the pieces that are relitigated? |
What?
Add a 'manage font' exclusive user permission to manage the install/remove fonts.
Why?
Currently, we are using
edit_theme_options
. Should we create/use a more specific permission?Props to @spacedmonkey and @felixarntz, who originally proposed this here:
https://wordpress.slack.com/archives/C02RQBWTW/p1696514853414459
The text was updated successfully, but these errors were encountered: