There is a serious security flaw in the code of field_views_field_default_views_data() function of /views/modules/field.views.inc file: assigning unescaped user input string to the label of the field. I suddenly stumble on it while writing my own custom filter handler. Fortunately, the fix is pretty obvious, so I attached the patch to this issue.

This security issue falls outside of the security advisory policy of the Drupal Security team. The vulnerability can only be exploited if the attacker has an elevated permission "administer fields". Therefore we can fix this in public and no private security report is necessary.

Comments

RedRat’s picture

Status: Active » Needs review

I have tested this patch on my production server and it works fine.

damienmckenna’s picture

Issue summary: View changes
damienmckenna’s picture

This is only possible if someone has permission to change field names, which requires the "administer field" permission. That permission is considered a special permission that should only be given to trusted users, so this isn't a security problem in the traditional sense.

dawehner’s picture

I am a bit confused here ... there are other instances where the field labels are used directly as well.

chris matthews’s picture

Version: 7.x-3.5 » 7.x-3.x-dev
Priority: Major » Normal

Version change only.

damienmckenna’s picture

StatusFileSize
new614 bytes

Rerolled.

I'm still tempted to close this as "won't fix" because admin labels of entity types and fields are generally considered admin-only, so if an admin is adding some XSS to your field labels maybe you have other problems?

klausi’s picture

Title: Security issue because of unescaped string in code » Security issue because of unescaped field labels
Priority: Normal » Critical
Status: Needs review » Needs work
Issue tags: +Security

This was released as backdrop security fix in https://backdropcms.org/security/backdrop-sa-core-2024-001

Raising priority to critical as this is a small XSS vulnerability, but fortunately can only be exploited by trusted admins as Damien said.

Setting to "needs work" as I think we should do the same fix as Backdrop.

klausi’s picture

Status: Needs work » Needs review
StatusFileSize
new2.58 KB

Ported patch from backdrop.

gresko8’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch Klausi!

damienmckenna’s picture

Thank you all for working on the fix and reviewing it.

renatog’s picture

Thanks everyone

Was reported years ago but If confirmed that that still happening today and it's really a security issue, since our stable releases are covered by the security advisory policy we must follow this instruction, right?!

Warning message

Security issues should not be reported here. Follow the procedure for reporting security issues.


Or if isn't considered a security issue, I'd suggest updating the issue title :)

klausi’s picture

Issue summary: View changes

It is a security issue, but it falls outside of the security advisory policy of the Drupal Security team. The vulnerability can only be exploited if the attacker has an elevated permission "administer fields". Therefore we can fix this in public (not sure why Backdrop issued an advisory).

Clarified that in the issue summary

damienmckenna’s picture

Thanks Klausi.

Put another way - this is a minor security hardening issue for some rare scenarios, rather than a something a non-admin would be able to exploit.

klausi’s picture

Priority: Critical » Normal
Status: Reviewed & tested by the community » Active

Oh hm, @jenlampton replied in Slack that the Backdrop fix is not necessary for Drupal 7 because Views UI has an extra XSS filter that Backdrop does not have anymore. She is right, I tried to exploit this but could not get XSS to trigger when adding a field in the Views UI.

Is there any other place where these field labels are displayed?

Very sorry for the noise here, I should have tested my assumptions fully before escalating here. Downgrading the priority again and setting this back to active.

For the Views module in Drupal 7 I think we should not remove the extra XSS filter in Views UI, even if there could be some double escaping then. Keeping the potential double escaping is the secure choice at this point in the late D7 cycle.

Let me know if you see the XSS trigger and where exactly!

damienmckenna’s picture