Defect #33846

Inline issue auto complete doesn't sanitize HTML tags

Added by Fernando Hartmann about 1 year ago. Updated 6 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Security
Target version:4.1.2
Resolution:Fixed Affected version:4.1.1

Description

If referring a issue that have a HTML tag in subject, the tag is rendered as an object in the auto complete tip.

To reproduce
  1. Create one issue with a subject like Test <select> tag
  2. Start a new issue, go to description field and type issue number created above
Result
  • We should display something like Feature #xxxx Test <select> tag
  • We display a select object rendered in the tip, like image bellow

This can be dangerous,as some one can inject HTML

tip.png (6.45 KB) Fernando Hartmann, 2020-08-12 19:26

sanitize_html.patch Magnifier (868 Bytes) Marius BALTEANU, 2020-10-05 22:51

autocomplete-by-title.png (56.7 KB) Go MAEDA, 2020-10-15 14:01

sanitize_html_v2.patch Magnifier (1.01 KB) Marius BALTEANU, 2020-10-16 07:47

tribute.png (132 KB) Marius BALTEANU, 2020-10-16 07:49

sanitize_html_v3.patch Magnifier (878 Bytes) Marius BALTEANU, 2020-10-16 08:01

test_for_33846.patch Magnifier (809 Bytes) Marius BALTEANU, 2020-12-05 18:10

sanitize_html_v4.patch Magnifier (2.18 KB) Go MAEDA, 2021-03-15 16:52


Related issues

Related to Redmine - Feature #31989: Inline issue auto complete (#) in fields with text-format... Closed

Associated revisions

Revision 20827
Added by Go MAEDA 6 months ago

Fix that inline issue auto complete does not sanitize HTML tags (#33846).

Patch by Marius BALTEANU.

Revision 20828
Added by Go MAEDA 6 months ago

Merged r20827 from trunk to 4.1-stable (#33846).

History

#1 Updated by Marius BALTEANU about 1 year ago

  • Assignee set to Marius BALTEANU

#2 Updated by Marius BALTEANU 12 months ago

  • Related to Feature #31989: Inline issue auto complete (#) in fields with text-formatting enabled added

#3 Updated by Marius BALTEANU 12 months ago

Fernando, thanks for catching this.

I've attached a patch to fix this issue.

#4 Updated by Marius BALTEANU 12 months ago

  • Assignee deleted (Marius BALTEANU)

#5 Updated by Go MAEDA 12 months ago

Marius BALTEANU wrote:

I've attached a patch to fix this issue.

Thank you for fixing the issue but I see <span> tags when using auto-complete by issue subject.

#6 Updated by Marius BALTEANU 12 months ago

  • Assignee set to Marius BALTEANU

Thanks for pointing this out, I was able to reproduce the problem. I will post soon a fix.

#7 Updated by Marius BALTEANU 12 months ago

Please try this new version, it should work as expected with one mention: the letters that match the search are no longer highlighted.

Also, instead of the sanitzeHTML function, I think it's better to use a library like https://lodash.com/docs/4.17.15#escape, but I'm not sure how to add it without copying the code or by using a module bundler like webpack. @Jean-Philippe, any recommendations on this?

#8 Updated by Marius BALTEANU 12 months ago

This one works on IE 11 as well.

#9 Updated by Marius BALTEANU 10 months ago

Attached is a test for this issue that can be applied only after #34123 is committed.

#10 Updated by Marius BALTEANU 10 months ago

  • File test_for_26089.patch.zip added

#11 Updated by Marius BALTEANU 10 months ago

  • File deleted (test_for_26089.patch.zip)

#13 Updated by Marius BALTEANU 10 months ago

  • Assignee set to Jean-Philippe Lang

#14 Updated by Marius BALTEANU 7 months ago

  • Assignee changed from Jean-Philippe Lang to Go MAEDA

#15 Updated by Go MAEDA 7 months ago

Update the patch for the latest trunk (r20791).

#16 Updated by Go MAEDA 6 months ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Committed the fix. Thank you all for your contribution.

#17 Updated by Go MAEDA 6 months ago

  • Subject changed from Inline issue auto complete (#) doesn't sanityze HTML tags to Inline issue auto complete doesn't sanitize HTML tags

#18 Updated by Holger Just 6 months ago

By the way: this a full-blown XSS vulnerability. With an issue subject such as

<span onmouseover="alert('pwned');">This is some exciting text</span>

arbitrary Javascript can be executed (as well as arbitrary HTML code shown). In my opinion, the assessment of the issue in Security_Advisories should therefore be increased to High.

#19 Updated by Marius BALTEANU 6 months ago

Holger Just wrote:

By the way: this a full-blown XSS vulnerability. With an issue subject such as

[...]

arbitrary Javascript can be executed (as well as arbitrary HTML code shown). In my opinion, the assessment of the issue in Security_Advisories should therefore be increased to High.

Thanks Holger, I've changed to High.

Also available in: Atom PDF